Back to blog

Blog

C4 Diagram Explained: 4 Levels, Real Examples & Rules

What a C4 diagram is, the 4 levels with a worked example, the notation rules reviewers check, and which C4 model diagrams your team actually needs.

C4 diagramUpdated 12/3/2026Shafi Khan

C4 Diagram Explained: 4 Levels, Real Examples & Rules

A C4 diagram is a software architecture diagram drawn with the C4 model: a set of zoom levels (system context, container, component and code) that show the same system to different audiences at the right amount of detail. In practice, most teams only need two of them, the context diagram and the container diagram, plus a deployment diagram when infrastructure matters.

You've seen the alternative: the diagram from 2023 nobody updated, seven unlabelled arrows, three colours that mean nothing, and a box called "Backend". Below: what each level contains, a worked C4 model example you can copy as code, the notation rules reviewers check, and the mistakes to dodge.

What is a C4 diagram?

The C4 model was created by Simon Brown and is described on the official site as "an easy to learn, developer friendly approach to software architecture diagramming" (c4model.com). The core idea: create "maps of your code" at various levels of detail, the same way you'd zoom from a country map to a street map.

The official C4 diagrams page lists four core diagrams and three supporting ones:

DiagramTypeWhat it answersTypical audience
System contextCore (level 1)What is this system, who uses it, what does it talk to?Everyone, technical or not
ContainerCore (level 2)Which apps and data stores make up the system, and how do they communicate?Engineers, architects, ops
ComponentCore (level 3)What are the major building blocks inside one container?Engineers working on that container
CodeCore (level 4)How is one component implemented (classes, functions)?Developers, usually generated by an IDE
System landscapeSupportingHow do all our systems fit together across the organisation?Architects, leadership
DynamicSupportingHow do elements collaborate at runtime for one use case?Engineers, reviewers
DeploymentSupportingWhere do containers run in a given environment?Platform, SRE, security

Two things make C4 different from "just draw boxes":

  1. It's an abstraction-first model, not a notation. The C4 site states it is both notation independent and tooling independent. Boxes can be any shape and any colour. What matters is that every box is a known type of thing (person, software system, container, component) at a known level.
  2. Each level tells a different story. The diagrams page puts it plainly: "The different levels of zoom allow you to tell different stories to different audiences." Your CFO and your on-call engineer shouldn't be squinting at the same picture.

→ Go from a plain-English system description to an editable diagram with Architect AI

The 4 levels of a C4 model diagram, explained

Let's zoom in, one level at a time.

Level 1: System context diagram

The big picture. One box for your software system in the middle, the people who use it, and the external systems it depends on. No databases, no microservices, no tech logos. If a non-engineer can't read it in 30 seconds, it's too detailed.

What belongs on it:

  • People (roles, not names): "Customer", "Support agent"
  • Your software system: one box, with a one-line description
  • External software systems: payment provider, email service, identity provider
  • Labelled relationships: "Sends order confirmation emails using", not "uses"

Level 2: C4 container diagram

This is the workhorse, and the diagram most teams actually mean when they say "architecture diagram". You zoom into your system box and show the containers inside it.

Big gotcha, straight from the official definition: a C4 container is not a Docker container. The C4 container page defines it as "an application or a data store", something "that needs to be running in order for the overall software system to work". Its examples include:

  • Server-side web application
  • Client-side web application (an SPA counts)
  • Mobile app
  • Serverless function
  • Database
  • Blob or content store
  • File system

So your React SPA, your API, your PostgreSQL database and your S3 bucket are all containers. Whether any of them runs in Docker is a deployment detail, and it belongs on a deployment diagram.

Level 3: Component diagram

Zoom into one container and show its major structural building blocks: modules, services or controllers grouped by responsibility. This is where "Orders API" becomes "Checkout controller", "Pricing service", "Payments gateway client".

Draw these selectively. If a container is a 400-line Lambda, a component diagram adds nothing.

Level 4: Code diagram

UML class diagrams, ER diagrams and so on, for one component. The C4 FAQ is refreshingly honest here: code diagrams go out of date fast, so the recommendation is to "(1) not create them at all or (2) generate them on-demand using tooling such as your IDE."

Which C4 diagrams do you actually need?

The official guidance: "you don't need to use all 4 levels of diagram" and "the system context and container diagrams are sufficient for most software development teams" (c4model.com/diagrams).

Our opinionated starter pack:

  • Always: system context + container
  • When infra is part of the review: deployment (per environment)
  • When a flow is confusing: one dynamic diagram for that flow
  • Only for complex containers: component
  • Never by hand: code

→ Generate review checklists for each diagram level with the free Architecture Review Checklist Builder

C4 model examples: one system, three diagrams

Theory is cheap, so here's a worked C4 model example. Meet Bookshelf, a fictional online bookstore:

  • Customers browse and buy books in a web app.
  • A single-page app calls an Orders API over HTTPS.
  • The API stores orders in PostgreSQL and charges cards through an external payment provider.
  • Order confirmation emails go out through an external email service.

Example 1: System context

