C4 diagrams
A person, a system, a container or a component is a box that says what it is and a sentence of what it does; a boundary is a group. Held to the same measure.
Declared with C4Context. Of 41 features Mermaid documents for a C4 diagram, 25 drawn as written, 16 drawn less something. See all 41 drawn both ways, or draw one yourself.

What is read
C4Context, C4Container, C4Component, C4Dynamic and C4Deployment are read into the same boxes and links as a flowchart, so everything else on this page holds for them: the rules, the design, Merlive's own lines. An element is a box that says what it is over its name and what it does under it; a boundary is a group; a relation is a link. In Merlive's own lines an element is its alias (%% note erp: …, %% main: buyer>erp).
| Written | Read as |
|---|---|
Person(buyer, "Buyer", "Raises orders") | A person: a box with the drawing of a person, «person» over its name, and what they do as its text |
System(erp, "ERP", "Holds orders") | A system: «system» over its name |
Container(api, "Order API", "C#", "Checks orders"), Component(…) | A container or a component, with what it is made in: «container: C#», «component: Repository» |
SystemDb, ContainerDb, ComponentDb | The same, drawn as a cylinder, of the kind that holds data: «container database: SQL Server» |
SystemQueue, ContainerQueue, ComponentQueue | The same, drawn as a pill, of the kind that holds data: «container queue: Service Bus» |
Person_Ext, System_Ext, ContainerDb_Ext and every other _Ext | Someone else's: of the kind external, and said so over its name («external system») |
System(erp), System(erp, "ERP<br/>live") | An element with no label is called by its alias; a <br/> in a label is a new line, and in a description a space |
| An element declared twice | The same element, said anew: the later line is what it is |
Boundary(firm, "The firm") { … }, Enterprise_Boundary, System_Boundary, Container_Boundary | A group of what is declared inside it, called by its label. The { may be on the line below |
Boundary(dept, "Buying", "department") { … } | A type that is written is added to the name: Buying [department]. One that is only implied (Enterprise_Boundary) is not |
Deployment_Node(azure, "Azure", "West Europe") { … }, Node, Node_L, Node_R | A node of a deployment is a group too, called Azure [West Europe] |
| A boundary inside a boundary | A group inside a group |
| A boundary or a node with nothing in it | A box of its name, «boundary» or «node: nginx» over it, with what it was described as for its text |
Rel(buyer, erp, "Raises orders in") | A link with an arrowhead, and its words |
Rel(web, api, "Calls", "HTTPS") | How it is made, after its words: Calls [HTTPS]. What a relation is described as beyond that is read past, as Mermaid reads past it |
BiRel(erp, bank, "Reconciles with") | A link with an arrowhead at both ends |
Rel_Back(buyer, erp, "Is told by") | A link from the second to the first |
Rel_U, Rel_Up, Rel_D, Rel_Down, Rel_L, Rel_Left, Rel_R, Rel_Right | A relation like any other: where a box goes is Merlive's to say |
Rel(…) in a C4Dynamic diagram, RelIndex(7, web, api, "Sends") | Numbered in the order written, as Mermaid numbers them: 1: Sends. The index a relation is given is read past, as Mermaid reads past it |
| Two relations between the same two | Both drawn. Mermaid keeps only the last |
| A relation with a boundary | A link to where the boundary begins, or from where it ends, as a link to any group is |
$descr="…", $techn="…", $type="…" | An argument given by name, wherever it stands |
"", or nothing between two commas | An argument left out |
"Raises orders, chases them (daily)" | Words in quotes keep their commas and brackets, and may run on down the lines |
$link="…", $tags="…", $sprite="…" | Read past: a page runs nothing of an author's, and Mermaid draws neither tags nor sprites |
UpdateElementStyle(erp, $bgColor="#b3261e") | A colour written as #rrggbb makes the element of the kind named for its hue, as a flowchart's style does; an element that is someone else's or holds data stays what it is. The colour of its words and its shadow are the design's |
UpdateRelStyle(buyer, erp, $offsetX="5"), UpdateLayoutConfig($c4ShapeInRow="2") | Read past: where a link's words sit and how many boxes are in a row are Merlive's to place |
title Ordering, in context, title: in front matter | What the picture is called, drawn above a still picture and as the heading of a page |
accTitle, accDescr, %% comments | As in a flowchart |
Not read, each named in a note, line when met: what a node of a deployment is described as when it has elements in it (a group has a name and nothing more); a colour given by name ($bgColor="grey": write it as #rrggbb); a colour for a boundary or for a link (UpdateRelStyle(…, $lineColor="blue")), which are the design's. A relation that names something nothing declares makes a box of that name, and says so. A line that is none of the above is said with its line number and nothing is drawn from it.
Merlive reads more kindly than Mermaid in three places, none of which changes a diagram Mermaid can draw: a last argument written without quotes (System(erp)), a comment after a line, and a relation with no words.
Feature by feature
Every feature Mermaid’s own pages set out for a C4 diagram, each with a sample of it in the corpus. A sample is drawn when every box, link and word it has is read and every rule passes. Drawn, less something is the same with one thing known to be missing, named beside it.
| Feature | Result | What is missing |
|---|---|---|
| A system in its context: a person, a system and one that is someone else's | Drawn | |
| People: one of the firm and one outside it | Drawn | |
| Systems: a system, one that is a database and one that is a queue | Drawn, less something | A queue is drawn as a pill: there is no cylinder on its side yet |
| Systems that are someone else's, a database and a queue among them | Drawn, less something | A queue is drawn as a pill: there is no cylinder on its side yet |
| Containers, with what each is made in and what it does | Drawn, less something | A queue is drawn as a pill: there is no cylinder on its side yet |
| Containers that are someone else's | Drawn, less something | A queue is drawn as a pill: there is no cylinder on its side yet |
| Components, with what each is made in and what it does | Drawn, less something | A queue is drawn as a pill: there is no cylinder on its side yet |
| Components that are someone else's | Drawn, less something | A queue is drawn as a pill: there is no cylinder on its side yet |
| A boundary round some of the elements | Drawn | |
| A boundary that says what kind of boundary it is | Drawn | |
| An enterprise's boundary with a system's boundary inside it | Drawn, less something | Mermaid writes [ENTERPRISE] and [SYSTEM] under the names of these boundaries; a type that was not written is not added |
| A container's boundary | Drawn, less something | Mermaid writes [CONTAINER] under the name of this boundary; a type that was not written is not added |
| Boundaries three deep | Drawn, less something | Mermaid writes [ENTERPRISE], [SYSTEM] and [CONTAINER] under the names of these boundaries; a type that was not written is not added |
| A boundary whose { is on the line below it | Drawn | |
| A deployment: nodes inside a node, and what runs on each | Drawn | |
| Nodes written as Node, Node_L and Node_R | Drawn | |
| A node that is described as well as named | Drawn, less something | What a node is described as is not drawn: a group has a name and nothing more |
| A relation | Drawn | |
| A relation that says how it is made, and one that is described | Drawn | |
| A relation that runs both ways | Drawn | |
| A relation that runs back, from the second to the first | Drawn | |
| Relations that say which way Mermaid should draw them | Drawn, less something | Up, down, left and right are read past: where a box goes is Merlive's to say |
| A dynamic diagram: what happens, in order | Drawn | |
| Relations given an index | Drawn | |
| Arguments given by name | Drawn | |
| Tags, links and sprites | Drawn, less something | A link is not followed: a page runs nothing of an author's. Tags and sprites are read past, as Mermaid reads past them |
| Arguments left empty | Drawn | |
| An element given colours of its own | Drawn, less something | Its fill is the colour written, as the nearest colour of the design; the colours of its words and its edge are the design's |
| An element given colours by name | Drawn, less something | A colour given by name is not read: only one written as #rrggbb is |
| A relation given colours of its own, and its words moved | Drawn, less something | A link's colour is the design's; where its words sit is Merlive's to place |
| A relation whose words are moved | Drawn | |
| How many elements and boundaries Mermaid should put in a row | Drawn | |
| A title | Drawn | |
| Front matter with a title | Drawn | |
| accTitle and accDescr | Drawn | |
| Comments on lines of their own | Drawn | |
| Commas, brackets and %% inside quotes | Drawn | |
| A line break in a label and in a description | Drawn | |
| Words in quotes that run on down the lines | Drawn | |
| An element declared twice | Drawn | |
| A whole diagram: people, a boundary of containers, a database, a queue and a system outside | Drawn, less something | A queue is drawn as a pill: there is no cylinder on its side yet |
Written from skills/merlive/reference.md in the repository, so the two cannot disagree.