merIDK / Diagram types / C4 diagram
Mermaid C4 diagram: example and syntax
The C4 model describes software architecture at four zoom levels: context, container, component and code. A context diagram is the top level: your system, the people who use it and the systems around it.
Open this example in the editor
Example code
C4Context
title Online banking
Person(customer, "Customer", "Holds an account")
System(bank, "Banking app", "Lets customers manage money")
System_Ext(mail, "Email service", "Sends notifications")
Rel(customer, bank, "Uses")
Rel(bank, mail, "Sends email via")
Result
C4Context
title Online banking
Person(customer, "Customer", "Holds an account")
System(bank, "Banking app", "Lets customers manage money")
System_Ext(mail, "Email service", "Sends notifications")
Rel(customer, bank, "Uses")
Rel(bank, mail, "Sends email via")Syntax quick reference
- Elements:
Person(),System(),System_Ext(),Container(),ContainerDb(). - Relations:
Rel(from, to, "label"). - Other levels:
C4Container,C4Component,C4Dynamic,C4Deployment.
How to use it
- Open the example in the editor, or paste your own Mermaid code.
- Edit the code on the left. The preview updates as you type, and errors point to the line.
- Export SVG or PNG, copy a Markdown block for GitHub or Notion, or copy a share link.