C4 Diagrams: A Guide to Visualizing Software Architecture

Making Engineering Diagrams speak for themselves

Show and Tell

I’m a very visual thinker, and when it comes to sharing ideas within the team, I will often try and distil things down to a diagram - which will usually sit at the top of my google doc. I always find it a delicate line with how much detail I try and get in to a diagram. Too much detail and the space gets crowded and nothing makes sense. Too little detail and the diagram may as well just be a sentence.

C4 Model

The C4 model, created by Simon Brown, provides a structured approach to visualizing software architecture at different levels of abstraction. It consists of four layers, each providing a different level of detail:

The different levels of zoom allow you to tell different stories to different audiences. That said, you don’t need to use all 4 levels of diagram; only those that add value

I’ll do my best to give an idea of the separate levels of abstraction, using the concept of making tea, where I have plenty of experience

Level 1: System Context

The System Context diagram shows your system in relation to its users and other systems it interacts with. This high-level view helps stakeholders understand where your software fits in the bigger picture. C4 System Context Diagram

Here, our system sits between the user and the utilities providers.

Level 2: Container

The Container diagram zooms in to show the high-level technical building blocks of your software system. Containers (not to be confused with Docker containers) represent applications or data stores that are part of your system. C4 Container Diagram

Here we break down our system into the container level things - these are the main objects in our system that interact with each other across a boundary, but that are all part of this system

Level 3: Component

The Component diagram breaks down individual containers to show the major structural building blocks and their interactions. This level is useful for developers and architects to understand the system’s implementation strategy.

C4 Component Diagram

Zooming into one of the objects in our container, we focus on the kettle, this has its own internal logic for performing its job behind a well defined interface.

Level 4: Code

The Code diagram (optional) zooms in further to show how a component is implemented using classes, interfaces, etc. This level is typically generated from the codebase rather than maintained manually.

C4 Code Diagram

Diving into a class within our component, the thermostat is a cleanly defined blob of logic which heats water until it is hot enough, then it stops.

Overview

Each level of the C4 model builds upon the previous one, providing increasingly detailed views of your software architecture while maintaining clarity and purpose at each zoom level.

Some diagram recommendations I’ve stolen directly from the site because they are concise enough:

Diagrams

Elements

Relationships