Architecture Diagrams with the C4 Model
One huge diagram helps nobody. The C4 model draws the system at four zoom levels: system context, containers, components and code. Each level answers different questions for different readers. Every box has a name, a type and a job; every line has a label and a direction. Keep diagrams next to the code, as text, so they stay true.
Author: bezzad
Contents
The problem: the diagram nobody understands
Our online shop has one “architecture diagram” on the wiki. It has 60 boxes, lines in every direction, three colors with no legend, and some boxes are apps, some are classes, some are teams.
A new developer looks at it for ten minutes and still cannot answer simple questions: “Which app do I change to add a payment method? Where is the order data stored?”
The problem is not the drawing tool. The problem is that one picture tries to answer every question for every reader.
The idea: zoom levels, like a map
A map of a country does not show the streets. A street map does not show the whole country. You zoom in when you need more detail.
The C4 model (by Simon Brown) applies this idea to software. It has four levels, and each level is for a different reader:
- System context. Our system as one box, the people who use it, and the other systems it talks to. Readers: everyone, including the business.
- Containers. Inside our system: the things that run or store data. Web app, API, database, message broker, worker. Readers: developers, operations, security.
- Components. Inside one container: its main parts and their jobs. Readers: the team that builds this container.
- Code. Classes and their relations. Usually generated by the IDE; draw it only when it really helps.
Level 1: system context
This one diagram answers: who uses the system, and what does it depend on? It is the best diagram to start a project, to explain the system to a manager, or to discuss security borders.
Level 2: containers
This is the diagram developers and operations use most. It shows:
- Every app and data store, with its technology.
- How they talk: HTTP, messages, database calls.
- What is ours and what is external.
Level 3: components
Zoom into one container, for example the API. Its components could be: Cart, Ordering, Pricing, Payments adapter. Draw this only for containers where the inside is not obvious, and only as deep as the team needs.
Rules that make diagrams readable
- A title on every diagram. “Online Shop, containers, October 2026”.
- Every box has: a name, a type (person, system, container, component), the technology when it matters, and one short line about its job.
- Every line has: a direction and a label with a verb: “places orders”, “reads and writes”, “sends confirmation”. Add the protocol when it matters.
- A legend if you use colors or shapes. Colors must not be the only way to tell things apart.
- One level per diagram. Do not mix apps and classes in one picture.
- Fewer boxes. If a diagram needs more than about 20 boxes, split it.
Extra diagram types can help next to the four levels:
- A dynamic diagram shows the order of steps for one scenario, for example “place an order”, with numbered lines.
- A deployment diagram shows where containers run: servers, regions, clusters.
Diagrams as code
A diagram in a drawing tool is easy to forget. Diagrams written as text in the repository are reviewed in pull requests and change with the code. One model can create many views. For example, with the Structurizr DSL:
workspace {
model {
customer = person "Customer"
shop = softwareSystem "Online Shop" {
web = container "Web app" "Pages for shopping" "React"
api = container "API" "Orders, cart, prices" "ASP.NET Core"
db = container "Orders database" "" "PostgreSQL"
}
payment = softwareSystem "Payment provider"
customer -> web "Browses and buys"
web -> api "Calls" "JSON/HTTPS"
api -> db "Reads and writes"
api -> payment "Takes payments" "HTTPS"
}
views {
systemContext shop { include * autolayout lr }
container shop { include * autolayout lr }
}
}
PlantUML and Mermaid also have C4 support. The tool matters less than the habit: diagrams live next to the code and are updated in the same pull request.
Other ways to describe architecture
C4 is one popular approach. You may meet others:
- The 4+1 view model (Philippe Kruchten): logical, development, process and physical views, plus scenarios that walk through them.
- Viewpoints and perspectives (Rozanski and Woods): a view for each group of stakeholders (functional, information, deployment …), and “perspectives” like security or performance that you check across all views.
- UML. Useful pieces: sequence diagrams for the order of calls, deployment diagrams, sometimes class diagrams. Most teams use only a small part of it.
- ArchiMate. A language for enterprise architecture: business processes, applications and technology in one model. Common in large organizations with TOGAF.
- Flowcharts for business processes and decisions.
| Question | A good picture |
|---|---|
| Who uses the system and what does it depend on? | C4 system context |
| What runs where, and with which technology? | C4 containers, deployment diagram |
| In which order do the calls happen in checkout? | Dynamic diagram or UML sequence diagram |
| How does the business process work? | Flowchart, or an Event Storming timeline |
| How do business, apps and infrastructure fit across the company? | ArchiMate |
Common mistakes
| Mistake | Result | The right way |
|---|---|---|
| One diagram for everything | Nobody understands it. | One level per diagram, one audience per level. |
| Boxes with only a name | Readers guess what each box is. | Name, type, technology and job. |
| Lines without labels | “This connects to that” says nothing. | A verb on every line, and a direction. |
| Colors without a legend | Different readers see different meanings. | A legend, and a title. |
| Diagrams only in a drawing tool | Out of date after one month. | Diagrams as code, next to the code. |
Summary in six lines
- One diagram cannot serve every reader; draw zoom levels.
- C4 levels: system context, containers, components, code.
- A container is anything that runs or stores data on its own.
- Every box: name, type, technology, job. Every line: direction and a verb.
- Keep diagrams as code in the repository and update them with the code.
- Other tools exist: 4+1 views, viewpoints, UML, ArchiMate; choose by the question you want to answer.