Understanding the C4 Model: A Better Way to Diagram Software Architecture
Every engineer has opened an architecture diagram and immediately regretted it.
Too many boxes. Arrows pointing everywhere. Zero context for whether you’re looking at the whole system or one function inside it.
That’s the problem the C4 model solves.
What C4 actually is
C4 stands for Context, Containers, Components, and Code. It’s a lightweight way to describe software architecture at four different zoom levels, created by Simon Brown as a reaction to the chaos of unstructured “boxes and lines” diagrams.
The core idea: architecture diagrams fail not because people draw badly, but because they mix abstraction levels. A single diagram tries to show the whole system, the database, the API, and a function signature, all at once.
C4 fixes that by splitting the picture into four separate, nested views — like zooming in with a map app instead of cramming a street map and a satellite photo onto the same page.
Level 1 — System Context
Zoom level: from space.
This diagram answers one question: what is this system, and who or what does it interact with?
You show your system as a single box. Around it, you show the people (users, admins, external actors) and other systems it talks to (payment gateways, email providers, third-party APIs). No internal detail. No technology choices.
This is the diagram you hand to a stakeholder who doesn’t write code and still understand exactly what the system does and who touches it.
Level 2 — Containers
Zoom level: the building blocks.
Now you open up that single box from Level 1. A “container” here doesn’t mean Docker — it means a separately deployable or runnable unit: a web app, a mobile app, an API service, a database, a message queue.
This diagram shows how those pieces talk to each other and what technology each one uses. It’s the diagram a new engineer needs on day one to understand the system’s shape before touching any code.
Level 3 — Components
Zoom level: inside one container.
Pick one container — say, your API service — and break it into its major components: the modules, services, or logical groupings of functionality inside it, and how they relate.
This is useful, but optional. Brown himself notes it’s the level most teams should generate on demand rather than maintain by hand, since it goes stale fast as code evolves.
Level 4 — Code
Zoom level: class diagrams.
The most granular level: class diagrams, entity relationships, or other code-level structure for a specific component.
In practice, almost nobody draws this manually anymore. IDEs and tools can generate it from the actual code, which is also the only way it stays accurate.
Why this matters more now, not less
AI coding tools generate components, services, and integrations faster than any team can mentally track them. The result is often architecture nobody can describe out loud, even though it technically works.
A System Context diagram takes ten minutes and forces the question: what is this system supposed to do, and what’s allowed to talk to it? A Container diagram takes another twenty and gives every new contributor, human or AI, a map instead of a guess.
You don’t need all four levels for every project. Most teams get the most value from Context and Containers, and treat Components and Code as generated artifacts rather than maintained ones.
The point isn’t more diagrams. It’s the right diagram, at the right zoom, for the question someone’s actually asking.
Leo Steffen