Mermaid SystemContextDiagram Spec¶
This schema describes the SystemContextDiagram spec for the Mermaid backend.
Properties¶
Properties
| Field | Type | Description |
|---|---|---|
type(required) |
string |
Type of the diagram. Must be exactly SystemContextDiagram. |
title |
string | null |
Optional diagram title. |
elements |
array[Element] |
Top-level elements. |
boundaries |
array[Boundary] |
Top-level boundaries. |
relationships |
array[MermaidRelationshipSchema] |
Top-level relationships. |
render_options |
MermaidRenderOptionsSchema |
Mermaid-specific render options. |
backend(required) |
string |
JSON schema backend. Must be exactly mermaid. |
Examples
JSON source
{
"backend": "mermaid",
"type": "SystemContextDiagram",
"elements": [
{
"type": "Person",
"alias": "user",
"label": "User"
},
{
"type": "System",
"alias": "app",
"label": "My App"
}
],
"relationships": [
{
"type": "REL",
"from": "user",
"to": "app",
"label": "Uses",
"technology": "HTTPS"
}
]
}
Rendered Mermaid source
C4Context
Person(user, "User")
System(app, "My App")
Rel(user, app, "Uses", "HTTPS")
Rendered image
JSON source
{
"backend": "mermaid",
"type": "SystemContextDiagram",
"title": "Retail Platform",
"elements": [
{
"type": "Person",
"label": "Customer",
"alias": "customer",
"description": "Places orders through the storefront."
},
{
"type": "PersonExt",
"label": "Support Agent",
"alias": "support_agent",
"description": "Handles issues in an external CRM."
},
{
"type": "SystemExt",
"label": "Payment Gateway",
"alias": "payment_gateway",
"description": "Processes card payments."
},
{
"type": "SystemExt",
"label": "CRM Platform",
"alias": "crm_platform",
"description": "External CRM used by support agents."
}
],
"boundaries": [
{
"type": "EnterpriseBoundary",
"label": "Acme Corp",
"alias": "acme_enterprise",
"description": "Internal systems owned by Acme.",
"elements": [
{
"type": "System",
"label": "Retail Platform",
"alias": "retail_platform",
"description": "Core platform for catalog, checkout, and order management."
}
],
"boundaries": [],
"relationships": []
}
],
"relationships": [
{
"type": "REL",
"from": "customer",
"to": "retail_platform",
"label": "Browses and places orders",
"technology": "HTTPS"
},
{
"type": "REL",
"from": "retail_platform",
"to": "payment_gateway",
"label": "Charges card",
"technology": "REST API"
},
{
"type": "REL",
"from": "support_agent",
"to": "crm_platform",
"label": "Manages customer issues",
"technology": "Web UI"
}
]
}
Rendered Mermaid source
C4Context
title Retail Platform
Person(customer, "Customer", "Places orders through the storefront.")
Person_Ext(support_agent, "Support Agent", "Handles issues in an external CRM.")
System_Ext(payment_gateway, "Payment Gateway", "Processes card payments.")
System_Ext(crm_platform, "CRM Platform", "External CRM used by support agents.")
Enterprise_Boundary(acme_enterprise, "Acme Corp", "Internal systems owned by Acme.") {
System(retail_platform, "Retail Platform", "Core platform for catalog, checkout, and order management.")
}
Rel(customer, retail_platform, "Browses and places orders", "HTTPS")
Rel(retail_platform, payment_gateway, "Charges card", "REST API")
Rel(support_agent, crm_platform, "Manages customer issues", "Web UI")
Rendered image
Elements¶
- MermaidPersonSchema
- MermaidPersonExtSchema
- MermaidSystemSchema
- MermaidSystemExtSchema
- MermaidSystemDbSchema
- MermaidSystemDbExtSchema
- MermaidSystemQueueSchema
- MermaidSystemQueueExtSchema
Boundaries¶
Relationships¶
Definitions¶
About labels and aliases
label is a display name for the element.
alias is a unique identifier used for referencing elements
in relationships and layouts.
If omitted, it is generated automatically.
You can also use label for referencing elements in relationships and layouts, but each label must be unique within the diagram.
RelationshipType¶
Relationship types supported by Mermaid C4 diagrams.
Items
| Type | Description |
|---|---|
BI_REL |
A bidirectional relationship between two elements. |
REL |
A unidirectional relationship between two elements. |
REL_BACK |
A unidirectional relationship pointing backward. |
REL_D |
A unidirectional downward relationship. Shorthand for REL_DOWN. |
REL_DOWN |
A unidirectional downward relationship. |
REL_L |
A unidirectional leftward relationship. Shorthand for REL_LEFT. |
REL_LEFT |
A unidirectional leftward relationship. |
REL_R |
A unidirectional rightward relationship. Shorthand for REL_RIGHT. |
REL_RIGHT |
A unidirectional rightward relationship. |
REL_U |
A unidirectional upward relationship. Shorthand for REL_UP. |
REL_UP |
A unidirectional upward relationship. |
DiagramElementPropertiesSchema¶
JSON schema for tabular diagram element properties.
Properties
| Field | Type | Description |
|---|---|---|
header |
array[string] |
Header columns. Default: ["Property", "Value"]. |
properties(required) |
array[array[string]] |
List of rows (each row is a list of string values). |
show_header |
boolean |
Whether to display the header row. Default: true. |
MermaidBoundarySchema¶
Mermaid JSON schema for a generic boundary.
Properties
| Field | Type | Description |
|---|---|---|
type(required) |
string |
Discriminator identifying the element type. Must be exactly Boundary. |
elements |
array[Element] |
Elements may be nested arbitrarily. |
boundaries |
array[Boundary] |
Boundaries may be nested arbitrarily. |
relationships |
array[MermaidRelationshipSchema] |
Relationships declared inside the boundary. |
alias |
string | null |
Unique identifier for the element. If not provided, it is autogenerated from the label. |
description |
string | null |
Optional description text. |
label(required) |
string |
Display name for the element. |
properties |
DiagramElementPropertiesSchema |
Optional property table metadata. |
stereotype |
string | null |
Optional Mermaid boundary type/stereotype label. |
MermaidEnterpriseBoundarySchema¶
Mermaid JSON schema for an enterprise boundary.
Properties
| Field | Type | Description |
|---|---|---|
type(required) |
string |
Discriminator identifying the element type. Must be exactly EnterpriseBoundary. |
elements |
array[Element] |
Elements may be nested arbitrarily. |
boundaries |
array[Boundary] |
Boundaries may be nested arbitrarily. |
relationships |
array[MermaidRelationshipSchema] |
Relationships declared inside the boundary. |
alias |
string | null |
Unique identifier for the element. If not provided, it is autogenerated from the label. |
description |
string | null |
Optional description text. |
label(required) |
string |
Display name for the element. |
properties |
DiagramElementPropertiesSchema |
Optional property table metadata. |
stereotype |
string | null |
Optional Mermaid boundary type/stereotype label. |
MermaidPersonExtSchema¶
Mermaid JSON schema for an external person.
Properties
| Field | Type | Description |
|---|---|---|
type(required) |
string |
Discriminator identifying the element type. Must be exactly PersonExt. |
alias |
string | null |
Unique identifier for the element. If not provided, it is autogenerated from the label. |
description |
string | null |
Optional description text. |
label(required) |
string |
Display name for the element. |
properties |
DiagramElementPropertiesSchema |
Optional property table metadata. |
MermaidPersonSchema¶
Mermaid JSON schema for a person.
Properties
| Field | Type | Description |
|---|---|---|
type(required) |
string |
Discriminator identifying the element type. Must be exactly Person. |
alias |
string | null |
Unique identifier for the element. If not provided, it is autogenerated from the label. |
description |
string | null |
Optional description text. |
label(required) |
string |
Display name for the element. |
properties |
DiagramElementPropertiesSchema |
Optional property table metadata. |
MermaidRelationshipSchema¶
JSON schema for relationships supported by Mermaid C4 diagrams.
Properties
| Field | Type | Description |
|---|---|---|
type(required) |
RelationshipType |
Type of the relationship. |
description |
string | null |
Additional details about the relationship. |
from(required) |
string |
The source element alias (or unique label). For Mermaid, this must resolve to a concrete element, not a boundary. |
label(required) |
string |
The label shown on the relationship edge. |
properties |
DiagramElementPropertiesSchema |
Optional property table metadata. |
technology |
string | null |
The technology used in the communication. |
to(required) |
string |
The destination element alias (or unique label). For Mermaid, this must resolve to a concrete element, not a boundary. |
MermaidSystemBoundarySchema¶
Mermaid JSON schema for a system boundary.
Properties
| Field | Type | Description |
|---|---|---|
type(required) |
string |
Discriminator identifying the element type. Must be exactly SystemBoundary. |
elements |
array[Element] |
Elements may be nested arbitrarily. |
boundaries |
array[Boundary] |
Boundaries may be nested arbitrarily. |
relationships |
array[MermaidRelationshipSchema] |
Relationships declared inside the boundary. |
alias |
string | null |
Unique identifier for the element. If not provided, it is autogenerated from the label. |
description |
string | null |
Optional description text. |
label(required) |
string |
Display name for the element. |
properties |
DiagramElementPropertiesSchema |
Optional property table metadata. |
stereotype |
string | null |
Optional Mermaid boundary type/stereotype label. |
MermaidSystemDbExtSchema¶
Mermaid JSON schema for an external database-like system.
Properties
| Field | Type | Description |
|---|---|---|
type(required) |
string |
Discriminator identifying the element type. Must be exactly SystemDbExt. |
alias |
string | null |
Unique identifier for the element. If not provided, it is autogenerated from the label. |
description |
string | null |
Optional description text. |
label(required) |
string |
Display name for the element. |
properties |
DiagramElementPropertiesSchema |
Optional property table metadata. |
MermaidSystemDbSchema¶
Mermaid JSON schema for a database-like system.
Properties
| Field | Type | Description |
|---|---|---|
type(required) |
string |
Discriminator identifying the element type. Must be exactly SystemDb. |
alias |
string | null |
Unique identifier for the element. If not provided, it is autogenerated from the label. |
description |
string | null |
Optional description text. |
label(required) |
string |
Display name for the element. |
properties |
DiagramElementPropertiesSchema |
Optional property table metadata. |
MermaidSystemExtSchema¶
Mermaid JSON schema for an external software system.
Properties
| Field | Type | Description |
|---|---|---|
type(required) |
string |
Discriminator identifying the element type. Must be exactly SystemExt. |
alias |
string | null |
Unique identifier for the element. If not provided, it is autogenerated from the label. |
description |
string | null |
Optional description text. |
label(required) |
string |
Display name for the element. |
properties |
DiagramElementPropertiesSchema |
Optional property table metadata. |
MermaidSystemQueueExtSchema¶
Mermaid JSON schema for an external queue-like system.
Properties
| Field | Type | Description |
|---|---|---|
type(required) |
string |
Discriminator identifying the element type. Must be exactly SystemQueueExt. |
alias |
string | null |
Unique identifier for the element. If not provided, it is autogenerated from the label. |
description |
string | null |
Optional description text. |
label(required) |
string |
Display name for the element. |
properties |
DiagramElementPropertiesSchema |
Optional property table metadata. |
MermaidSystemQueueSchema¶
Mermaid JSON schema for a queue-like system.
Properties
| Field | Type | Description |
|---|---|---|
type(required) |
string |
Discriminator identifying the element type. Must be exactly SystemQueue. |
alias |
string | null |
Unique identifier for the element. If not provided, it is autogenerated from the label. |
description |
string | null |
Optional description text. |
label(required) |
string |
Display name for the element. |
properties |
DiagramElementPropertiesSchema |
Optional property table metadata. |
MermaidSystemSchema¶
Mermaid JSON schema for a software system.
Properties
| Field | Type | Description |
|---|---|---|
type(required) |
string |
Discriminator identifying the element type. Must be exactly System. |
alias |
string | null |
Unique identifier for the element. If not provided, it is autogenerated from the label. |
description |
string | null |
Optional description text. |
label(required) |
string |
Display name for the element. |
properties |
DiagramElementPropertiesSchema |
Optional property table metadata. |
Mermaid Render Options¶
MermaidRenderOptionsSchema¶
Final layout configuration for rendering a Mermaid C4 diagram.
Encapsulates layout directives, macros, tag definitions, and visual styles applied at render time.
Properties
| Field | Type | Description |
|---|---|---|
styles |
array[ |
List of style update macro configurations. |
update_layout_config |
UpdateLayoutConfigSchema |
Configuration for updating default layout behavior. |
MermaidElementStyleSchema¶
Style update for an individual diagram element.
Properties
| Field | Type | Description |
|---|---|---|
type(required) |
string |
Discriminator identifying the element type. Must be exactly ElementStyle. |
bg_color |
string | null |
Background color. |
border_color |
string | null |
Border line color. |
element(required) |
string |
Alias of the element to style. |
font_color |
string | null |
Font/text color. |
MermaidRelStyleSchema¶
Style update for relationship lines.
Properties
| Field | Type | Description |
|---|---|---|
type(required) |
string |
Discriminator identifying the element type. Must be exactly RelStyle. |
from_element(required) |
string |
Alias of the source element to style. |
line_color |
string | null |
Color of the relationship line. |
offset_x |
integer | null |
Optional horizontal offset for the label position. |
offset_y |
integer | null |
Optional vertical offset for the label position. |
text_color |
string | null |
Color of the relationship label text. |
to_element(required) |
string |
Alias of the target element to style. |
UpdateLayoutConfigSchema¶
Configuration for updating default layout behavior in Mermaid C4 diagrams.
Properties
| Field | Type | Description |
|---|---|---|
c4_boundary_in_row |
integer | null |
Maximum number of boundaries per row. |
c4_shape_in_row |
integer | null |
Maximum number of non-boundary elements (e.g. systems, containers, components) per row. |