C4 Model
Introduction
Visualising software architecture is crucial for understanding, designing, and communicating the structure and dynamics of a software system. C4 modelling is a lightweight approach to visualising software architecture in a way that is easy to understand for different stakeholders. The C4 model was created as a way to help software development teams describe and communicate software architecture, both during up-front design sessions and when retrospectively documenting an existing codebase. It’s a way to create “maps of your code”, at various levels of detail, in the same way you would use something like a Maps Application to zoom in and out of an area you are interested in.
It organises architectural information into four hierarchical levels of diagrams, each providing a different level of abstraction.
Four Levels of C4 Modelling
Level 1 - System Context Diagram
The context diagram provides a simple, high-level view of the system and its interactions with actors and external systems. It is useful for Business Stakeholders, Product Owners, Architects and Developers to get a broader understanding of the system.
Level 2 - Container Diagram
The container diagram breaks the system into containers and zooms in to show these containers and how these containers interact with each other. This helps the Architects and Developers to understand technology choices and communication protocols used for the Interactions.
Level 3 - Component Diagram
The component diagram further zooms into a single container and provides an insight into its internal structure. It identifies key components within the application and their interactions. This is useful for Developers and Architects designing and maintaining the system.
Level 4 - Code Diagram (Optional)
The code diagram provides a detailed implementation level view of a specific component. Typically shows classes and methods. This is useful for low-level design discussions and understanding complex logic in the component.
Benefits of C4 Modelling
The C4 modelling provides clarity and consistency as it presents software architecture at different levels of abstraction, making it understandable for both technical and non-technical stakeholders. It provides a structured way to document architecture, ensuring consistency across teams and enables efficient communication and ensures alignment to prevent rework.