This domain is lightly tested in the CPSA-F exam, but understanding real-world examples deepens your grasp of all other domains. Architecture is best learned by studying how others have solved real problems โ€” and by understanding why they made specific trade-offs.

9.1 Styles vs. Patterns vs. Design Patterns

These terms are often confused. Understanding the distinction helps you communicate precisely:

Scope Hierarchy: Style โ†’ Pattern โ†’ Design Pattern Architectural Style Defines the overall shape and vocabulary of the entire system Examples: Client-Server, Layered Event-Driven, REST Pipe-and-Filter ๐Ÿ™ City Planning Level Architecture Pattern Solves a specific recurring problem at system/ subsystem level Examples: MVC, CQRS, Saga Circuit Breaker Strangler Fig ๐Ÿ  Building Level Design Pattern Solves a code-level design problem within a component Examples: Strategy, Observer Factory, Decorator Singleton, Adapter ๐Ÿงฑ Room/Fixture Level Wider scope โ†โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ†’ Narrower scope
ConceptScopeExamplesAnalogy
Architectural StyleHigh-level structural organization of the entire system.Client-server, layered, event-driven, REST, pipe-and-filterCity planning
Architecture PatternA proven solution for a specific recurring problem at system level.MVC, CQRS, Saga, Circuit Breaker, Strangler FigBuilding design
Design PatternA solution at the object/class level. Code-level design problems.Strategy, Observer, Factory, Decorator, SingletonInterior design
An architectural style defines the overall shape; an architectural pattern solves a specific structural problem within that shape; a design pattern solves a code-level problem within a component. You can mix styles and patterns โ€” e.g., a microservices style using CQRS pattern with Strategy design pattern inside each service.

9.2 Reference Architectures

Web Application (3-Tier)

The most common architecture for business applications. A presentation tier (browser/mobile), an application tier (business logic, stateless), and a data tier (database). The application tier is typically deployed as a single deployable unit (monolith) or a collection of services.

3-Tier Web Application Presentation Browser / Mobile React, Angular Flutter, Swift ๐ŸŒ CDN-served Application Business Logic REST API / GraphQL Stateless (scalable) โš–๏ธ Load balanced Data Persistence PostgreSQL, MongoDB Redis (cache) ๐Ÿ”„ Replicated HTTPS TCP Stateless app tier enables horizontal scaling behind a load balancer
Quality FocusArchitectural Tactic
ScalabilityStateless app tier โ†’ horizontal scaling behind a load balancer
AvailabilityMultiple app instances, database replication, health checks
SecurityHTTPS, authentication middleware, input validation, CORS
PerformanceCDN for static assets, caching layer (Redis), connection pooling

Event-Driven Architecture

Components communicate through events (facts about things that happened). Producers publish events to a broker (Kafka, RabbitMQ, AWS SNS/SQS); consumers subscribe and react. Strong decoupling, but adds complexity in debugging and consistency.

Event-Driven Architecture Order Svc Producer User Svc Producer ๐Ÿ“จ Event Bus Kafka / RabbitMQ / SNS+SQS Topics: orders.*, users.*, payments.* Notification Svc Analytics Svc Inventory Svc Producers don't know consumers โ€” new consumers can subscribe without changing producers
Quality FocusArchitectural Tactic
Loose couplingProducers don't know consumers; events are immutable facts
ScalabilityConsumers scale independently based on throughput needs
ResilienceMessages persist in broker even if consumer is temporarily down
ConsistencyEventual consistency; requires careful event ordering and idempotency

Batch Processing (ETL)

Scheduled jobs that extract data from sources, transform it, and load it into a destination. Uses pipes-and-filters pattern. Common in data warehousing, reporting, and data migration. Modern versions use tools like Apache Spark, AWS Glue, or dbt for SQL transformations.

Mobile + Backend for Frontend (BFF)

Instead of having mobile and web clients call the same generic API, each client type gets its own backend (BFF) tailored to its needs. The BFF aggregates, transforms, and optimizes data for its specific client. This prevents the "one API to rule them all" problem where the API becomes bloated trying to serve every client type.

9.3 Monolith vs. Microservices โ€” The Spectrum

