Systems, boundaries and architecture
Parts that work together
Section titled “Parts that work together”A system is a set of parts that work together to do something none of them does alone. An online shop is a system: a web application, a database of products, a payment provider, an email service, and the browser of the customer who is buying. Take any one of them away and the shop is no longer a shop.
Three things describe a system: its components, the connections between them, and its purpose. Components are the parts. Connections are who asks whom for what. The purpose is the reason anyone built it, and it is the only thing that tells you whether a part belongs.
Mental model. To understand a system, draw its parts, draw the arrows between them, and write down what it is for. If you cannot do all three, you do not yet understand it.
Draw it
Section titled “Draw it”Here is the shop as a picture. Each box is a component and each arrow means “sends requests to”.
Text version of the diagram
- Customer's browser (outside Our system) sends requests to Shop application.
- Shop application (inside Our system) sends requests to Product database, Payment provider, Email delivery service.
- Product database (inside Our system) does not call another component.
- Payment provider (outside Our system) does not call another component.
- Email delivery service (outside Our system) does not call another component.
The dashed region is the boundary of the system. Everything in it is what the shop’s team builds and runs. Everything outside it is something the shop uses, or someone who uses the shop.
The boundary is a choice, and it decides what you can fix
Section titled “The boundary is a choice, and it decides what you can fix”The boundary of a system separates what its team builds, runs and answers for from everything else. There is no natural line in the world. Someone draws it, and where they draw it matters, because it decides what you can change.
- Inside, you control the behaviour. When something breaks you can read the logs, change the code, and ship a fix.
- Outside, you can only observe, ask, and wait.
Three kinds of thing sit outside:
- Dependencies: things your system calls, and which someone else runs. The payment provider and the email service are dependencies.
- Users: the people and programs that call your system. A customer’s browser is a user, and so is a partner’s script that places bulk orders. You do not choose how they behave.
- Everything else that shapes the system without being part of it: the network between the parts, the company’s rules, the market.
To decide where a thing belongs, ask two questions: who runs it? and who is called when it breaks? The answer is not the company’s organisation chart. A stock system run by another team in the same company is outside your boundary, because that team fixes it on its schedule, not yours.
Try drawing it
Section titled “Try drawing it”Sort nine things around the shop into the right place. A few of them were not drawn in the picture, which is what happens to dependencies in real life.
Challenge
Where is the boundary?
A system's boundary separates what its team builds, runs and answers for from everything else. Sort each of these into the right place for the online shop in the diagram above.
Sorting needs JavaScript.
Categories
- Inside our system
- We build it, run it, and answer for it when it breaks.
- Outside: something we depend on
- Someone else runs it. When it breaks we are affected, and we cannot fix it ourselves.
- Outside: whoever uses the system
- They send requests. We do not control how they behave.
Check your answers at least once before looking at the answers.
What happens if the payment provider is down?
Section titled “What happens if the payment provider is down?”The shop’s own code is correct. The application is running and the product database is healthy. Customers still cannot pay.
The arrow from the application to the payment provider crosses the boundary. Every arrow that crosses the boundary is a dependency, and a system cannot be more available than the things it cannot do without. If the provider is down 0.1% of the time (99.9% available, about 8.8 hours a year) and checkout needs it, checkout is down at least that long, whatever happens inside.
What you control is what the shop does during that time. It can show an error. It can keep the order and take the payment later. It can offer another way to pay. Each choice is a design decision inside the boundary about a failure outside it, and the next lessons give you the tools to make it: a numerical way to count availability, and a way to separate the dependencies you cannot do without from the ones you can.
Architecture
Section titled “Architecture”A list of features says what a system does. It does not say how the system is built, and two systems with exactly the same features can be built in very different ways.
The architecture of a system is its structure, meaning its components and how they connect, together with the decisions about that structure that are costly to change later. Martin Fowler passes on Ralph Johnson’s way of putting it: architecture is the decisions you wish you could get right early in a project.
Take two shops with the same features. One is a single application with one database. The other is split into separate services for the catalogue, the cart and the checkout, each with its own data.
| Question | One application | Several services |
|---|---|---|
| Changing the cart | Rebuild and deploy the whole application | Deploy the cart service on its own |
| A bug in search | It can bring down everything running in the same process | It tends to stay inside the search service |
| Failures you can have | Fewer, because there are fewer connections | More, because every connection is one |
| How many teams can work without waiting for each other | One or two | Many |
| What it costs to run | Less to run and to understand | More to run and to understand |
Neither is better. Each one trades something for something else, and the right choice depends on the requirements and the constraints, which are the next two lessons. What matters now is the idea: architecture is where the trade-offs live, and the arrows between the boxes are the cost of drawing more boxes.
- A system is parts, the connections between them, and a purpose.
- The boundary separates what you build, run and answer for from everything else. It is a choice, and it decides what you can fix.
- Outside the boundary are dependencies (someone else runs them), users (people and programs that call you), and everything else that shapes the system.
- Ask who runs a thing and who is called when it breaks. The organisation chart is not the answer.
- An arrow that crosses the boundary is a dependency, and your system cannot be more available than what it cannot do without.
- Architecture is the structure of the system and the decisions about it that are costly to change. Two systems with the same features can have different architectures, and the difference is a set of trade-offs.
Next: requirements, or what the system must do and how well.
Your progress
Built by GhaziAlibi.
© ShardCraft. All rights reserved.