The C4 model is a hierarchical way to visualize a software system. It uses four levels of abstraction, represented by the letters C, A, D, and P, to provide different levels of detail. Here's a summary of each "C":
1. Context (C):
- Purpose: Provides the highest-level overview of the entire system. It shows the system in its environment and how it interacts with users and other systems.
- Content: A single diagram showing the system as a whole, its users, and its connections to external systems. It focuses on the "big picture."
- Focus: Understanding the system's purpose and its relationship to the outside world.
- Example: A diagram showing a web application, its users (e.g., customers, administrators), and other systems it integrates with (e.g., payment gateways, databases).
2. Containers (A):
- Purpose: Breaks down the system into major components or "containers." These are high-level building blocks that encapsulate functionality.
- Content: Diagrams showing the major containers (e.g., web application, mobile app, database server) and how they interact with each other.
- Focus: Identifying the key components of the system and their responsibilities.
- Example: A diagram showing the containers of a web application: a web server, an application server, and a database server.
3. Components (D):
- Purpose: Decomposes each container into its constituent components. Components are self-contained units of functionality within a container.
- Content: Diagrams showing the components within each container and their relationships. These diagrams often use simple boxes and arrows to represent dependencies.
- Focus: Understanding the internal structure of each container and how its components work together.
- Example: Within the "application server" container, components might include a user authentication module, a product catalog module, and an order processing module.
4. Code (P):
- Purpose: Provides the most detailed view, showing the code structure of individual components. This level is often omitted unless necessary for specific technical discussions.
- Content: Diagrams showing the classes, functions, and other code elements within a component. Often uses UML class diagrams or similar notations.
- Focus: Understanding the implementation details of the system.
- Example: A UML class diagram showing the classes and relationships within the "product catalog module."
In essence, the C4 model provides a structured way to:
- Communicate: It offers a common language for discussing software systems with different stakeholders.
- Understand: It helps to break down complex systems into manageable parts.
- Document: It provides a visual representation of the system's architecture.
- Adapt: It allows for easier modification and evolution of the system.
The key is to start at the Context level and progressively zoom in to the Container, Component, and Code levels as needed. You don't need to create all four levels for every part of the system. The appropriate level of detail depends on the audience and the purpose of the diagram.