The C4 model is a hierarchical approach to visualizing software architecture that describes a system through four levels of diagrams: context, containers, components and code. Created by software architect Simon Brown, it gives teams a shared vocabulary of a few core abstractions and lets readers zoom from a high-level picture into technical detail, much like moving between maps of different scales.
The C4 model is deliberately notation independent and tooling independent. It does not prescribe shapes or colors; instead, it defines what each diagram should show and for whom, which makes it popular for documentation, onboarding and architecture reviews in teams that find full UML too heavy.
Core abstractions of the C4 model
Every C4 diagram is built from a small set of well-defined building blocks. Consistent use of these terms is what makes diagrams comparable across teams, because a box labeled as a container always means the same kind of thing.
The table defines each abstraction and gives typical examples.
| Abstraction | Meaning | Examples |
|---|---|---|
| Person | A human user or role | Customer, support agent |
| Software system | The highest-level unit that delivers value | Online banking system, email service |
| Container | A separately runnable or deployable unit | Web application, mobile app, database |
| Component | A grouping of related functionality inside a container | Payment controller, notification module |
| Code element | Classes, functions or tables | OrderService class, users table |
A frequent misunderstanding concerns the word container. In the C4 model, it means any runtime boundary that executes code or stores data, such as a single-page application, a serverless function or a schema. It is not limited to Docker containers, although a Docker container can be one.
The four diagram levels
The C4 model organizes diagrams as zoom levels, each aimed at a different audience and answering a different question. Most teams find that the first two levels deliver most of the value, while the lower levels are drawn selectively.
| Level | Question answered | Primary audience |
|---|---|---|
| 1. System context | What does the system do and who uses it | Everyone, including non-technical staff |
| 2. Container | What runnable parts exist and how they communicate | Developers, operations, architects |
| 3. Component | How one container is structured internally | Developers of that container |
| 4. Code | How a component is implemented | Developers, usually generated by tools |
Beyond the four core levels, the C4 model defines supplementary diagrams. A system landscape diagram shows all systems in an organization, a dynamic diagram shows the runtime sequence of a use case, and a deployment diagram maps containers onto infrastructure such as clusters, regions or servers.
How the C4 model differs from other approaches
The C4 model sits between informal whiteboard sketches and formal modeling languages. It adds structure and consistent terminology to sketches, while avoiding the steep learning curve of complete UML specifications.
| Approach | Focus | Typical trade-off |
|---|---|---|
| C4 model | Hierarchical structural views | Easy to learn, limited behavioral detail |
| UML | Formal notation for structure and behavior | Expressive, but heavy and often inconsistent in practice |
| 4+1 view model | Multiple stakeholder views | Comprehensive, but abstract to apply |
| arc42 | Documentation template | Complements C4 diagrams rather than replacing them |
| Ad hoc box diagrams | Quick communication | Ambiguous boxes and arrows |
The C4 model also combines well with other practices in software architecture. Diagrams can illustrate decisions recorded in an architecture decision record, document the boundaries of microservices or a modular monolith, and show how an event-driven architecture routes messages between containers.
Creating effective C4 diagrams
Good C4 diagrams are self-explanatory without a presenter. Each one should carry a title, a key or legend, and labeled relationships that say what flows and how, for example JSON over HTTPS or asynchronous messages through a broker.
- Label every element with name, type and responsibility, such as Web API, container, Java and Spring Boot, handles orders.
- Make every arrow unidirectional and labeled with intent and protocol, never a bare line.
- Keep each diagram to one level of abstraction and avoid mixing components with external systems in confusing ways.
- Include a legend explaining shapes, colors and line styles.
- Limit the element count: roughly 20 elements is a practical upper bound for readability.
Many teams use diagrams as code, where a text model generates all views. Tools based on the Structurizr DSL or C4 extensions for PlantUML and Mermaid keep the model and views consistent, allow review in version control and reduce drift when the architecture changes.
Limitations and common mistakes
The C4 model describes static structure first, so it is not a full specification method. Behavior, data models, security controls and non-functional requirements need complementary documentation, such as sequence diagrams, threat models or quality attribute scenarios.
| Mistake | Consequence | Fix |
|---|---|---|
| Drawing the code level by hand | Diagrams go stale quickly | Generate from code or skip it |
| Mixing abstraction levels | Readers lose orientation | Split into separate diagrams |
| Unlabeled arrows | Dependencies remain ambiguous | Add intent and technology |
| Treating containers as Docker only | Missing databases and clients | Use the C4 definition |
| Never updating diagrams | Documentation loses trust | Keep models in version control |
The most important warning is about maintenance. Diagrams that no longer match the running system mislead more than they help, so teams should draw only the views they will keep up to date as part of normal delivery work. A small set of accurate, current diagrams is worth more than a complete but outdated collection.
The simple explanation
The C4 model is a way to draw software like a set of maps. The first map shows the whole country: the system and the people who use it. The next maps zoom into cities, neighborhoods and finally single streets.
Each map uses the same few kinds of boxes, so anyone can read them. A manager can stop at the first picture, while a developer can zoom in as far as needed.
How it is used in practice
A team of twelve developers maintains an insurance claims platform and keeps losing time explaining it to new hires. The lead architect introduces the C4 model and writes the views in a text-based DSL stored in the same repository as the code.
The system context diagram shows policyholders, claims handlers, a payment provider and a document archive. The container diagram shows a React web app, a mobile app, a claims API, a rules engine, a PostgreSQL database and a message broker, with every arrow labeled by protocol. Component diagrams exist only for the claims API, the most complex container.
Within two months, new developers report that they understand the platform in their first week instead of the first month, and architecture reviews start from the container diagram rather than from improvised whiteboard sketches.