C4 Metamodel
The C4 model, created by Simon Brown, is a lean way to describe the structure of software. It is often seen only as a set of diagram types, but underneath the diagrams there is a small metamodel: four kinds of elements in a hierarchy, connected by relationships. The diagrams are views of that model at different zoom levels, much like zooming in on a map.
C4 deliberately does not prescribe a notation. Boxes and lines can look however you like, as long as the elements and relationships are used consistently.
Elements
| Element | Definition | Examples |
|---|---|---|
| Person | A human user of the software: an actor, role or persona | Customer, Back-office clerk |
| Software System | The highest level of abstraction: something that delivers value to its users, usually owned by one team | Order Management, the company's CRM |
| Container | A separately runnable or deployable unit that executes code or stores data. Not a Docker container, although it may run in one | Web app, mobile app, API service, database, message topic, file bucket |
| Component | A group of related functionality behind a well-defined interface, inside a container. Not separately deployable | Order controller, Payment adapter |
| Code | Classes, functions, tables that implement a component | Usually generated by tools, if shown at all |
Each element has a name, a short description, and, for containers and components, a technology (for example "Java / Spring Boot" or "PostgreSQL"). Elements can also carry tags for styling and filtering.
Relationships are unidirectional and should have a description that states their intent ("Sends order events to", "Reads customer data from") and, where useful, a technology ("HTTPS/JSON", "Kafka").
Diagrams (views)
The core diagrams zoom in one level at a time:
| Level | Diagram | Shows | Audience |
|---|---|---|---|
| 1 | System Context | One software system, its users and the systems it interacts with | Everyone, including non-technical people |
| 2 | Container | The containers inside one software system and how they communicate | Architects, developers, operations |
| 3 | Component | The components inside one container | Developers |
| 4 | Code | Classes or tables inside one component | Developers (usually skipped) |
Supplementary diagrams:
- System Landscape: all software systems and people in the organization, which is a view of the systems inventory.
- Dynamic: how elements collaborate at runtime for one feature or use case.
- Deployment: how container instances are mapped to deployment nodes (servers, clusters, cloud services) and infrastructure nodes (load balancers, firewalls) in a given environment.
Model as code
Because C4 is a model and not just pictures, it can be maintained as code. In Structurizr DSL, you define the model once and derive many views from it:
workspace "Shop" {
model {
customer = person "Customer"
payments = softwareSystem "Payment Provider" "External PSP" "External"
orders = softwareSystem "Order Management" {
web = container "Web Shop" "Customer-facing UI" "React"
api = container "Order Service" "Creates and tracks orders" "Java / Spring Boot"
db = container "Orders DB" "Stores orders" "PostgreSQL" "Database"
}
customer -> web "Places orders using"
web -> api "Calls" "HTTPS/JSON"
api -> db "Reads from and writes to" "JDBC"
api -> payments "Requests payments from" "HTTPS"
}
views {
systemContext orders "Context" { include * }
container orders "Containers" { include * }
}
}
The same model can also be expressed with PlantUML (C4-PlantUML), Mermaid (C4 diagrams) or IcePanel.
Strengths and limitations
| Strengths | Limitations |
|---|---|
| Very easy to learn; a shared vocabulary within an hour | No business layer: no capabilities, processes or data entities |
| Works at the level developers think in | Ownership, lifecycle and costs are not part of the model |
| Notation-independent; works on a whiteboard and in tools | Interfaces are relationships, not first-class elements |
| Model-as-code tools avoid outdated diagrams | Focused on one or a few systems, less on whole-portfolio analysis |
Mapping to other metamodels
- C4 Software System ≈ Backstage
System≈ ArchiMate Application Component (top level). - C4 Container ≈ Backstage
Component(code) orResource(data stores). - C4 Deployment Node ≈ Backstage
Resource≈ ArchiMate Node.
Using the same identifiers in C4 models and the systems inventory makes it possible to generate the System Landscape diagram from the inventory, instead of drawing it by hand.
Official documentation
- C4 model: the official site by Simon Brown
- Abstractions: the element types, for example Software system, Container and Component
- Diagrams: overview, System Context, Container, Component, Code, System Landscape, Dynamic, Deployment
- Notation: recommendations for diagram notation
- Tools: Structurizr DSL (language reference), C4-PlantUML, Mermaid C4 diagrams