Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

C4 diagrams

sirene draws Mermaid C4 diagrams (C4Context, C4Container, C4Component, C4Dynamic, and C4Deployment) as images and as text. Elements fill rows from the left, boundaries go below them, and in text the relations are listed under the drawing:

C4Container
    title Shop
    Person(user, "Customer")
    System_Boundary(shop, "Shop") {
        Container(web, "Web App", "Go", "Serves pages")
        ContainerDb(db, "Database", "Postgres")
    }
    Rel(user, web, "Uses", "HTTPS")
    Rel(web, db, "Reads")
the drawing of the mermaid source above

See crates/sirene-core/tests/fixtures/c4/valid/ for context, container, and deployment diagrams. In the editor a C4 diagram is read-only on the drawing side.

What is read

SyntaxDrawn as
Person, System, Container, Componenta box with its <<type>>, label, [technology], and description; a person has an icon
...Db, ...Queue (e.g. SystemDb, ContainerQueue)a cylinder, upright or lying down
..._Ext (e.g. Person_Ext, SystemDb_Ext)the external colors
Boundary, Enterprise_Boundary, System_Boundary, Container_Boundarya dashed box titled at the top left with its kind
Deployment_Node, Node, Node_L, Node_Ra solid box titled at the top left
Rel, Rel_U, Rel_D, Rel_L, Rel_R, RelIndexan arrow with its label and [technology]
Rel_Back, BiRelan arrow the other way, or both ways
UpdateElementStyle, UpdateRelStylethe colors given by $bgColor, $fontColor, $borderColor, $textColor, $lineColor
UpdateLayoutConfig$c4ShapeInRow elements and $c4BoundaryInRow boundaries per row
title, frontmatter titlethe title above
accTitle, accDescrread, not drawn

Arguments go by position or by name ($descr="...") and may be quoted.

Errors

A statement that is none of the above, an unclosed string, (, or {, and a stray } are errors. An id declared twice, an element without an alias, and a relation to an unknown id are errors and skipped. A { after an element is a warning and its contents are drawn outside it. A macro that is read but not drawn, such as AddElementTag or Lay_R, and a row count that is not a whole number of at least 1, are warnings.

Not drawn

Tags, sprites, links, relation offsets, and Rel_U/Rel_D/Rel_L/Rel_R directions are ignored, and boundary styles are not drawn. Theme variables are ignored.