Examples & Case Studies
Reference architectures, the distinction between styles, patterns, and design patterns, real-world case studies, and migration strategies โ architecture learned through practice.
Architectural Styles vs. Patterns vs. Design Patterns
These three terms are often confused. They operate at different levels of scope โ from the shape of the entire system down to code-level solutions within a single component.
Architectural Style
- Defines the overall shape and vocabulary of the entire system
- Client-server, layered, event-driven, REST, pipe-and-filter
- Analogy: city planning
Architecture Pattern
- Solves a specific recurring problem at the system/subsystem level
- MVC, CQRS, Saga, Circuit Breaker, Strangler Fig
- Analogy: building design
Design Pattern
- Solves a code-level design problem within a component
- Strategy, Observer, Factory, Decorator, Singleton
- Analogy: interior design
- Architectural Style โ defines the overall shape and vocabulary of the entire system (city planning)
- Architecture Pattern โ a proven solution for a recurring problem at the system/subsystem level (building design)
- Design Pattern โ a code-level solution within a single component (interior design)
- Wider scope โ narrower scope: Style โ Pattern โ Design Pattern
- You can combine styles and patterns freely within one system
Common Reference Architectures
Reference architectures are proven blueprints for common application types. They provide a starting point โ not a rigid prescription โ that you adapt to your specific requirements and constraints.
3-Tier Web Application
- Presentation โ Application โ Data
- Stateless app tier enables horizontal scaling
Event-Driven Architecture
- Components communicate through events via a broker
- Strong decoupling, eventual consistency
Batch Processing (ETL)
- Extract โ Transform โ Load pipelines
- Pipes-and-filters pattern for data processing
Backend for Frontend (BFF)
- Each client type gets its own tailored backend
- Prevents bloated "one API for all" syndrome
The most common architecture for business applications โ a presentation tier, a stateless application tier, and a data tier.
| Quality Focus | Architectural Tactic |
|---|---|
| Scalability | Stateless app tier โ horizontal scaling behind a load balancer |
| Availability | Multiple app instances, database replication, health checks |
| Security | HTTPS, authentication middleware, input validation, CORS |
| Performance | CDN for static assets, caching layer (Redis), connection pooling |
Components communicate through events โ immutable facts about things that happened. Producers publish events to a broker; consumers subscribe and react independently.
| Quality Focus | Architectural Tactic |
|---|---|
| Loose Coupling | Producers don't know consumers; events are immutable facts |
| Scalability | Consumers scale independently based on throughput needs |
| Resilience | Messages persist in broker even if a consumer is temporarily down |
| Consistency | Eventual consistency โ requires careful event ordering & idempotency |
- 3-Tier Web: Presentation โ stateless application โ data; most common reference architecture
- Event-Driven: Components communicate through events via a broker โ loose coupling, eventual consistency
- Batch (ETL): Extract โ Transform โ Load pipelines using the pipes-and-filters pattern
- BFF: Each client type (web, mobile) gets its own tailored backend API
- Reference architectures are starting points โ adapt them to your specific constraints
Monolith vs. Microservices โ The Spectrum
This is not a binary choice. The reality is a spectrum โ from a single deployable monolith all the way to hundreds of fine-grained microservices. Start simple and evolve when you have a clear need.
- Monolith vs. microservices is a spectrum, not a binary choice
- Start with a modular monolith โ extract services only when you have a clear need
- Moving right on the spectrum adds operational complexity (CI/CD, monitoring, tracing)
- You can always extract later โ you can't easily merge back
Case Studies
Architecture is best learned by studying how others have solved real problems โ and by understanding why they made specific trade-offs. Every decision has consequences.
An e-commerce platform (simplified Amazon). Here's how architecture decisions map to quality requirements and trade-offs.
| Decision | Rationale | Trade-off |
|---|---|---|
| Microservices | 5 teams, independent deployment, different scaling needs | Operational complexity; CI/CD, monitoring, tracing investment |
| Kafka Event Bus | Loose coupling; independent evolution; audit trail | Eventual consistency; harder debugging; schema evolution |
| CQRS for Catalog | 10:1 read-to-write ratio; different data models | Two data stores to maintain; sync lag |
| Saga for Order flow | No distributed transactions; each service owns its data | Compensating transactions on failure; complex failure modes |
A 15-year-old monolithic application needs modernization. Rewriting from scratch is too risky. Instead, use the Strangler Fig pattern โ gradually replace pieces while the system stays fully operational.
- Put a proxy/facade in front of the monolith that routes all traffic
- Extract one capability at a time as a new service behind the proxy
- Route traffic gradually โ feature flags, canary releases
- Repeat until the legacy monolith is empty
- Start with a monolith โ extract only when domain and team boundaries are clear
- Invest in observability early โ distributed tracing, centralized logging, metrics
- Event schema evolution is hard โ use a schema registry from day one
- Test failure modes โ chaos engineering is not optional for distributed systems
- E-Commerce case study: domain-driven decomposition, event bus, CQRS, Saga โ every decision is a trade-off
- Strangler Fig: gradual migration from legacy โ always in a working state, zero big-bang risk
- Named after a tropical fig that grows around a host tree, eventually replacing it entirely
- Every architecture decision is a trade-off โ document the rationale, not just the choice
Styles vs Patterns
- Style = system shape (city planning)
- Pattern = subsystem solution (building design)
- Design Pattern = code-level (interior design)
Proven Blueprints
- 3-Tier: stateless app tier โ horizontal scaling
- Event-Driven: loose coupling via broker
- ETL & BFF for specialized use cases
Monolith โ Microservices
- It's a spectrum, not a binary choice
- Start modular monolith, extract when needed
- You can extract later; can't merge back
Real-World Lessons
- Domain decomposition with event bus
- Strangler Fig for gradual migration
- Every decision is a trade-off โ document why