Skip to content

C4 Diagram

Last updated:

Mermaid Studio provides comprehensive support for C4 model diagrams inside IntelliJ-based IDEs, making it easy to document your system architecture without leaving your editor. C4 diagrams visualize software architecture at different levels of abstraction — Context, Container, Component, and Dynamic — and Mermaid Studio supports every variant.

Syntax highlighting integrates directly with IntelliJ’s color scheme system, so diagram colors always match your editor theme.

C4 diagram syntax highlighting in Armada Dark theme

Mermaid Studio provides comprehensive support for C4 diagrams:

  • Syntax highlighting - Color-coded elements, boundaries, and relationships
  • Code completion - Suggestions for C4 elements and relationship types
  • Live templates - Abbreviations that scaffold elements, boundaries, deployment nodes, relationships, and styling overrides
  • Documentation hover - See element descriptions on hover
  • Refactoring - Rename elements and update all references
  • Find usages - See where elements are referenced
  • Inlay hints - Inline parameter hints for clarity
  • Code Vision - Relationship counts at a glance
  • Navigation bar - Quick access to elements
  • Brace matching - Navigate boundary delimiters
  • Code folding - Collapse boundaries and containers
  • Formatting - Auto-format your diagram code
  • Inspections - Detect undefined references
  • Color provider - Preview and pick colors for styling
  • Structure view - Hierarchical overview of elements and boundaries

A set of 40 context-aware live templates scaffolds the people, systems, containers, components, boundaries, deployment nodes, relationships, and styling overrides that C4 diagrams use. Type a short abbreviation, accept it from the completion popup, and tab through the template variables.

Individual abbreviations can be toggled under Settings > Tools > Mermaid Studio > Live Templates in the C4 group. See Live Templates for the cross-cutting mechanics (triggering, contextual visibility, configuration).

The e-suffixed abbreviations produce the _Ext external variants of each element.

AbbreviationExpansion
perPerson (Person(alias, "label", "desc"))
pereExternal person (Person_Ext(...))
sysSoftware system (System(...))
sysdbSystem database (SystemDb(...))
sysqSystem queue (SystemQueue(...))
syseExternal software system (System_Ext(...))
sysdbeExternal system database (SystemDb_Ext(...))
sysqeExternal system queue (SystemQueue_Ext(...))
AbbreviationExpansion
conContainer (Container(alias, "label", "techn", "desc"))
condbContainer database (ContainerDb(...))
conqContainer queue (ContainerQueue(...))
coneExternal container (Container_Ext(...))
condbeExternal container database (ContainerDb_Ext(...))
conqeExternal container queue (ContainerQueue_Ext(...))
AbbreviationExpansion
cmpComponent (Component(...))
cmpdbComponent database (ComponentDb(...))
cmpqComponent queue (ComponentQueue(...))
cmpeExternal component (Component_Ext(...))
cmpdbeExternal component database (ComponentDb_Ext(...))
cmpqeExternal component queue (ComponentQueue_Ext(...))

Each boundary template wraps its body in a block you tab into to add nested elements.

AbbreviationExpansion
bndBoundary block (Boundary(alias, "label") { ... })
ebEnterprise boundary block (Enterprise_Boundary(...) { ... })
sbSystem boundary block (System_Boundary(...) { ... })
cbContainer boundary block (Container_Boundary(...) { ... })
AbbreviationExpansion
dnodeDeployment node block (Deployment_Node(alias, "label", "type") { ... })
nodeNode block (Node(...) { ... })
nodelLeft-aligned node block (Node_L(...) { ... })
noderRight-aligned node block (Node_R(...) { ... })

The directional templates pin the arrow direction, and rli is the indexed form used in dynamic diagrams. The from and to fields draw on name completion, so they suggest the aliases already declared in the diagram.

AbbreviationExpansion
relRelationship (Rel(from, to, "label"))
reltRelationship with technology (Rel(from, to, "label", "techn"))
birelBidirectional relationship (BiRel(from, to, "label"))
reluRelationship pointing up (Rel_Up(...))
reldRelationship pointing down (Rel_Down(...))
rellRelationship pointing left (Rel_Left(...))
relrRelationship pointing right (Rel_Right(...))
relbBack relationship (Rel_Back(...))
rliIndexed relationship for dynamic diagrams (RelIndex(index, from, to, "label"))
AbbreviationExpansion
uesUpdate element style (UpdateElementStyle(alias, $bgColor=..., $fontColor=...))
ursUpdate relationship style (UpdateRelStyle(from, to, $textColor=..., $lineColor=...))
ulcUpdate layout config (UpdateLayoutConfig($c4ShapeInRow=..., $c4BoundaryInRow=...))

The sample picker seeds a new diagram from a working example instead of a blank file. C4 now ships a starter for each level, so you can begin from the abstraction you’re documenting rather than rebuilding the scaffolding from C4Context by hand.

The picker lists the C4 starters alongside the rest of the catalog, with a live preview of the selected one.

Five C4 starters are available, one per level. Container, Component, Dynamic, and Deployment are new in this release; Context shipped previously.

SampleStarts you with
C4 ContextA system in scope, its users, and external systems it interacts with.
C4 ContainerContainers within a system: apps, services, data stores.
C4 ComponentComponents inside a container and their interactions.
C4 DynamicRuntime collaboration between elements, step by step.
C4 DeploymentHow containers map onto infrastructure nodes.

Each starter has a Basic and a Styled variant; toggle between them in the picker’s toolbar before inserting.

Diagram types:

  • C4Context - System context (highest level)
  • C4Container - Container diagram
  • C4Component - Component diagram
  • C4Dynamic - Dynamic/sequence view

Elements:

C4Container
Person(user, "User", "Description")
System(sys, "System", "Description")
System_Ext(ext, "External", "Description")
Container(cont, "Container", "Tech", "Description")
ContainerDb(db, "Database", "PostgreSQL", "Stores data")

Boundaries:

C4Container
System_Boundary(b1, "My System") {
Container(api, "API", "Node.js")
ContainerDb(db, "Database", "PostgreSQL")
}

Relationships:

  • Rel(from, to, "label") - Basic relationship
  • Rel(from, to, "label", "technology") - With technology
  • BiRel(a, b, "label") - Bidirectional

For the complete syntax reference, see the Mermaid.js C4 Diagram documentation.