C4 Model — An Elegant Way to Describe Solution Architecture
The creation of a solution architecture document is an important step in the software development lifecycle. User stories contain the requirements which are the primary inputs to defining the architecture, along with the NFRs . The C4 model provides a way to describe the architecture at various levels and possibly for different audiences. As the name implies, there are 4Cs:
- Context
- Container
- Component
- Code
In order to explain the 4Cs, let us consider that we are building a solution that helps recruiters in resume selection and candidate interviews.
The Context diagram gives the high level users a view of the system getting built or enhanced. It can also include other applications that are necessary for the new application to function.
In the diagram, recruiter and candidate are two persons or roles that use the new Applicant Tracking System getting built or enhanced.
Get Dânesh Hussain Zaki’s stories in your inbox
Join Medium for free to get updates from this writer.
The Container diagram goes one level deeper into the system getting built. It shows the various modules or containers that are part of the application. Here you can see that the Applicant Tracking System ATS has an AI Agent container, a Web Application container, a Database container and an API container. The interactions between the containers and between the user s with the containers are shown.
The Component diagram takes one container and further expands it into components. The AI Agent container expands into Interviewer Agent, Profile and Job DB, and Profile Matcher Agent components.
The Code diagram is optional and typically represented using a UML Class diagram. It is usually generated from IDEs.
The various diagrams help present views for different audiences. Business users might be interested in the context, while developers could focus on component diagrams.
Other Diagrams in the C4 Model
There are also other diagrams such as the System Landscape diagram, Dynamic diagram and Deployment diagram. But the 3C diagrams are the ones for which the C4 model is most extensively used.
Diagramming Tools
Tools such as Mermaid and Structurizr are available that generate C4 diagrams based on a DSL input.
A custom generator can also be built that gets user stories from Azure DevOps (or equivalent) using the Azure DevOps API. It can feed the stories to a LLM to identify C4 objects that would be part of a C4 context and container diagram. It can then further generate the DSL for input to Mermaid or Structurizr to generate the diagrams. As the diagrams are DSL based, they can be versioned and managed as code. The generator could run whenever there is a change to the user story, thus keeping the diagrams in sync with the requirements.
The C4 model is a simple and elegant way to provide a view of the solution architecture. With the tools and DSL based approach, it would be a “living” document that is up to date with the requirements. These are a few good reasons that compel the C4 model’s adoption to describe solution architecture. And possibly why it has be gaining recognition alongside UML.







