Skip to content

Architecture Patterns

Choosing an architecture is the highest-leverage decision you make on a project. Get it right and your team ships features for years without drowning in complexity. Get it wrong and you spend eighteen months on a rewrite that was avoidable on day one.

The problem is that most architecture content either floats at 30,000 feet ("microservices are about bounded contexts!") or drowns in implementation details without explaining when or why. This section bridges that gap. Every pattern here includes a decision framework — the specific conditions under which it shines, the conditions under which it becomes a liability, and the migration path if you need to switch.

The Architecture Decision Framework

Before diving into any pattern, ask these five questions about your system:

  1. Team size and structure — How many engineers? How many teams? Are they co-located?
  2. Change velocity — Which parts of the system change daily? Which parts are stable for months?
  3. Scale profile — What needs to scale independently? Read-heavy? Write-heavy? Bursty?
  4. Consistency requirements — Can you tolerate eventual consistency, or do you need strong guarantees?
  5. Operational maturity — Do you have monitoring, CI/CD, and on-call in place?

Decision Matrix

PatternBest WhenAvoid WhenTeam SizeOperational Overhead
MicroservicesIndependent team scaling, polyglot needs, different release cadencesSmall team, early-stage product, unclear domain boundaries20+ engineersHigh
Event-DrivenAsync workflows, audit trails, system decoupling, real-time reactionsSimple CRUD, strong consistency required everywhere5+ engineersMedium-High
CQRS & Event SourcingComplex domains with audit needs, different read/write scaling, temporal queriesSimple domains, small data sets, teams unfamiliar with eventual consistency5+ engineersHigh
Hexagonal ArchitectureLong-lived applications, multiple integrations, high testability requirementsPrototypes, throwaway scripts, very small scope2+ engineersLow
Clean ArchitectureComplex business logic, framework independence, large codebasesSimple CRUD apps, tight framework coupling is acceptable3+ engineersLow-Medium
Domain-Driven DesignComplex business domains, domain expert collaboration, large systemsWell-understood simple domains, purely technical infrastructure5+ engineersMedium
Design PatternsCode-level structure, testability, extensibility, team communicationOver-engineering simple code, pattern hunting1+ engineersLow
Cloud-NativeElastic scaling, resilience, independent deployability, managed servicesOn-premises only, simple apps, no operational maturity5+ engineersMedium-High

Concept Map

How the Patterns Relate

These patterns are not mutually exclusive — they operate at different levels of abstraction. Domain-Driven Design is a strategic approach to understanding your problem space. Hexagonal and Clean Architecture are structural patterns for organizing code within a single deployable unit. Microservices is a deployment and team-scaling strategy. Event-Driven is a communication pattern. CQRS and Event Sourcing are data patterns.

The most effective architectures layer these together. A mature system might use DDD to discover bounded contexts, clean architecture inside each service, microservices for deployment, event-driven communication between them, and CQRS for the few services that genuinely need separate read and write models. Design Patterns operate at the code level — they are the building blocks (Factory, Strategy, Repository, Decorator) that implement the internals of every higher-level pattern. Cloud-Native patterns operate at the infrastructure level — they provide the resilience (Circuit Breaker, Retry, Saga), deployment (serverless, containers), and operational strategies that make distributed architectures production-ready.

Learning Path

Architecture patterns build on each other. Learn them in this order to avoid applying distributed solutions to problems that don't need them.

OrderPatternWhy This Order
1SOLID PrinciplesCode-level foundation — every other pattern assumes you understand SRP, OCP, DIP
2Design PatternsGoF patterns — Strategy, Observer, Factory, Decorator. The vocabulary for the rest
3Clean ArchitectureStructuring a single application — dependency rule, use cases, boundaries
4Hexagonal ArchitecturePorts and adapters — isolating business logic from frameworks and infrastructure
5Domain-Driven DesignModeling complex domains — aggregates, bounded contexts, ubiquitous language
6MicroservicesDecomposing a system into services — only after you've mastered the monolith
7Event-Driven ArchitectureAsync communication between services — events, commands, choreography vs orchestration
8CQRS & Event SourcingSeparating reads from writes, audit logs, temporal queries
9Cloud-NativeDesigning for Kubernetes, managed services, elastic scale
10Functional ProgrammingImmutability, pure functions, composition — reduces entire classes of bugs
11Multi-TenancySaaS architecture — data isolation, tenant routing, feature flags per tenant

The Golden Rule

Master steps 1–5 before touching 6+. Most teams jump to microservices while their single application is still a mess. The patterns at the top of this list pay dividends at every scale; the patterns at the bottom only pay off at sufficient complexity.

How to Use This Section

Each pattern page includes: a first-principles explanation of the core idea, a TypeScript reference implementation, a decision checklist (should you use this?), common anti-patterns and pitfalls, and a migration guide for introducing the pattern into an existing codebase. Read the patterns that match your current needs first, then read the others to understand the trade-offs you are implicitly making.

"What I cannot create, I do not understand." — Richard Feynman