ElementC4 typeDescription
CustomerPersonBrowses and buys books
BookshelfSoftware system (ours)Lets customers browse the catalogue and place orders
Payment providerExternal software systemProcesses card payments
Email serviceExternal software systemDelivers transactional email

Relationships: Customer → Bookshelf "Browses books and places orders using"; Bookshelf → Payment provider "Requests card payments from"; Bookshelf → Email service "Sends order confirmations using".

Example 2: Container

Inside Bookshelf you'd show: Web App (React SPA), Orders API (Node.js), Orders DB (PostgreSQL). Each arrow carries a protocol: SPA → API "Makes API calls to" over JSON/HTTPS, API → DB "Reads from and writes to" over SQL/TCP.

Example 3: Deployment

One diagram per environment. Production might put the SPA on a CDN and spread the API across two availability zones; staging might squash it all into one. Same containers, different deployment diagrams, which is why C4 keeps them apart.

If Bookshelf were a fleet of microservices owned by different teams, the modelling changes: we walk through those options in our guide on how to draw a microservices architecture diagram.

→ Sketch your own context and container views from a prompt with Architect AI

C4 diagram as code with Structurizr DSL

You can draw C4 in any tool. But if you want one model to power several diagrams, a modelling tool beats a canvas. The Structurizr DSL is a well-known text language built around exactly that idea. Here's Bookshelf, using syntax from the Structurizr DSL language reference:

workspace "Bookshelf" "C4 model example" {

    model {
        customer = person "Customer" "Browses and buys books."

        bookshelf = softwareSystem "Bookshelf" "Lets customers browse the catalogue and place orders." {
            spa = container "Web App" "Catalogue and checkout UI." "React"
            api = container "Orders API" "Handles carts, orders and payments." "Node.js"
            db = container "Orders DB" "Stores customers, carts and orders." "PostgreSQL" {
                tags "Database"
            }
        }

        payments = softwareSystem "Payment Provider" "Processes card payments." "External"
        email = softwareSystem "Email Service" "Delivers transactional email." "External"

        customer -> spa "Browses books and places orders using" "HTTPS"
        spa -> api "Makes API calls to" "JSON/HTTPS"
        api -> db "Reads from and writes to" "SQL/TCP"
        api -> payments "Requests card payments from" "HTTPS"
        api -> email "Sends order confirmations using" "HTTPS"
    }

    views {
        systemContext bookshelf "Context" {
            include *
            autoLayout lr
        }

        container bookshelf "Containers" {
            include *
            autoLayout lr
        }

        styles {
            element "Database" {
                shape Cylinder
            }
        }
    }
}

Notice there's no customer -> bookshelf line, yet the context view still shows the customer using Bookshelf. That's because, per the Structurizr docs, "By default, the Structurizr DSL will create 'implied relationships' automatically". The customer uses a container, so the customer uses the system. Define once, render at every zoom level. Rename "Orders API" and both views update.

Diagrams as code isn't for every moment, though: it's a tough sell in a live workshop or a pre-sales call. We broke down that trade-off in architecture diagrams as code vs drag-and-drop tools, and if Structurizr is on your shortlist, here's an honest Architecto vs Structurizr comparison.

→ See where Structurizr fits and where Architecto fits

C4 notation rules reviewers actually check

C4 doesn't dictate shapes or colours, but the official notation guidance is strict about clarity. Use this as your pre-review checklist:

  • Title describes the diagram type and scope ("Container diagram for Bookshelf")
  • Key/legend explains every shape, colour, line style and border
  • Every element's type is explicit (person, software system, container, component)
  • Every element has a short description of its responsibility
  • Every container and component names its technology ("Node.js", "PostgreSQL")
  • Every line is unidirectional and labelled, with the label matching the arrow's direction
  • No lazy labels: the guidance says to avoid single words like "Uses"
  • Relationships between containers name a protocol ("JSON/HTTPS", "SQL/TCP")
  • Acronyms are understandable by every audience who'll see the diagram
  • Colour coding is consistent within and across diagrams, and survives black-and-white printing and colour blindness

On arrows: should they show dependencies or data flow? The C4 diagrams FAQ says "This is your choice", as long as the description matches the direction of the arrow. Pick one convention per diagram and say which in the key.

→ Turn this list into a shareable review checklist in seconds

Common C4 diagram mistakes (and quick fixes)

1. Treating containers as Docker containers. Symptom: your container diagram is a Kubernetes pod list. Fix: model apps and data stores; push runtime details to a deployment diagram.

2. Putting the message broker in as one giant box. Every service points at "Kafka" and the diagram tells you nothing. The C4 guidance on queues and topics offers two valid options: model each queue or topic as its own data-store-style container, or drop them and put the queue name on the arrow with a "via" label. Neither is "right"; choose the one that tells your story.

3. Mixing levels. A database on the context diagram, class names on the container diagram. One scope per diagram.

4. Unlabelled or bidirectional arrows. Can't write a sentence for the arrow? That's a design finding, not a drawing problem.

