Browse our guides or talk to our team.
A C4 Model describes or defines software architecture at different levels of detail. A C4 Model is a set of diagrams representing the context, containers, components, and code of a piece of software. The hierarchy of these diagrams allows different audiences to understand the software architecture at the level of detail they need.
You can use a C4 model for microservices, to show how you’re planning to build a system, to describe an existing system, or visualize your enterprise cloud strategy. C4 diagrams are an alternative, simplified framework compared to UML diagrams and can describe multiple systems, unlike more specific AWS architecture diagrams, GCP architecture diagrams, or Azure architecture diagrams.
The C4 Model was created by Software Architecture for Developers author, Simon Brown.
To jump straight into diagramming, you can sign up for a free trial of Gliffy Online.
There are four types of C4 models, each one for a different audience and containing a different level of detail. These are the context, container, components, and code diagrams that make up your software architecture model.
Context diagrams are the most general description of what your system does, who will use it, and what other systems it will interact with. A context diagram will help you describe the scope of your project and help you pinpoint who the user is and what problem you’re going to solve.
The container diagram takes the first step into describing the software system and shows the APIs, applications, databases, and microservices that the system will use. Each of these applications or services is represented with a container and the interactions between them are shown at a high level.
One step deeper than the container diagram, the component diagram details groups of code within a single container. These components represent abstractions of your codebase.
This diagram type is comparable to a UML component diagram, but follows a less-strict set of “rules” in order to create the software architecture diagram.
The last level requires lots of detail to show how the code of a single component is actually implemented. To do this, you would want to make a UML class diagram or entity relationship diagram that describes the component.
Depending on your project and the containers or components you need to describe, you’ll end up having a set of four or more diagrams that represent your C4 model. If you make a C4 model in Gliffy, you can use links directly on shapes in your diagrams to allow users to double-click into deeper levels of your model.
In Gliffy, you’ll open a new diagram and use basic shapes to build your context diagram. Drag and drop the shapes that represent your software system, including your user or persona and any software systems connected to the one you’re diagramming. As you drag and drop shapes, type to add text that labels or describes the components in your diagram.
Each shape in C4 Models usually includes:
While working on your context diagram, consider setting style rules that will dictate how you draw the additional diagrams of a C4 model. For example, you could choose to put the system you’re describing in a darker blue color than the systems it interacts with. Your users or personas could be a different color as well. External elements should always be the same color.
These rules will create visual consistency that allows viewers to quickly read and understand all four diagrams in relation to one another.
Using the connector tool in the Gliffy toolbar, drag and drop lines between the elements in your context diagram. You can select a line and type to give it a label.
To re-style the line, click the line and then click on the dark grey line icon that appears alongside it. Here, you can change the color, stroke, and style of the connector or add arrowheads to indicate the directions data flows throughout your system.
In the upper right side of Gliffy’s toolbar, click the layer button to open the layers panel.
Double-click to rename your current layer, giving it a clear name like “Context Diagram.” Then, click the duplicate layer button to quickly copy this layer. Rename your copy for the next level of the C4 model, the container diagram.
You can toggle the visibility of these layers by hovering over the layer name and then clicking the eye icon that appears to the right. You can also lock the additional layers to prevent accidental editing.
Select your new container diagram layer and rearrange the shapes and information you included in your context diagram to drill one level deeper into the details.
You can drag out an additional shape or rectangle to create a boundary for the elements in the container you’re describing. To make sure this shape doesn’t get in the way of the additional elements, use the Send to Back option in the toolbar to set it behind everything else on your container diagram layer.
When you get to Step 4, duplicate your Container Diagram layer so that you can use it as a base or template for the Component Diagram.
Your component diagram will detail the code inside the container you described in the previous diagram. Just follow the same steps, moving the existing diagram elements to make space for more details.
Your last diagram in the C4 model will detail the code included in your system — but this level of detail isn’t always required to create an effective description of your architecture. It’s common to make a UML class diagram to describe this code, if you decide it’s necessary.
You can use Gliffy’s dynamic layer linking feature to create “buttons” that allow your diagram viewers to toggle through the layers of your C4 model. This functionality is not available for free trial accounts.
If you’d like to make it possible for a viewer to toggle through the layers of your C4 model, you can add a new layer and name it something like “Layer View,” then draw out four shapes to act as buttons to toggle through each layer.
Open the layers panel and click on the shape you’d like to use to show the Context Diagram layer. Then, click the layer link icon on the lower right side of the layers panel. From here, simply select the layers you want to display when a diagram viewer clicks on this button. Click save to lock in your changes. You’ll see a small eye icon appear next to the shape.
Repeat for the additional buttons in your diagram.
When you’re done, save your diagram and generate a link by clicking the “Share” button. Using that new share link, you can double-check that your buttons work to toggle through the layers as expected.
While C4 models are useful to have in your back pocket as a reference, they’re more useful when it comes to keeping everyone on a team on the same page. In addition to sharing your C4 model via a link, you can also export and embed your diagram. Here are the other ways to share your final diagram:
▶️ Video resource: Exporting from Gliffy
🔎 Guide: Embedding Diagrams with Gliffy
For basic C4 modeling, you can use Gliffy to describe your architecture. Gliffy also supports drawing and diagramming for other types of software architecture diagrams or software engineering diagrams, likeUML diagrams, Entity-Relationship diagrams, and cloud architecture diagrams.
If you haven’t yet, be sure to sign up for a free trial to try it yourself.
Try Online Atlassian Apps