Fundamentals 17 min read

Stop Chasing Frameworks: Master These 7 Architecture Patterns First

This article breaks down seven practical software‑architecture patterns—Bounded Context, Sidecar, Publisher‑Subscriber, Application Gateway, Microservices, Micro‑frontends, and CQRS/Event Sourcing—showing how they can be combined in a real e‑commerce system and guiding architects on when each pattern best solves complexity, performance, or team‑collaboration challenges.

DeepNoMind
DeepNoMind
DeepNoMind
Stop Chasing Frameworks: Master These 7 Architecture Patterns First
Software architecture has no silver bullet, but a practical set of pattern combinations can balance complex business, rapid iteration, and team collaboration. This article explains seven common architecture patterns and demonstrates how they cooperate within a single e‑commerce system.

1. Bounded Context

Many projects start as a monolith—single codebase, single database, all domain concepts mixed. Over time the following problems appear:

The same term means different things in different modules (e.g., “order” in risk, settlement, customer service).

Changing a small requirement forces edits across a tangled codebase.

Splitting services becomes unclear.

Bounded Context defines clear boundaries for these concepts:

Each context focuses on a small business area such as product catalog, order flow, payment, or account & permission.

Within a context, terminology, data structures, and business rules are unified.

Contexts communicate via explicit interfaces or messages.

Implementation at the code level:

Split directory structure, modules, or services by business context.

Each context owns its domain model, use cases, and infrastructure.

Future microservice or modular migration follows these natural splits.

Applicable scenarios:

Medium‑high business complexity with many concepts (e‑commerce, finance, SaaS platforms).

Feeling that “one change ripples the whole system” but not yet ready for microservices.

Preparing for future service or team decomposition.

E‑commerce system bounded contexts
E‑commerce system bounded contexts

2. Sidecar

Legacy core systems are often built on outdated stacks, stable for years, and difficult to modify, yet they need added cross‑cutting capabilities such as authentication, logging, monitoring, and rate limiting.

The Sidecar pattern deploys a companion process alongside the main application to handle traffic or common capabilities:

All traffic first passes through the Sidecar, then is forwarded to the main app.

The Sidecar implements auth, access control, logging, circuit breaking, retries, and rate limiting.

The main app remains unchanged while gaining a full suite of shared abilities.

In Kubernetes, a Service Mesh pushes a Sidecar to every pod, making all inter‑service communication go through it for unified encryption, monitoring, and rate limiting.

Legacy systems that cannot be easily modified but need added security or observability.

Multi‑language, multi‑stack environments that require a common implementation of cross‑cutting logic.

Sidecar pattern diagram
Sidecar pattern diagram
Service mesh architecture
Service mesh architecture

3. Publisher‑Subscriber

When many synchronous HTTP calls exist, upstream failures cascade downstream, and scaling, rate limiting, and circuit breaking become complex.

The Publisher‑Subscriber pattern uses a message broker to decouple senders and receivers:

Publisher only posts messages to a topic, unaware of consumers.

Subscriber only consumes messages of interest, processing them asynchronously.

Two delivery mechanisms are common:

Competing Consumers : one consumer in a consumer group processes each message, enabling parallel work across multiple workers.

Fan‑out : the same message is delivered to multiple subscribers, suitable for broadcasting events to several downstream systems.

Applicable scenarios:

Long‑running asynchronous tasks (e.g., report generation, email/SMS sending).

Business events that need to notify multiple downstream services (e.g., order paid → inventory, logistics, marketing).

Desire to decouple systems and improve overall fault tolerance.

Publisher‑Subscriber diagram
Publisher‑Subscriber diagram
Publisher‑Subscriber delivery mechanisms
Publisher‑Subscriber delivery mechanisms

4. Application Gateway

When the number of back‑end services grows, exposing each directly leads to many domains/ports for front‑ends and complex unified security configuration.

The Application Gateway provides a single entry point:

Clients access one domain, e.g., api.example.com.

The gateway routes requests to specific back‑ends based on path, host, header, etc.

It also handles SSL termination, WAF, anti‑crawling, rate limiting, black/white lists, and unified authentication.

Compared with traditional layer‑4 load balancers, the gateway works at layer‑7 (HTTP), enabling business‑aware routing and policies.

Applicable scenarios:

Exposing many back‑ends behind one or a few domains.

