Tech Tip: Using C4Model for documenting software architecture in a modern way using the technique created by a software architect (Simon Brown). It has been inspired by Unified Modeling Language and 4+1 architectural view model and adds the modern approach to simplify documenting and visualizing the software architecture.

C4Model is the modern way to document and visualize software architecture with different levels of abstractions – Context, Container, Components and Code and supporting architecture as a code methodology.

  • Context – System Context diagram provides a starting point, showing how the software system in scope fits
  • Containers – A Container diagram zooms into the software system in scope, showing the high-level technical building blocks
  • Components – zooms into an individual container, showing the low-level components inside it
  • Code – e.g. UML class diagram can be used to zoom into an individual component, showing how that component is implemented

Key Questions

Considering a relatively new approach, the below section answers some of the key questions, which usually surfaces when considering a new documentation approach for the software architecture:

Q1) Why to use C4Model instead of UML or other approaches?

Answer: It is not a competitive or alternative solution – it just provides the framework to visualize the software architecture using 4 simple views at varying levels of abstractions. The idea is to bring provide a user-friendly view of architecture with consistency across the enterprise using a simple approach. It compliments UML, 4+1 architecture model, ArchiMate, and other modeling frameworks.

Q2) Is there any specification available for C4Model compliance?

Answer: The simplicity is the essence of C4Model recommendation – it is another variation of UML with guidance to apply template, layout, legend, arrow, and eventually abstractions to visualize the architecture. So, in essence, there is no hard-bound rules to check compliance.

Q3) Do I need a special editor or IDE to create C4Model diagrams?

Answer: While Simon (the inventor) himself has created a specialized tool, Stucturizr. However, there is no specific tool required as you can also use Powerpoint, Visio, or any diagramming tool. Below is the list of tools supporting C4Model diagrams:

Architecture Tools supporting C4Model
Architecture Tools supporting C4Model

Q4) What is the support available in terms of client libraries, tooling and integrations?

Answer: There is a GitHub space available to support client libraries, tools, and integrations. An open-source solution like PlantUML also supports C4Model – click here to access the repository.

You can use DSL, programming languages (Java), and others to document the architecture and generate the diagram from the code.

Q5) Can you share example of design or architecture diagrams created using C4Model?

Answer: While C4Model.com itself provides examples, there are below GitHub repositories you can use it for reference:

Here is an example depicting an architecture for a blogging website (say vedcraft.com) using PlantUML following C4Model:

Context Diagram

System Context Diagram for a blogging website using C4Model
System Context Diagram for a blogging website using C4Model

Code to generate the above diagram using architecture as a code:

https://gist.github.com/vedcraft/7e6ef542fc96b8d81fb6bbe3f01193c2

Container Diagram

Container Diagram for a blogging website using C4Model
Container Diagram for a blogging website using C4Model

Code to generate the above diagram using architecture as a code:

https://gist.github.com/vedcraft/2e285b3470ccbe1d5b66f4d0776cbc81

Read blogs on architecture and design

Software Architecture and Design Patterns

Emerging Technology Patterns & Trends

Technology Learnings and Knowledge Sharing

Leave a Comment