Previously we were talking about the importance of having a common modeling language for the design of applications in the organizations, today we will see a little more in detail the C4 modeling language
Analogy
Before going deeper into C4, let’s explain the reasoning behind its structure. Its creator often uses an analogy about how we use Google maps and zoom in and out depending on the level of information we want. To give another example, in this case I am going to make the analogy with buildings.
Let’s imagine a building where we want to buy an apartment. Involved in that apartment, there are a multitude of different plans, each of them containing different information, because the people to whom this information is addressed will also be different.
For example, we can have a first plan with the general view of the building, where all the floors and their design are shown, ideal to get an idea of what the building is like in general.

If we want to have more detail, we can zoom in a little, and we would have the floor plan, where the floors and rooms are shown and how they are communicated between them. This plan is ideal to discuss with the family who will have each room or to see the measurements for the furniture.
If we keep zooming in to get more detail, we could have a view of the plumbing or electrical installation of the apartment.
We could keep zooming in and get a detailed view of the electrical assembly of one of the switch boxes. Very interesting plan for the electrician, but maybe not so much to show to our family.
They are plans with different level of detail, different information, because the people interested in each of the plans is different.
Something similar happens in C4.
C4
C4 (Context, Containers, Components, and Code) is a set of architecture diagrams that provides a pragmatic and scalable approach to modeling software architecture and focuses on providing simple, readable, and easy-to-understand diagrams. C4 was developed by Simon Brown and has become a popular modeling language in the software architecture community.
C4 diagrams are designed to be simple and understandable while being easy to extend and communicate, making them a useful tool for software development. Each of the four levels of abstraction (Context, Containers, Components and Code) focuses on different aspects of the architecture and is represented by a separate diagram.

The four levels of abstraction of C4 are briefly described below:
- Context (Level 1): this level provides a high-level view of the system and its context. It describes the relationship and interactions of the system with its environment, with other systems and the external actors interacting with it. The main purpose of the context diagram is to provide a high-level view of the system architecture.
- Containers (Level 2): this level describes the system components and their grouping into containers. Containers are high-level components that contain other components. The container diagram shows the overall structure of the system and how it is divided into smaller components. As an important clarification, this level has nothing to do (despite its name) with containers such as Docker or other virtualization systems. This level usually coincides with applications or databases.
- Components (Level 3): this level describes the individual components of the system and how they interact with each other. Each component represents a functional unit of the system. This diagram shows the relationship between the components and how they communicate.
- Code (Level 4): this level describes the internal structure of the components and the detail of their implementation in code. This diagram shows the internal structure of each component and how it is implemented in code. The code diagram is optional and is only used in situations where it is necessary to analyze the source code of the system.
Other diagrams
C4 tells us about the four main diagrams, but we can accompany them with other diagrams that will help us to know the reality of each application.
Returning to the building analogy, we may be interested in other types of information, for example:
- Location of the building: Where is the building located in the city? Is it a good neighborhood? Does it have parks around it? For this we can use a city map where we can mark the building on the map.
- Communication: Is it well communicated? How can I move from the building to other parts of the city? A map of the transport network where we can see the location of the building would be ideal.
- General supplies: How is it connected to the electricity and water supply? A plan of the facilities would help in this case.

In the same way, C4 allows the use of complementary diagrams that help, for example, to know:
- The global context of the company and how this system relates to the rest of the systems. For this C4 talks about the “System Landscape” diagram.
- The relationship that will be given between the elements, once the system is working. We could do it by means of the “Dynamic Diagram”.
- How the solution will be deployed at the infrastructure level. Through the “Deployment Diagram” we can represent how levels 1 and 2 of the design are related to the available infrastructure such as physical machines, virtual machines, networks, etc…
Benefits
Using C4 to model software architecture has several benefits. Some of them include:
- Provides a high-level view of the system architecture.
- Facilitates communication and understanding among team members.
- Enables better planning and decision making regarding the evolution of the system.
- Provides a scalable structure for modeling the software architecture.
- Promotes clear and accurate documentation of the system architecture.
- It is easy to learn and quick to implement.
- There are many tools available for its design.
- Can be created graphically or by coding.
Conclusion
C4 is a simple, scalable and readable software architecture modeling approach that focuses on four levels of abstraction: context, containers, components and code. C4 diagrams are useful for providing a clear and accurate view of the software architecture, which facilitates communication and understanding among team members and enables better planning and decision making regarding the evolution of the system. In addition, C4 encourages clear and accurate enterprise-wide documentation of the system architecture, which is very useful for long-term software maintenance.
C4 is easy to understand and use, which makes it popular with software developers. In addition, C4’s scalable approach allows architecture diagrams to be adapted to systems of different sizes and complexities.
it’s really easy to use and the results are good, but it lacks the neede depth to link tech and business
Great!!! Thank you for sharing this details.