This is one of the most debated topics in software architecture. The reality is that it's a spectrum, not a binary choice:

The Monolith-to-Microservices Spectrum Monolith Single deployable Simple ops Modular Monolith Clean modules Single deploy Service-Based Few coarse services (3-8) Micro- services Many small services (50+) โœ… Start here for most projects Move right ONLY when you have a clear need โ€” never start with microservices
Start with a well-structured modular monolith. Extract services only when you have clear domain boundaries, team boundaries, and a genuine need for independent deployment. You can always extract later โ€” you can't easily merge back.

Case Study: E-Commerce Platform

Consider an e-commerce platform like a simplified Amazon. Here's how architecture decisions map to quality requirements:

Service Boundaries (Domain-based decomposition)

E-Commerce Domain Decomposition ๐Ÿ“ฆ Catalog Products, Search Elasticsearch Read-heavy ๐Ÿ›’ Order Create, Track PostgreSQL + ACID Consistent ๐Ÿ“Š Inventory Stock levels Event-sourced Real-time ๐Ÿ’ณ Payment Stripe/PayPal Idempotent PCI isolated ๐Ÿ“ง Notify Email, SMS Fire-and-forget Eventually ๐Ÿ“จ Kafka Event Bus โ€” OrderPlaced ยท PaymentProcessed ยท StockReserved Each service owns its own database โ€” no shared databases Services communicate ONLY through events or explicit API calls Each service maps to one bounded context in DDD terminology

Key Architectural Decisions

DecisionRationaleTrade-off
Microservices over monolith5 teams of 6 devs each; independent deployment needed; different scaling needs per serviceOperational complexity; need investment in CI/CD, monitoring, tracing
Event bus (Kafka) between servicesLoose coupling; services can evolve independently; events provide audit trailEventual consistency; debugging is harder; event schema evolution
CQRS for Product Catalog10:1 read-to-write ratio; search requires different data model than catalog managementTwo data stores to maintain; sync lag between write and read
Saga for Order + Payment + InventoryNo distributed transaction; each service owns its dataCompensating transactions needed on failure; complex failure modes

Lessons Learned

  • Start with a monolith โ€” Extract services only when you have clear domain boundaries and team boundaries
  • Invest in observability early โ€” Distributed tracing (Jaeger/Zipkin), centralized logging (ELK), and metrics (Prometheus/Grafana) are prerequisites, not nice-to-haves
  • Event schema evolution is hard โ€” Use a schema registry (Avro/Protobuf) from day one
  • Test the failure modes โ€” What happens when Kafka is down? When a service is slow? Chaos engineering is not optional for microservices

Case Study: Legacy Modernization with Strangler Fig

A 15-year-old monolithic banking application needs modernization. Rewriting from scratch is too risky (the "big bang" approach has a high failure rate). Instead, use the Strangler Fig pattern:

Strangler Fig Pattern โ€” Gradual Migration Phase 1: Start Legacy Monolith (100% traffic) Phase 2: Extract Legacy (~70%) New Service (~30%) Phase 3: Complete Legacy (tiny) New Services (~95% traffic) Route traffic gradually from legacy to new services โ€” zero big-bang risk
  1. Put a proxy/facade in front of the monolith that routes all traffic
  2. Extract one capability at a time as a new service behind the proxy
  3. Route traffic gradually from legacy to new service (feature flags, canary releases)
  4. Repeat until the legacy monolith is empty (or contains only what doesn't justify migrating)

The Strangler Fig pattern is named after a tropical fig tree that grows around a host tree, eventually replacing it entirely. The key advantage: you're always in a working state โ€” there's no "construction period" where nothing works.


Summary

ConceptKey Takeaway
Style vs. Pattern vs. Design PatternStyle = system shape; Pattern = subsystem solution; Design Pattern = code-level solution
3-Tier WebMost common reference architecture; stateless app tier enables horizontal scaling
Event-DrivenLoose coupling via events; eventual consistency; great for integration
Monolith SpectrumStart modular monolith โ†’ extract services only when needed
Strangler FigGradual migration from legacy โ€” always in a working state
Architecture decisionsEvery decision is a trade-off โ€” document the rationale, not just the choice