C4 model

The C4 model, level by level

Software architecture at four levels of zoom: context, containers, components and code.

C4 system context diagram of Gridline, a messaging API: a customer developer and an on-call engineer use it, and it relies on mobile carriers, an email provider, APNs and FCM, billing and a status page.
C4 container diagram of Gridline: a developer dashboard, public REST API, rate limiter, message router, delivery workers, webhook dispatcher, analytics pipeline and Kafka, with Postgres and Redis data stores.
C4 component diagram of Gridline’s rate limiter: a Limit API, rule resolver, rule cache, rule loader, overrides, metrics, token bucket and local fallback, backed by Postgres and Redis.
C4 code diagram of Gridline’s token bucket: the TokenBucket class, Clock and BucketStore interfaces, QuotaRule and RateLimitDecision data classes, RedisBucketStore and the take_tokens.lua script.
  1. Level 1 System context Who uses it, and what it relies on.
  2. Level 2 Containers The apps and data stores inside it.
  3. Level 3 Components The parts inside one container.
  4. Level 4 Code The classes behind one component.

What is the C4 model?

The C4 model is a way to diagram software architecture at four levels of zoom: Context, Containers, Components and Code, the four Cs in its name. Simon Brown created it. It doesn’t prescribe a notation: it defines what each level shows and leaves the shapes, colors and tools up to you. The official reference is c4model.com.

  1. 1Context
  2. 2Containers
  3. 3Components
  4. 4Code

The four levels of the C4 model

Each level zooms into one part of the level above, for a different reader.

Gridline, l1 context view of the map Open the interactive map

Gridline, an example messaging API, follows the level you’re reading.

  1. Level 1: System context diagram

    Your system as one box, with the people who use it and the other systems it interacts with. No technologies, protocols or internals.

    Who reads it
    • Technical people
    • Non-technical people
    C4 system context diagram of Gridline, a messaging API: a customer developer and an on-call engineer use it, and it relies on mobile carriers, an email provider, APNs and FCM, billing and a status page.
    Gridline in context: the developers and on-call engineers who use it, and six systems around it.
  2. Level 2: Container diagram

    The system opened up into its containers: the apps and data stores that make it up, such as web and mobile apps, APIs, databases, serverless functions and file stores. Here a container is anything that has to run for the system to work, not a Docker container.

    Who reads it
    • Architects
    • Developers
    • Operations
    • Security
    C4 container diagram of Gridline: a developer dashboard, public REST API, rate limiter, message router, delivery workers, webhook dispatcher, analytics pipeline and Kafka, with Postgres and Redis data stores.
    Gridline’s ten containers, from the public REST API and rate limiter to Kafka, Postgres and Redis.
  3. Level 3: Component diagram

    One container opened up into its components: groups of related functionality behind an interface, each with its responsibility and technology.

    Who reads it
    • Architects
    • Developers
    C4 component diagram of Gridline’s rate limiter: a Limit API, rule resolver, rule cache, rule loader, overrides, metrics, token bucket and local fallback, backed by Postgres and Redis.
    Inside Gridline’s rate limiter: the Limit API, rules, overrides, metrics and a token bucket kept in Redis.
  4. Level 4: Code diagram

    One component opened up into its code: classes and interfaces in a UML class diagram, or tables in an entity relationship diagram. This level is optional. It’s best generated by tools, and only worth having for your most important components.

    Who reads it
    • Developers
    C4 code diagram of Gridline’s token bucket: the TokenBucket class, Clock and BucketStore interfaces, QuotaRule and RateLimitDecision data classes, RedisBucketStore and the take_tokens.lua script.
    The token bucket’s code: TokenBucket, the BucketStore it depends on, and the Lua script Redis runs.

The anatomy of a C4 diagram

Whatever shapes and colors you use, every C4 diagram needs these parts to be read on its own.

L2 Containers How a send request gets through Gridline. Customer’s app External system Gridline · software system Public REST API Container · Go · REST Accepts and validates send requests. Rate limiter Container · Kotlin · gRPC Enforces each customer’s quota. POST /v1/messages Check · gRPC Key External system Container Software system Uses 1 2 3 4 5 6 7 8
  1. Title What the diagram shows, and at which level.
  2. Type Person, software system, container or component.
  3. Description One line on what it does.
  4. One-way arrow Each relationship points one way.
  5. One level Only containers here. Components get a view of their own.
  6. Technology What it’s built with.
  7. Label What it does, and how: a check, over gRPC.
  8. Key Explains every shape, color, line and icon.

