Dr Milan Milovic provides a brilliant description for The C4 Model. Letโs take a look.
When developing software, it is important to have a clear plan and understand how different components of the system will work together. Documentation and diagramming help us to achieve this by providing a ๐๐ถ๐๐๐ฎ๐น ๐ฟ๐ฒ๐ฝ๐ฟ๐ฒ๐๐ฒ๐ป๐๐ฎ๐๐ถ๐ผ๐ป ๐ผ๐ณ ๐๐ต๐ฒ ๐๐ผ๐ณ๐๐๐ฎ๐ฟ๐ฒ ๐ฎ๐ฟ๐ฐ๐ต๐ถ๐๐ฒ๐ฐ๐๐๐ฟ๐ฒ. This helps different stakeholders, like developers, testers, and clients, to have a common understanding of the software design.
One of the preferred ways to visualize the software architecture is ๐๐ต๐ฒ ๐๐ฐ ๐บ๐ผ๐ฑ๐ฒ๐น, developed by Simon Brown, a software architect, and author. The C4 model examines a software systemโs static structures containers, components, and code. And individuals use the software programs we create.
The C4 model consists of ๐ณ๐ผ๐๐ฟ ๐น๐ฒ๐๐ฒ๐น๐ ๐ผ๐ณ ๐ฎ๐ฏ๐๐๐ฟ๐ฎ๐ฐ๐๐ถ๐ผ๐ป, which are represented by four different types of diagrams:
๐น ๐๐ผ๐ป๐๐ฒ๐ ๐ (๐๐ฒ๐๐ฒ๐น ๐ญ): System Context diagram - This diagram shows the system in context, providing an overview of the system and its environment. The system here is the highest level of abstraction and it shows the system under consideration as a box in the center, surrounded by its users and other systems that interact with it. These diagrams help provide a big-picture overview.
๐น ๐๐ผ๐ป๐๐ฎ๐ถ๐ป๐ฒ๐ฟ๐ (๐๐ฒ๐๐ฒ๐น ๐ฎ): Container diagram - This diagram shows the high-level components or services within the system and how they are connected. It shows each component as a box with its internal details abstracted away, which are separately deployable or executable. Containers can represent APIs, databases, file systems, etc.
๐น ๐๐ผ๐บ๐ฝ๐ผ๐ป๐ฒ๐ป๐๐ (๐๐ฒ๐๐ฒ๐น ๐ฏ): Component diagram - This diagram shows the internal components of a container and how they interact with each other. Here we can visualize abstractions in our codebase. E.g. in C#, it is an implementation class behind some interface.
๐น ๐๐ผ๐ฑ๐ฒ (๐๐ฒ๐๐ฒ๐น ๐ฐ): Code diagram - This diagram shows the detailed structure of a single component or module, including its classes and their relationships.
Most teams should at the very least produce and keep up-to-date ๐ฐ๐ผ๐ป๐๐ฒ๐ ๐ ๐ฎ๐ป๐ฑ ๐ฐ๐ผ๐ป๐๐ฎ๐ถ๐ป๐ฒ๐ฟ ๐ฑ๐ถ๐ฎ๐ด๐ฟ๐ฎ๐บ๐ for their software system. If they are useful, component diagrams can be made, but for long-term documentation needs, youโll need to figure out how to automate changes to these diagrams.
Image source: c4model. com.