Architecture
Last updated
An architecture is the big shape of a system: what the main parts are and how they connect. A few shapes come up again and again, and each makes some things easy and others hard. In this lesson you'll follow one text message through Pila's parts, meet clients and servers, layers, monoliths and services, and see why the right shape depends on the qualities the system needs.
By the end of this lesson you can
- Describe client and server, layers, a monolith and services
- Trace one request through a system's parts
- Explain why quality attributes, not fashion, should drive the architecture
Follow one text message
Before naming shapes, look at one. Here is Pila's architecture, as one text from Lola Remy passes through it. It's drawn as a UML sequence diagram, which lesson 4.4 explains: each part is a column, and time runs down the page. Walk through it.
Press Walk through it to follow the messages in time order, one stop at a time.
- Lola Remy texts PILA to the SMS gateway, without waiting.
- The gateway calls Pila’s web server (POST /v1/tickets), which calls the queue rules: take_number(phone).
- The queue rules save ticket 38 in the database, which replies.
- Replies go back up: 38 to the web server, 201 and the reply text to the gateway, and a text to Lola Remy.
- Separately, the waiting-room screen asks the web server who’s being served (GET /v1/queue/now), and gets the answer.
Five parts, each with one job. Lola Remy sees none of them.
Clients, servers and layers
Two shapes are already in that picture.
Client and server. A client asks; a server answers. The waiting-room screen is a client of Pila's web server; so is the SMS gateway, when it passes on a text. Pila is itself a client of the gateway when it sends a reply. Most systems you use are clients and servers, talking over a network.
Layers. Inside Pila's server, the code is arranged in layers, each using only the one below:
| Layer | Its job | Knows nothing about |
|---|---|---|
| Web (top) | Turn requests into calls, and results into replies | The queue rules’ details |
| Queue rules | Who gets which number, the limit, the priority lane | Web requests, or how data is stored |
| Storage (bottom) | Save and load tickets in the database | Why the rules want them |
Layers keep a change in one place. If the centre's closing time changes, only the queue rules change. If the database changes, only storage changes.
One program, or several?
A monolith is a system built and run as one program, even if its code is in tidy layers and modules. A services architecture (often called microservices when the services are small) splits it into several programs that talk over the network: a queue service, an SMS service, a reporting service, each deployed on its own.
Martin Fowler and James Lewis describe services as a way to let many teams change and release parts independently. The price is high: network calls that can fail or be slow, data split across services, and many more things to deploy, monitor and keep in step. Fowler's advice, "MonolithFirst", is that most systems that succeeded with services started as a monolith and split later, once the boundaries were understood.
0 of 5 placed right
Two developers build and run everything
Testing the whole flow from text to reply on a laptop
Fifty teams each releasing their own part daily without waiting for each other
One part needs a hundred times the computing power of the rest
Finding out why a reply was slow
A third shape, event-driven, has parts announce what happened ("number 38 was called") so any interested part can react without being asked. It suits systems where many parts must react to the same events. Pila might use it one day to add vaccination reminders without touching the queue.
Qualities drive the shape
Why is Pila a small monolith in layers? Not because monoliths are better. Bass, Clements and Kazman's Software Architecture in Practice argues that an architecture is chosen to meet quality attributes: the non-functional requirements of lesson 3.6.
- Performance (300 texts an hour): easily met by one program and one database.
- Reliability (up on 99.5% of mornings): fewer moving parts means fewer things to fail.
- Maintainability (two developers): one codebase they can hold in their heads.
- Cost: one small server, within the barangay's budget.
A national queue system for every health centre would weigh those differently, and might rightly be split. The same reasoning, different requirements, a different shape.
Spot the trap: ten services for two people
Marco has been reading about how a famous streaming company built its system. He draws Pila as ten microservices: tickets, texts, screen, staff, reports, and five more.
What happens if…
Check what you learned
Sources
Every claim on this page comes from these sources: the standard, the founding text of a method, a study, or the official record of a project, from the body that publishes it. Industry reports are labelled as such.
- Bass, Clements and Kazman, Software Architecture in Practice, 4th edition (2021): quality attributes as what drives architecture
- Martin Fowler and James Lewis: Microservices: what microservices are, and what they cost
- Martin Fowler: MonolithFirst: why many successful systems start as one program
- ISO/IEC/IEEE 42010:2022, Architecture description: what an architecture is, and describing it for its stakeholders