Supplementary diagrams

Three more views of the same model, for questions the four levels don’t answer.

  • System landscape diagram

    Every software system in the enterprise and the people who use them, on one page: a system context diagram with no single system in focus.

    Who reads it
    • Technical people
    • Non-technical people
  • Dynamic diagram

    How elements work together at runtime for one feature or use case, as numbered steps over a context, container or component view.

    Who reads it
    • Technical people
    • Non-technical people
  • Deployment diagram

    How containers map to infrastructure in one environment: deployment nodes such as cloud regions, clusters, servers and managed services, and the container instances each one runs.

    Who reads it
    • Architects
    • Developers
    • Infrastructure
    • Operations

C4 vs UML, ArchiMate and CALM

C4 explains a software system to people.
UML goes deeper into its design, ArchiMate wider across the enterprise, and CALM turns it into code a pipeline can check.

C4 model

Diagramming approach · Simon Brown

Mainly System context to code, sometimes enterprise.

UML

Modeling language · Object Management Group

Mainly Components to code, sometimes containers.

ArchiMate

Enterprise architecture language · The Open Group

Mainly Enterprise to system context, sometimes containers.

CALM

Architecture-as-code specification · FINOS

Mainly System context to containers.

Written as

Diagrams, any notation

Diagrams, standard notation

Diagrams, standard notation

JSON, checked against a schema

Best for

Explaining a system to technical and non-technical readers

Detailed design: classes, sequences and state machines

Describing and analyzing architecture across business domains

Automated validation and compliance checks in CI/CD

Make your own C4 model

Start from a description, from the systems you run, or from the diagrams you already have.

From a description

Describe your system in plain English. Eraser AI draws the C4 diagram, and you refine it with follow-up prompts.

Open the C4 diagram generator →

From the systems you run

Connect the systems that already describe your architecture. Eraser models them, and Eraser AI draws a map from the model. Rescan a source to bring its maps up to date.

C4 levelBuilt from
Context and landscape
  • ServiceNow CMDB
  • Ardoq
  • OrbusInfinity
Containers and deployment
  • AWS
  • Azure
  • Google Cloud
  • VMware
  • Infrastructure as code in your repos
Components
  • GitHub
  • GitLab
  • Azure DevOps

From Mermaid or PlantUML

Paste your Mermaid or PlantUML into Eraser AI, and it redraws the diagram in Eraser, ready to edit.

Start in Eraser →

Click through a C4 model

C4 doesn’t prescribe a medium, so a model doesn’t have to be a stack of images.

Forkway, an example food-delivery platform. Press Play a flow to watch an order go end to end.

  • Drill down

    Open a box to see what’s inside it.

  • Play a flow

    Watch a dynamic diagram move, one step at a time.

  • Filter

    Show one team, phase or technology, and fade the rest.

  • Open a record

    Every box is a record, with details such as its team and technology.

C4 model examples

See all map examples →

Choosing a C4 tool

C4 tools differ in where the model comes from: code you write, diagrams you draw, or the systems you already run. They also differ in how the model stays current, and who can see it.

FAQ

Frequently asked questions

  • What does C4 stand for?

    Context, Containers, Components and Code: the four levels of the model, from the widest view of a software system to the most detailed.

  • What are C1, C2, C3 and C4 diagrams?

    Informal names for the four levels. C1 is a system context diagram, C2 a container diagram, C3 a component diagram and C4 a code diagram.

  • Do you need all four levels?

    No. System context and container diagrams are enough for most teams. Draw component diagrams where they help, and code diagrams rarely: they’re optional, and best generated from the code.

  • What’s the difference between a container and a component?

    A container is something that must run for the system to work, such as a web app, an API or a database. A component is a group of related functionality inside one container, behind an interface. It runs as part of its container, not on its own.

  • When is the C4 model a good fit?

    When different people need to understand one software system at different levels of detail, such as in onboarding, design reviews and architecture documentation. For a whole enterprise portfolio, start with a system landscape diagram.

  • Who created the C4 model?

    Simon Brown created it, and c4model.com is the official reference.

  • Can I share a C4 map with people who don’t use Eraser?

    Yes. Export the map to HTML and you get an interactive page anyone can open in a browser. Every interactive map on this page is one of those exports.

  • Can I use Eraser for free?

    Yes, the Free plan is for individuals and small teams who are getting started on Eraser. Free plan teams get a limited number of files and AI credits.

Start your C4 model.

Describe it, or build it from the systems you run, and share a map anyone can click through.