5. Hand-maintaining everything. The C4 FAQ notes each level changes at a different rate, and recommends generating diagrams from real sources where possible: service catalogs for context, static analysis for components, and IaC definitions or cloud configuration for deployment diagrams.

That last one is where most "documentation debt" lives. If you've inherited a codebase with zero diagrams, start from what's real: our playbook for reverse-engineering architecture from code covers it end to end.

→ Ground your container view in the actual codebase with Code Analysis

How Architecto fits a C4 workflow

Straight talk: if your team wants strict model-as-code with C4 semantics baked into the DSL, a dedicated modelling tool like Structurizr is purpose-built for that. Architecto works on the jobs around the diagram, where most teams lose time:

  • Start from intent, not a blank canvas. Architect AI turns a natural-language description into a structured topology you can edit, then hands it into cost, threat, compliance and documentation workflows. That's a fast way to get a first container or deployment-style view on screen for a review.
  • Check the picture against the code. Code Analysis brings repository structure and dependencies into the design review, which is exactly the input you want for component-level thinking.
  • Package it for humans. HyperDocs combines an editor, AI generation and visuals for design docs, so your context and container diagrams land inside a narrative instead of a lonely PNG in a wiki.
  • Already have a docker-compose file? The free Docker Compose Diagrammer is a quick way to see the services you'd model as containers.

→ Put your C4 diagrams inside a reviewable design doc with HyperDocs

Key takeaways

  • A C4 diagram is a zoom level of the C4 model: system context, container, component or code, plus landscape, dynamic and deployment as supporting types.
  • Context + container covers most teams. Add deployment when infra matters, dynamic for confusing flows, and component only where it pays off.
  • A C4 container is an app or data store, not a Docker container.
  • Notation is flexible, but titles, keys, element types, descriptions, technologies and labelled one-way arrows are non-negotiable.
  • Diagrams as code (for example Structurizr DSL) lets one model drive several views, so renames don't break five diagrams.
  • Diagrams rot at different speeds. Generate from real sources (code, IaC, catalogs) wherever you can.

→ Start free and turn your next architecture description into a diagram

FAQ

What is a C4 diagram?

A C4 diagram is a software architecture diagram drawn with the C4 model, Simon Brown's approach to creating maps of your code at different levels of detail. The four core levels are system context, container, component and code, and there are three supporting types: system landscape, dynamic and deployment. The model is notation independent and tooling independent.

Do I need all four levels of the C4 model?

No. The C4 model's own guidance says you don't need to use all four levels, and that the system context and container diagrams are sufficient for most software development teams. Add component diagrams only where a container is complex enough to need them, and generate code diagrams on demand rather than maintaining them by hand.

Is a C4 container the same as a Docker container?

No. In the C4 model a container is an application or a data store, something that needs to be running for the overall software system to work. Examples include a server-side web app, a single-page app, a mobile app, a serverless function, a database, a blob store or a file system. It may or may not run in a Docker container.

How do you keep C4 diagrams up to date?

Each level changes at a different rate, so maintain them differently. Context diagrams change very slowly, container diagrams fairly slowly, component diagrams often during active development, and code diagrams constantly. The C4 FAQ recommends generating diagrams from real sources where you can: service catalogs for context, static analysis for components, and infrastructure as code or cloud configuration for deployment diagrams. Defining diagrams as code in version control also helps, because changes go through pull requests.

→ Stop hand-drawing boxes: start free with Architecto

Ship diagrams people actually read

C4 isn't about prettier boxes. It's about the right zoom level for every audience and arrows that mean something. Want the first draft on screen fast? Describe your system, let Architect AI build the starting topology, then refine it with your team.

→ Start free with Architecto and try Architect AI on your next design review.

FAQ

Questions readers ask before they act on this page.

What is a C4 diagram?

A C4 diagram is a software architecture diagram drawn with the C4 model, Simon Brown's approach to creating maps of your code at different levels of detail. The four core levels are system context, container, component and code, and there are three supporting types: system landscape, dynamic and deployment. The model is notation independent and tooling independent.

Do I need all four levels of the C4 model?

No. The C4 model's own guidance says you don't need to use all four levels, and that the system context and container diagrams are sufficient for most software development teams. Add component diagrams only where a container is complex enough to need them, and generate code diagrams on demand rather than maintaining them by hand.

Is a C4 container the same as a Docker container?

No. In the C4 model a container is an application or a data store, something that needs to be running for the overall software system to work. Examples include a server-side web app, a single-page app, a mobile app, a serverless function, a database, a blob store or a file system. It may or may not run in a Docker container.

How do you keep C4 diagrams up to date?

Each level changes at a different rate, so maintain them differently. Context diagrams change very slowly, container diagrams fairly slowly, component diagrams often during active development, and code diagrams constantly. The C4 FAQ recommends generating diagrams from real sources where you can: service catalogs for context, static analysis for components, and infrastructure as code or cloud configuration for deployment diagrams. Defining diagrams as code in version control also helps, because changes go through pull requests.

Related reading

Keep moving through the architecture workflow.