Need for unified security, traffic governance, and monitoring.

Application gateway routing
Application gateway routing

5. Microservices

Microservices break an application into a set of small, independent services:

Each service has its own API and database.

Services communicate via network protocols, allowing independent deployment and scaling.

Different services can use different technology stacks and storage solutions.

Practical pitfalls include:

Distributed transactions and data consistency become harder.

Debugging and troubleshooting costs increase dramatically.

Deployment, monitoring, and configuration management complexity spikes.

Thus microservices represent a trade‑off package: higher operational complexity in exchange for better parallel development, independent deployment, and scalability.

Applicable scenarios (when truly needed):

Different business modules have distinct performance, scalability, or high‑availability requirements.

Different teams need relatively independent iteration of their modules.

A clear bounded‑context division and mature DevOps practices already exist.

If the application is not complex and the team is small, a well‑structured monolith combined with bounded contexts and modularization is often more pragmatic.

Microservices architecture
Microservices architecture

6. Micro‑frontends

Large web applications maintained by multiple long‑term teams face build slowdown, repository conflicts, and inconsistent lifecycles.

The Micro‑frontends idea is:

Split a web front‑end into several independent “mini‑apps”.

Each mini‑app owns a functional area and has its own release cadence.

A portal or shell composes them into a unified UI.

With Web Components and similar standards, each micro‑frontend can even use a different framework as long as it exposes a unified component interface.

Applicable scenarios:

Large web applications maintained by multiple teams.

Desire for independent release and rollback of different business modules.

Front‑end codebase growing too large for a single repository.

Micro‑frontend architecture
Micro‑frontend architecture

7. CQRS & Event Sourcing

In many systems, read requests far outnumber writes, or read and write concerns differ completely.

CQRS (Command Query Responsibility Segregation) proposes:

Separate models (and possibly data stores) for writes (commands) and reads (queries).

Write side focuses on correctness, business rules, and transactional consistency.

Read side focuses on query efficiency, reporting needs, and multidimensional views.

When combined with Event Sourcing :

The write side stores an immutable sequence of events (e.g., “account credited 100”, “account debited 30”).

Current state is reconstructed by replaying events.

Any point in time can rebuild different views, providing strong audit capability.

Applicable scenarios:

Systems with extremely high performance, scalability, or audit‑tracking requirements (e.g., payments, risk control).

Read‑heavy workloads where read and write models differ.

CQRS + Event Sourcing have very high learning and maintenance costs; avoid unless the benefits clearly outweigh the overhead.

CQRS architecture
CQRS architecture
Different CQRS architectures
Different CQRS architectures
Event sourcing CQRS architecture
Event sourcing CQRS architecture

8. Polyglot Architecture

In a real e‑commerce system, the above patterns are often used together rather than choosing a single one:

Use Bounded Context to split domains such as product, order, payment, and account.

Within each context, optionally apply Microservices for further isolation.

Front‑end teams employ Micro‑frontends to compose pages.

Cross‑context event synchronization uses Publisher‑Subscriber and a message broker.

Expose a single domain externally via an Application Gateway that routes requests to various back‑ends.

Critical core paths leverage CQRS / Event Sourcing for auditability and traceability.

Legacy or third‑party services are wrapped with a Sidecar to add security and observability.

This combination is called Polyglot Architecture :

It does not cling to a single “unified architecture style”.

Each bounded context selects the most suitable pattern and technology stack.

E‑commerce polyglot architecture
E‑commerce polyglot architecture

Conclusion

When designing architecture, ask three questions:

What is the biggest pain point of the current business – complexity, performance, availability, or team collaboration?

Where does the existing architecture clearly fall short?

If a pattern is introduced, which problems does it specifically alleviate, and what new complexities does it introduce?

Understanding patterns provides more tools for critical decisions, not a collection of flashy tricks. Always start from the problem, then choose the simplest viable pattern combination.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

Design PatternsSoftware ArchitecturemicroservicesCQRSsidecarevent sourcingbounded contextpolyglot architecture
DeepNoMind
Written by

DeepNoMind

I’m Yu Fan, a tech leader with deep technical expertise and managerial vision. Formerly at Motorola, now at Mavenir, I’ve led teams for years, focusing on backend architecture and cloud-native solutions, staying abreast of AI and other frontier fields, and championing personal growth and lifelong learning.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.