The C4 Model: Zoom Levels for Architecture Diagrams
Most architecture diagrams fail in the same way. Boxes of different kinds sit next to each other, arrows have no labels, there's no legend, and a database, a team and a Java package all look the same. Everyone in the meeting nods, and everyone understands something different.
The C4 model, created by Simon Brown, fixes that with one simple idea: draw a system the way a map app shows a city, at a few fixed zoom levels. Each level has a clear audience and a clear set of things that belong on it. The four levels are Context, Containers, Components and Code.
Explore It Yourself
Below is Roarline, the fictional ticketing platform used across this documentation section. Click the boxes with a + to zoom in.
The Four Levels
| Level | Shows | For whom | Worth drawing? |
|---|---|---|---|
| 1. System context | Your system as one box, the people who use it and the systems it depends on | Everyone, including non-technical people | Always |
| 2. Containers | The apps, services, databases and queues that make up the system, and how they communicate | Developers, operations, architects | Almost always |
| 3. Components | The major building blocks inside one container, such as modules or services | Developers of that container | Only for containers complex enough to need it |
| 4. Code | Classes, interfaces, tables | Developers working on a specific part | Rarely; generate it from the code if you need it |
"Container" doesn't mean Docker
In C4, a container is anything that needs to run or store data on its own: a web app, a mobile app, a backend service, a database, a message queue, a serverless function. It often happens to run in a Docker container, but that's a coincidence of naming. If you could deploy it, start it or back it up separately, it's probably a container.
When to Stop Zooming
Most teams get the most value from levels 1 and 2. They change slowly, they fit on one screen, and they answer the questions new team members actually ask. Draw level 3 only for the containers where people regularly get lost, like Roarline's Application. Level 4 goes out of date the moment someone refactors, so let your IDE draw it when you need it.
A good test: if a diagram needs a verbal explanation every time you show it, it is either missing labels or mixing levels.
Rules for Diagrams That Explain Themselves
- One level per diagram. Don't put a database table next to an external system
- Every box says what it is: a name, a type in brackets (for example
[Container: Java, Spring Boot]) and one sentence about its job - Every arrow has a label that says what flows or what is asked, and how if it matters (
JSON/HTTPS,SQL,events) - Arrows point in one consistent direction, usually "who calls whom" or "where the data goes". Say which in the legend
- Add a title and a legend. Colours and shapes mean nothing unless they're explained
- Show the boundary of what you're zooming into, so it's clear what is inside and what is a neighbour
C4 and arc42
C4 and arc42 fit together naturally. arc42 says where things go; C4 says how to draw them.
| C4 diagram | arc42 section |
|---|---|
| System context | 3. Context and Scope |
| Containers and components | 5. Building Block View (level 1 and 2) |
| Dynamic diagram (a numbered flow between elements) | 6. Runtime View |
| Deployment diagram (containers mapped to infrastructure) | 7. Deployment View |
Diagrams as Code
Diagrams drawn by hand rot quickly. Describing the model as text lets you review it in pull requests, generate every level from one source, and keep names consistent. This is how part of Roarline looks in the Structurizr DSL:
workspace "Roarline" {
model {
fan = person "Fan" "Buys tickets for live events"
psp = softwareSystem "Payment provider" "Charges and refunds cards" "External"
roarline = softwareSystem "Roarline" "Ticketing platform" {
webShop = container "Web shop" "Fans browse and buy" "TypeScript, React"
app = container "Application" "All business logic" "Java, Spring Boot"
db = container "Database" "One schema per module" "PostgreSQL" "Database"
}
fan -> webShop "buys tickets"
webShop -> app "calls" "JSON/HTTPS"
app -> db "reads and writes" "SQL"
app -> psp "charges" "HTTPS"
}
views {
systemContext roarline {
include *
autoLayout
}
container roarline {
include *
autoLayout
}
}
}
Other popular options are the C4 extension for PlantUML and the C4 diagram types in Mermaid. The interactive diagram on this page works the same way: it is generated from a small data model, and automated tests check that every arrow connects two boxes that actually exist.
Key Takeaways
- C4 is a set of zoom levels, not a notation: context, containers, components, code
- Levels 1 and 2 give most teams most of the value
- A container is anything that runs or stores data on its own, not only a Docker container
- Every box needs a name, a type and a purpose; every arrow needs a label
- Keep diagrams as code, next to the system they describe
Further Reading
- c4model.com: the official introduction by Simon Brown, with examples and FAQs
- Structurizr: tooling for C4 diagrams as code