Skip to content

C4 model

The C4 model is a hierarchical visual notation for software architecture, created by Simon Brown in 2018. It defines four nested abstraction levels — Context, Container, Component, Code — and prescribes what each diagram should and should not show.

Authoritative sourcehttps://c4model.com
MaintainerSimon Brown
Local home in the kittemplate/docs/diagrams/c4/
Slot in pentaglyph#2 of 5 — the visual layer

Architecture diagrams typically suffer:

  • Boxes-and-lines tyranny — nobody knows what a box represents (a process? a class? a database?).
  • Notational fragmentation — UML, ArchiMate, ad-hoc shapes, all in the same repo.
  • Single-zoom curse — one giant diagram showing everything is unreadable; one diagram per module loses the big picture.

C4 fixes all three by enforcing four discrete zoom levels, each with a clear semantics for what a “box” means at that level.

LevelWhat a box representsAudienceTypical count per project
L1 — System ContextA whole software system (yours + external)Everyone, including non-technical stakeholders1
L2 — ContainerA deployable / runnable unit (web app, API, database, message bus)Developers and ops1 per top-level system
L3 — ComponentA grouping of code within a container (a module, a package)Developers working in that container1 per container
L4 — CodeClasses / functions (rarely drawn — IDEs already render this)ImplementersRare, on-demand only

The discipline: never mix levels in one diagram. A Container diagram should not show external systems (that’s L1); a Component diagram should not show containers (that’s L2).

Pentaglyph treats docs/diagrams/c4/workspace.dsl (Structurizr DSL) as the single source of truth for all C4 diagrams. SVG renders go under docs/diagrams/c4/exports/ and are committed so GitHub / CodeCommit web UIs can display them without local tooling.

template/docs/diagrams/c4/
├── workspace.dsl ← single source of truth (Structurizr DSL)
└── exports/ ← committed SVG renders
├── system-context.svg
├── container.svg
└── component-<name>.svg

Pentaglyph pairs C4 diagrams with arc42:

  • arc42 §3 Context & ScopeC4 L1 System Context
  • arc42 §5 Building BlocksC4 L2 Container + L3 Component
  • arc42 §6 Runtime View ↔ sequence diagrams (not C4 per se, but rendered the same way)
  • Structurizr DSL — text-based DSL, version-controllable, recommended by Simon Brown himself.
  • Structurizr Lite — local renderer for DSL.
  • PlantUML / Mermaid — work, but require manual layout and lose the official C4 styling.
  • Drawing tools (Lucidchart, draw.io) — accepted but they drift from code and cannot be linted.
  • Whenever a non-trivial architectural conversation involves drawing a box. C4 makes “what kind of box is that?” answerable in one word.
  • Especially valuable for onboarding — new engineers can read C4 diagrams cold.
  • Single-process scripts.
  • Diagrams of processes (BPMN is better) or data flow in detail (DFDs are better at that specific job).