What is c4?

C4 Model

The C4 model is a "visual notation" and process for architecting software systems. It stands for Context, Containers, Components, and Code. It's designed to be easily understandable by a wide audience, including both technical and non-technical stakeholders. The C4 model focuses on creating a set of diagrams that provide different levels of abstraction, each tailored to a specific audience and purpose.

Here's a breakdown of the four levels:

  • Context Diagram: Shows the software system in relation to its users and other software systems. This is the highest level of abstraction, showing the overall scope and external dependencies of the system.

  • Container Diagram: Zooms into the system and shows the major containers (applications, data stores, microservices, etc.) that make up the system. This level focuses on the runtime architecture of the system.

  • Component Diagram: Zooms into an individual container and shows the major components within it. Components are groupings of related functionality. This level focuses on the logical architecture of a container.

  • Code Diagram: (Optional) This level is a very low-level diagram that represents the code elements of the system. UML class diagrams are often used at this level, but it's frequently avoided in favor of letting the code itself be the source of truth.

The C4 model emphasizes using simple boxes and lines with labels to create easy-to-understand diagrams. It also encourages a consistent notation across all levels. This consistency makes it easier for people to navigate the different levels of abstraction and understand the system as a whole. The approach uses "boxes and lines" rather than a complex set of icons so anyone can draw these diagrams with almost any tool.