C4 model: Context diagrams
简介 / Introduction
The C4 model is a layered approach to visualising software architecture — Context → Container → Component → Code. The Context diagram is the highest level, showing system boundaries, interactions between systems, and external actors. This article compares PlantUML and Mermaid side-by-side for rendering the same C4 Context diagram.
PlantUML 版
PlantUML uses the standard library C4 to draw C4 diagrams. Ensure the backend has plantuml-stdlib installed.
1 | !include <C4> |
The result is a system-context diagram: two actors (customer, employee) on the outside, three systems (Internet Banking System, Core Banking System, Email System) in the centre, with arrows indicating data flow direction.
Mermaid 版
Mermaid has built-in C4Context diagram support since v10, providing similar capability to PlantUML’s C4 library.
1 | C4Context |
对比 / Side-by-side
| Feature | PlantUML | Mermaid |
|---|---|---|
| Library import | !include <C4> |
Built-in C4Context |
| Person / System declaration | Person(id, "Name", "Desc") |
Same |
| Relationship syntax | Rel(from, to, "label") |
Same |
| Layout direction | Automatic | Automatic |
| Enterprise boundary | Supported via Enterprise_Boundary |
Not supported |
| External system notation | System_Ext |
System (same syntax) |
The two syntaxes are nearly identical. The main difference is that PlantUML requires importing the standard library, while Mermaid has C4 support built in. PlantUML’s Enterprise extensions offer richer boundary visualisations for complex organisational structures.
小结 / Wrap-up
C4 Context diagrams are the best starting point for showing the big picture of a system — no implementation details required, yet clear enough for non-technical stakeholders. PlantUML delivers the full feature set via its stdlib, while Mermaid covers most common use cases with its built-in syntax. Choose based on your team’s existing toolchain and need for enterprise-level features.
- Title: C4 model: Context diagrams
- Author: puml.online
- Created at : 2026-09-26 09:00:00
- Updated at : 2026-09-29 01:06:38
- Link: https://puml.online/blog/c4-diagram-context-en/
- License: This work is licensed under CC BY-NC-SA 4.0.