C4 Model
Context, Container, Components and Code
Last updated
Context, Container, Components and Code
Last updated
A simple and clear model for documenting/visualizing Software Architecture.
It has 4 levels of detailed diagrams.
It is the highest level of abstraction and describes something that delivers value to its users.
This includes the software system being modelled, and any other depended softwares.
What is not Software Systems:
Product domains.
Bounded contexts.
Business capabilities.
Feature teams, tribes or squads.
Diagram exemple.
Represents an application or data store. (It is a Deployable Unit)
A container is something that needs to be running in order for overall software systems to work.
Server-side web applications: A container could be a Node.js application, a Ruby on Rails application, etc.
Client-side applications: A container could be an Angular or React SPA
or SSR
.
Serverless functions: A container could be a single serverless function (Ex.: Lambda, Azure Function, etc).
Database: A container could be a relational database, noSQL or Amazon RDS.
File systems: A container could be full local file system or portion or a larger networked fs (Ex.: SAN, NAS, etc).
Shell scripts: Could be a single shell script in Bash
.
Diagram example.
It is a grouping of related functionalities encapsulated behind a well defined interface.
All the Components inside a container execute in the same process space.
OOP languages: A component is made up of classes and interfaces.
Procedural programming languages: A component could be made up of a number of files in a particular directory.
JS: A component could be a JS module.
Diagram example.
These are one or more elements constructed with the basic building blocks of the used programming language, (like class
, interface
, enums
, function
, object
, etc).
Diagram example.
It is a library to create C4 Model diagrams through code.
A VSCode plugin named PlantUML
is also available to run PlantUML.
Requires Java and Graphviz.
Then execute in VSCode
this command PlantUML: Preview Current Diagram
.