Architectural styles in system design
Architectural styles are reusable families of system organization patterns (like layered, client–server, microservices, pipe-and-filter) that guide how components connect, how data flows, and what non-functional properties (scalability, modifiability, availability) a system will have.
Drafted with Aria, reviewed by the AiCanCode.org team · Updated . How we write and check our notes. Spotted an error? Use Give Feedback at the bottom of the page.
Why it matters
Architectural styles help engineers choose a high-level structure for a system before writing detailed designs or code. They directly affect non-functional properties such as scalability, maintainability, performance, and reliability, so choosing the right style is one of the earliest and most important system design decisions.
Key ideas
Begin with definitions. Define each bold term before it is used.
- Architecture (software system): the set of principal design decisions about the organization of a software system, expressed as components (modules), their externally visible properties, and the relationships and interactions among them.
- Architectural style: a family of systems in which components and their connectors follow a common pattern of organisation and interaction. An architectural style defines allowed component types, connector types, and constraints on composition.
- Component: a modular, replaceable, independent unit with defined interfaces. It performs computation or stores data.
- Connector: a communication mechanism that controls interaction between components (examples: procedure call, message passing, shared data).
- Interface: the exposed operations and data formats a component supports.
- Non-functional property: a quality attribute of the system (examples: performance, scalability, availability, modifiability).
Core idea: an architectural style is a template that constrains component types and connectors to yield predictable properties. Think of it like a set of rules or a grammar for building systems.
Common styles (for each: define, assumptions, how to draw):
Layered style
- Definition: Components are arranged in horizontal layers. Each layer provides services to the layer above and uses services from the layer below.
- Assumptions: strict ordering of abstraction; communication mostly between adjacent layers (or allowed only to immediate neighbour in strict layering).
- To draw: draw horizontal bands labelled (top to bottom) Presentation, Application (or Business), Domain/Logic, Persistence/Database. Optionally show Platform/OS below as an underlying platform (not counted as an application layer). Draw arrows downward from a higher layer to the layer it calls.
- Key consequences: promotes separation of concerns and modifiability; can add caching layers; may reduce performance due to many hops.
Client–Server style
- Definition: The system has distinct client components (requesters of service) and server components (providers of service). Communication is typically request–response.
- Assumptions: clear requester/provider roles; servers can be replicated; state may be centralised or distributed.
- To draw: place clients on left, servers on right; draw arrows from each client to server(s) labelled "request" and returning arrows labelled "response".
- Consequences: easy to scale servers; single point of failure if server is not replicated; simple mapping to web applications.
Pipe-and-Filter style
- Definition: Data streams pass through a sequence of processing elements called filters. Each filter transforms the data; filters are connected by pipes that carry data streams.
- Assumptions: data can be processed incrementally; transformations are independent; data format contract between adjacent filters.
- To draw: draw boxes in a horizontal sequence labelled Filter1, Filter2, ... and arrows (pipes) between them showing flow left-to-right.
- Consequences: high reuse of filters, easy to parallelise; not suitable if filters need shared state.
Event-driven (pub–sub) style
- Definition: Components produce and consume events. A broker or message bus dispatches events to subscribers.
- Assumptions: decoupling of producers and consumers; eventual consistency acceptable for many use cases.
- To draw: draw event producers, an event bus/broker in the centre, and subscribers with arrows: producers -> bus -> subscribers.
- Consequences: high decoupling and scalability; harder to reason about end-to-end timing and ordering.
Microkernel (plug-in) style
- Definition: A small, minimal core system (the microkernel) provides core services; additional functionality is implemented as plug-in modules.
- Assumptions: core must be stable and small; plug-ins communicate via well-defined extension points.
- To draw: draw a small central box labelled Microkernel and several boxes around labelled Plug-in1, Plug-in2 with arrows to/from kernel.
- Consequences: good for extensibility and product-line engineering; can be complex to design stable extension points.
Microservices
- Definition: An application decomposed into small, independently deployable services. Each service owns its data and provides a business capability.
- Assumptions: independent deployment pipelines; network communication between services; services are loosely coupled.
- Draw: many small service boxes, each with its own database, connected via API gateway or service mesh.
- Consequences: highly scalable and independently deployable; added complexity (distributed transactions, operational overhead).
Repository style
- Definition: Many components interact through a shared repository (central data store). Components read and write to the repository.
- Assumptions: centralised data model; components tolerate shared-state coupling.
- Draw: large central database/repository and many components around it with arrows to/from the repository.
- Consequences: easy data sharing and analysis; repository can become a bottleneck and single point of failure.
Broker style
- Definition: A broker component mediates communication and coordination between heterogeneous components, translating requests and forwarding them to appropriate servers.
- Assumptions: heterogeneous components need interoperability; brokering logic centralises communication.
- Draw: clients/components -> broker <- servers, with the broker in the middle.
- Consequences: decouples clients and servers and supports heterogeneity and location transparency; introduces an extra hop and potential bottleneck; broker can become a single point of failure unless replicated.
For each style universities expect: definition, diagram, assumptions, advantages, disadvantages, and at least one real-world example (a sentence).Give those for 2–3 styles in an exam.
Formulas
Availability = MTTF / (MTTF + MTTR) — MTTF = mean time to failure (seconds), MTTR = mean time to repair (seconds). Applies to a single component system to estimate steady-state availability.
Reliability(t) = e^(−λ·t) — λ = failure rate (s⁻¹), t = time (s), reliability unitless (probability). Applies when failures are Poisson processes and constant failure rate.
Service rate (μ) = 1 / (average service time per request), and in a stable single-server system the throughput X ≤ μ (X ≈ μ only when the server is fully utilized). Units: requests per second (s⁻¹).
Latency_total ≈ network_latency + service_time + queueing_delay — each term in seconds (s). Applies for estimating end-to-end request time.
(These performance/availability formulas are basic approximations architects use when comparing architectures.)
Worked examples
Example 1 — Long-answer exam question (model answer): Question: Define the layered architectural style. Draw the standard four-layer layout and explain advantages and disadvantages. Model answer (step-by-step):
- Definition: "The layered architecture organises a system into horizontal layers where each layer provides services to the layer above and consumes services from the layer below." (Bold the term.)
- Draw: four horizontal bands labelled (top to bottom) Presentation, Application/Business Logic, Domain/Model, Persistence/Database. Add arrows showing calls from top to next layer only.
- State assumptions: adjacency calls allowed only; interfaces between layers are stable.
- Advantages: separation of concerns, easier to change implementation of one layer, testability.
- Disadvantages: possible performance overhead, sometimes artificial separation, changes in lower layers may ripple upward.
- Real-world example: traditional desktop applications and many enterprise systems.
Example 2 — Design decision question (numerical-style reasoning): Question: A web-based e-commerce system must support 1000 concurrent users, allow independent deployment of catalog and payment functions, and must be fault tolerant. Recommend an architectural style and justify. Answer (stepwise):
- Constraints: concurrency 1000, independent deployability, fault tolerance.
- Candidate styles: monolithic layered, client–server, microservices. Evaluate:
- Monolithic: simpler, but independent deployment and fault isolation poor.
- Microservices: services can be independently deployed (meets requirement), services can be replicated for fault tolerance and scaling (meets concurrency), but operational complexity increases.
- Recommendation: Microservices with API gateway, separate databases for Catalog and Payment (to allow independent scaling), and load balancers. Use circuit breakers and retries to improve fault tolerance.
- Short mapping: Service A (Catalog) -> stateless, replicate N instances behind LB; Service B (Payment) -> isolated DB, stricter security.
- Justify trade-offs: increased operational cost accepted for required properties.
Example 3 — Trace for pipe-and-filter (algorithmic trace): System: Log-processing pipeline with filters: ReadLines -> ParseJSON -> FilterErrors -> AggregateByService -> StoreCSV. Input: three lines (1) valid JSON info, (2) valid JSON error, (3) malformed line. Trace steps: list each filter with input and output; show filter 1 yields three items, ParseJSON converts items 1 and 2 to objects and produces an error token for item 3, FilterErrors emits only item 2, AggregateByService groups counts {ServiceX:1}, StoreCSV writes a one-row CSV. End state: CSV file with 1 error count. This demonstrates how filters drop, transform, and aggregate data.
Common mistakes
- Confusing layered architecture with network protocol stack (OSI): they are conceptually similar but OSI is a communication stack, not an application layering solution.
- Drawing layers with bidirectional arrows everywhere — strict layered style restricts interaction to adjacent layers (exams may require you to state whether you assume strict or relaxed layering).
- Forgetting to state assumptions (e.g., whether services are stateful or stateless) when arguing about scalability and availability.
- Treating event-driven systems as synchronous request–response systems; you must explain eventual consistency and ordering concerns.
For your exam
Question types: definitions, short notes (advantages/disadvantages), diagrams, compare & contrast two styles, choose architecture for given requirements and justify, trace data flow in a style, list non-functional effects. What a full-marks answer includes:
- Clear definition of the style with bold definition term.
- A labeled diagram described exactly (or drawn if exam allows diagrams).
- Explicit assumptions the style makes about communication, state, and component life-cycle.
- Two or three clear advantages and two or three disadvantages with one-line explanations each.
- One concrete example mapping (e.g., map system modules to layers or services).
- If asked to choose a style for requirements: list constraints, shortlist candidate styles with reasoning, make a recommendation and describe how you would realise it (load balancing, replication, database strategy, communication patterns).
Quick check
- Define "architectural style" in one sentence.
- List two advantages and one major disadvantage of the microservices style.
- Draw (describe how to draw) a pipe-and-filter diagram for a three-stage data transformation pipeline. Answers: 1) An architectural style is a reusable pattern that prescribes component types and connectors and constraints for organising systems. 2) Advantages: independent deployability and fine-grained scalability; disadvantage: increased operational complexity due to distributed-system concerns. 3) Draw three boxes in sequence labelled Filter1 -> Filter2 -> Filter3, connect them left-to-right with arrows labelled Pipes indicating data flow; label inputs on the left and outputs on the right.
Finished this topic? Mark it so your progress, study plan and readiness keep up.
Stuck on something here?