Skip to main content

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​

ElementDefinitionExamples
PersonA human user of the software: an actor, role or personaCustomer, Back-office clerk
Software SystemThe highest level of abstraction: something that delivers value to its users, usually owned by one teamOrder Management, the company's CRM
ContainerA separately runnable or deployable unit that executes code or stores data. Not a Docker container, although it may run in oneWeb app, mobile app, API service, database, message topic, file bucket
ComponentA group of related functionality behind a well-defined interface, inside a container. Not separately deployableOrder controller, Payment adapter
CodeClasses, functions, tables that implement a componentUsually 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:

LevelDiagramShowsAudience
1System ContextOne software system, its users and the systems it interacts withEveryone, including non-technical people
2ContainerThe containers inside one software system and how they communicateArchitects, developers, operations
3ComponentThe components inside one containerDevelopers
4CodeClasses or tables inside one componentDevelopers (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.dsl
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​

StrengthsLimitations
Very easy to learn; a shared vocabulary within an hourNo business layer: no capabilities, processes or data entities
Works at the level developers think inOwnership, lifecycle and costs are not part of the model
Notation-independent; works on a whiteboard and in toolsInterfaces are relationships, not first-class elements
Model-as-code tools avoid outdated diagramsFocused 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) or Resource (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​