Skip to content

Architecture explorer

One HTML file that lets a reader drill from the system context down to the code, C4 style. Everything project-specific is one data block, window.MODEL, holding nodes, relationships, scenarios, state machines and, optionally, pictures and the data schemas. The rendering engine around it never changes, so a page can be rebuilt with a newer template at any time.

Open the live example Start from an empty explorer

The empty explorer is this page with nothing on its map: add boxes by hand (✎ Add a box), let an AI agent build the map (Agents in the page), or open a model.js. Your edits stay in your browser until you download them (model.js, the page, JSON-LD, Turtle, .rete, Mermaid).

What belongs on which level (is it a container or a component? a store or an external system?) is in Modelling with C4: a test for each type, the usual mistakes and a checklist.

Architecture explorer, container level

What readers can do

Map

Boxes open in place: from the system context (L1) to containers (L2), components (L3) and code (L4). A box with children shows a + N inside badge; double-click it or press the badge to open it, and the boxes around it make room. Keys 1 to 4 open the whole map to a level. Pan, zoom, a minimap and search (/) help on large models: press the minimap to move the view there, or drag the view's frame in it (on the map and in the Data view). Zoomed far out (below 34 %, a whole system at L3 or L4), each box shows only its name, large enough to read; rest the pointer on a box to see it at full size beside it, and click boxes to collect them: each keeps its large copy, with a ✕, and joins the selection, so you can compare several (see Reading the map zoomed out). Boxes, arrows, scenarios and schemas can carry icons: a glyph for what they are, or the logo of their technology.

The status bar along the bottom of the map says what is open (each name goes there when clicked), what is selected or which flow is playing, how many boxes are hidden or moved (with show all and reset layout), and the latest message, such as what an arrangement did. When it is longer than the bar it scrolls slowly like a ticker; rest the pointer on it (or tab into it) to hold it still and click. With reduced motion it does not move: it shows everything when you point at it. With nothing else to say it shows the usage hint.

Relationships are declared once, between the most specific elements known, and drawn between whatever is visible. A closed container therefore shows every relationship of the things inside it. Arrows are squared by default, running in the gaps between boxes on separate lanes; the edges ▾ menu (or E) switches to straight arrows that bend around boxes. An arrow label that would still overlap another label or a box is folded into a small ··· marker on its arrow: point at the arrow or the marker (or select one of its ends) to read it. The labels ▾ menu puts the labels in the boxes (the default, see Labels in the boxes), on the arrows or nowhere; L cycles through the three. Rest the pointer on an arrow or a row and a card tells you what it carries: both ends, the relationships behind it and the flow steps that travel along it. A click on an arrow selects it (see Selecting connections). Opening a box does not crowd it with traffic that is not its own: an arrow that has nothing inside an open box goes around it (Around open boxes in the edges ▾ menu, on by default; #around=0 turns it off).

Beyond the view. Zoomed in, arrows run off the edges of the map and the boxes at their other ends are out of sight. The border of the map then names them, the way a game points at what is off screen: on the side where an arrow leaves, a chip in its colour reads TO and the box it goes to (or FROM and the box it comes from), with the box's C4 level (L1 to L4), the arrow's label and a small pointer at the crossing. On the left and right sides the chips run along the border, turned so that their bottom faces out. Chips that would crowd merge into one ("5 arrows"); a click lists them. A click on a chip moves the view to that box, keeps the zoom, and keeps the arrow's label shown; hovering lights the arrow. With a selection, only its arrows count. Name them in the frame in the edges ▾ menu turns it off (#beyond=0).

Moving boxes. Point at a box and a round thumbtack button shows at its top right corner (on a touch screen, select the box first). Click it to free the box, then drag it to another place in its group; its arrows follow it while you drag. Dropped on another box, the two swap. While a free box is selected, the arrow keys move it one place. A drag on a fixed box still pans the map. The moves are your own view, kept in this browser for this project; the model, its downloads and the URL do not change. A chip in the status bar along the bottom of the map says N moved · reset layout. Edit mode starts from your moves: it writes them into the model's layout, as one step you can undo.

Arranging the boxes. arrange ▾ in the toolbar (or R) moves the boxes for you so that fewer arrows cross, bend or run behind a box. Tidy gives the fewest crossings, whatever the shape; Flow left → right and Flow top → bottom put each box before what it calls; Layers puts people first, then the software, then data stores and external systems. Arrange the whole map (every open box, then the top level) or this box (the boxes in the selected box when it is open, else the boxes around it). Every candidate is routed by the page's own router and kept only if it does better, and a line in the menu gives the numbers (crossings 15 → 6 · bends 80 → 72). The result is your own moves, as above: undo goes back one arrangement, reset layout back to the model's layout. In edit mode the same menu (also on the editor's rail) writes the cells into the model as at, one undoable edit. check-model.mjs --arrange prints the same suggestion per group, ready to copy into model.js.

The example with the API service open after Tidy on the whole map: the arrange menu lists Tidy, Flow left to right, Flow top to bottom and Layers, with whole map or this box; its last line reads "Tidy, the whole map: 1 of 3 groups changed, crossings 15 → 6, bends 80 → 72, your view only", and the status bar along the bottom of the map says what is open, 9 moved, reset layout, and repeats the arrangement's line

Tidy on the whole map, zoomed to the API service (#open=api): one of the three groups changed, its components now cross 6 times instead of 15.

Selecting several boxes. Ctrl + click (Cmd + click on macOS, or Shift + click anywhere) adds a box to the selection or takes it out. The selected boxes, everything inside them and every box at the other end of one of their arrows stay bright, and the rest fades. The panel then lists the selected boxes, the relationships between them, and what they use and are used by together; P pins them all.

Details panel

Click a box to see its description, notes, technology, source file and line (linked to the repository), the boxes inside it, and the lists of what it uses and what uses it. Every entry navigates to the other end.

With nothing selected, the first time you open a project the panel welcomes you with How to explore: the levels, the keys and the legend. After that it shows the project's Overview (its introduction and the boxes per level), and the guide waits behind the round ? at the start of the map's bottom line (or the ? key), in a card over the map.

The handle on the right edge of the map (or I) folds the panel away and gives the views the whole width; it stays folded when you select a box (the handle shows a dot) until you bring it back. On a phone the panel is a bottom sheet that folds to one line. The minimap's – button (or O) shrinks it to a small chip. Both remember their state and appear in the URL (#panel=closed, #mm=min). The minimap draws the boxes in colour, a hue per type: people in the accent colour, containers teal, components violet, data stores gold, states green, code grey.

Images

A box can carry pictures: screenshots of what a user sees, diagrams, photos, or mock-ups clearly labelled illustrative. It shows a small picture badge with the count; its panel has a gallery with captions, credits and the kind of picture, and a click on a picture or on the badge opens it in a viewer (Left Right to move, Esc to close). Arrows, scenarios and steps can carry pictures too: a step's picture (what the user sees there) appears in the Dynamic panel while that step is current. Images sit next to model.js in img/ and the build copies them next to the page (or --embed-images puts them inside it). Every image needs an alt text.

The image viewer open on the example's AnnotatePage component: a wireframe of the Annotate page, with an orange "illustrative" label, its caption, credit and alt text

The example's pictures are wireframes drawn from the page components' code and labelled illustrative: the example project was never run, so there is nothing to take a screenshot of.

Icons

A box, an arrow, a scenario, a schema or an entity can have an icon: a glyph for what it is (a user, a queue, a bucket) or the logo of its technology. It shows before a closed box's tag and an open box's title, at the start of an arrow's label (a small badge in the middle when labels are off), on IN / OUT rows, in the panel, the Pinned board, the Dynamic view, the Data view, search hits and exports. A page without icons looks exactly as before.

The example at level 2 with icons in brand colours: a user glyph on each person, the React, FastAPI and Python logos on the containers, the MinIO, PostgreSQL and Redis logos on the stores, a terminal glyph on minio-init, and small glyphs on some arrow labels (world-www, sql, stack-push)

The example at level 2 with icons in brand colours (#level=2&icons=brand). It has 29 icons (on 18 boxes, 4 arrows and 7 schemas), with 8 different technology logos.

icon What it is Licence
database, user, server, stack-push, bucket … one of 91 built-in glyphs from Tabler Icons, inside the page: they work offline MIT
tabler:<name> any Tabler icon (about 5,000; Tabler Icons 3.51.0) MIT
si:<slug> any Simple Icons brand logo (about 3,500; Simple Icons 16.37.0), such as si:postgresql the SVG data is CC0; each logo stays a trademark of its owner, shown only to identify the technology
a key of MODEL.icons, a file next to model.js, an https URL, a data: URI your own icon yours: give source and license

Vendor cloud icon sets (AWS, Azure, Google Cloud) are not open source: the plugin neither bundles nor fetches them. A model may point icon at such a file of its own when its terms allow it.

  • In the page, offline. build-explorer.mjs writes the library icons a model names into the page, from a local npm package (simple-icons, @tabler/icons), else a disk cache, else jsDelivr at the pinned versions. --no-fetch keeps the build off the network (icons not in the cache then draw as a dashed ? and the check warns); --icon-cache <dir> picks the cache folder. The model keeps only the reference.
  • Safe SVG. Every SVG is cut down to shapes before it is drawn (path, circle, rect … with their geometry, fill and stroke): scripts, links, images, text and styles are dropped, so a pasted icon cannot run anything.
  • Colours. mono (the default) draws an icon in the colour of the text beside it; brand draws a logo in its brand colour, but only where it keeps a contrast of at least 3:1 with what it sits on in the current theme (else mono); off hides them. The reader picks it in the Icons row of size ▾, the model sets the default (view.icons, view.showIcons), the URL overrides it (#icons=brand). iconColor on one icon sets brand or a tone for that icon.
  • Choosing icons. In edit mode, a box's Style, a connection and a scenario have an Icon field with a picker: it searches the built-in set offline, loads the Tabler and Simple Icons lists on demand (once per visit), suggests icons from the box's technologies, and takes your own SVG, pasted or from a file. A picked library icon is copied into MODEL.icons with its source and licence, so the downloaded page and model draw it offline. The whole model's form has Suggest icons from technology… for every box at once. From the command line, suggest-icons.mjs model.js proposes an icon per box and schema with the reason (a logo from the tag, name or tech, else a glyph from its words or type), and --apply-to copy.js writes them into a copy for you to compare.
  • Agents find icons with search_icons and set them with the edit tools' icon argument.

State machines

A lifecycle (task statuses, order states) is drawn as states and transitions inside the box that owns it, with the initial and final states marked.

A task lifecycle drawn as a state machine

Scenarios

The Dynamic tab (D) shows one runtime flow at a time, step by step, as a collaboration diagram, a sequence diagram or a step table. Draw it at any level, on the boxes open on the map, or on your pinned boxes: steps that stay inside one box are folded away. Step through with Left Right, or play it with Space. ☰ all scenarios (S) lists every scenario with a short explanation, the elements it passes through and its length.

Zoom in and out with the +, − and ⤢ (fit) buttons at the bottom right, as on the map, with + - F and 0 (100 %), or with a pinch. The collaboration diagram zooms with the wheel at the pointer and pans with a drag, like the map; so does the sequence diagram (the wheel zooms at the pointer, Shift + wheel scrolls sideways, a drag pans it, a double-click on its empty space fits it again; zoomed far out it becomes an overview of numbered arrows, each label in its tooltip), and its participant header and step list stay on top and on the left, aligned with the lanes; on the step table the buttons change the text size. The zoom stays while you step or play, and the current step is brought into view; another scenario, level or style fits again. Export still saves the whole diagram.

A scenario can also be read as a use case: its primary actor, goal, trigger, preconditions and outcome are listed under its description in the panel, when the model has them.

The Annotate + submit scenario as a sequence diagram at the container level, in its flow colour, with its use case in the panel

Every scenario has a colour of its own: its arrows, numbers and current step are drawn in it, and a swatch shows it next to the picker. Set one with color, or let the scenarios take distinct colours by order.

Flows on the map

flows ▾ in the toolbar (or W) paints one or several scenarios on the map, each in its colour: the arrows its steps travel along get a coloured band under them, with chips carrying the step numbers, and the boxes they pass through stay bright while the rest fades. Where several flows share an arrow, the band is striped in their colours and their chips sit side by side. A legend lists the flows on, plays one step by step on the map (▶, see A flow inside a box), opens one in the Dynamic view, or turns it off; the URL carries them (#flows=upload,review). Its – button folds it to a one-line chip (#legend=min, remembered; until you choose, it is folded on a narrow screen). Fitting the map keeps the boxes clear of the legend, as of the minimap, the zoom buttons and the status bar, and a fitted map makes room again when the legend appears or folds, or when the window changes size.

Two flows painted on the map at the container level: the annotate flow in gold and the review flow in violet, with numbered chips on the arrows, a striped band where they share an arrow, and the legend at the top right

Sequence inside a box

On the map, an open box that a scenario passes through gets a ⇅ sequence button. Its inside becomes a sequence diagram of that scenario: its own parts as lifelines, and the outside elements it talks to as dashed cards at the edges (callers on the left, what it calls on the right). Switch scenario with ‹ ›, play it with ▶ play, click a message for the code behind it, or select a part and show its own sequence to go one level deeper. The map's arrows run into the sequence itself rather than to an IN / OUT section: each one meets the message row it carries, where a dot and a chip with the step numbers (1·9) mark it; an arrow that no message of this scenario travels meets the card of the part it belongs to, named in its chip. Point at an arrow to light its row, or at a row to light its arrow.

A scenario drawn inside the API container on the map: the arrows from the web app, MinIO, PostgreSQL and Redis end at the message rows they carry, each with a dot on the border and a chip with its step numbers; step 3 is picked and the panel shows it

A flow inside a box

An open box that a scenario does something inside also gets a ⇄ flow button (or ⇄ Flow inside in its panel). It plays that scenario among the boxes inside, step by step, as a collaboration diagram drawn in place: nothing moves, so you see which of the parts you already know take part, and in which order. Each step is a numbered message on the arrow it travels (↩ against the arrow, dotted where no arrow joins the two), a ↻ badge on a box for a step inside it, and a step that comes in from outside or goes out crosses the border, where a chip names the other end (from MinIO · L2). The current step is drawn on top in the flow's colour, with both ends ringed; the steps before it stay coloured and the ones after it are faint, and the rest of the map fades.

The people who take part are in the flow, with their own actions, so it starts with whoever starts it. When a person's box is near (the people above an open system), it stays bright, is ringed on its step and the steps run from it. When it is far (the people at L3, far above a container), the person comes to the box as a card beside its border, and the steps run from the card.

⇢ left to right in the bar lays the boxes inside out in the order the flow reaches them while it plays: the box the flow comes in by first, then each box a column right of the one that reaches it, and the boxes it does not reach in a row underneath. It is only your view: turn it off, or leave the flow, and the boxes go back. The page remembers the choice.

The bar at the top right steps through it: the scenario picker, ‹ › (Left Right), ▶ play (Space, one step every 1.5 s), Dynamic › for the same scenario in the Dynamic view, and ✕ (Esc) to leave. The panel shows the current step with the code behind it and every step of the flow. Open a box inside to see its own parts take the steps; ▶ on a row of the flows legend plays that flow over the whole map. The URL carries it (#collab=api:upload&cstep=3, and &cflow=lr with left to right on).

The upload flow played inside the Image Annotation Tool at the container level: step 3, Web app → API service, drawn in blue on its arrow with both boxes ringed; the earlier steps coloured, the later ones faint; a ↻ badge on the API service for its inner steps, the Admin above the system bright with its arrow to the Web app (it acts in the flow), and the bar at the top right with the scenario, ⇢ left to right, 3 / 15 and play

The map and its sequence side by side

Press V (or ⫴ sequence in a flow's bar, or ⫴ with the map in the Dynamic view) and the flow's sequence diagram opens on the right of the map, in step with it. The current step is the same on both sides, and you move it from either: Left Right and Space, a click on a message or a row of the sequence, or a click on an arrow of the flow on the map. Select a box on the map and its lifeline lights up in the sequence; point at a message and its arrow lights up on the map, and the other way round. The map decides the lifelines: open the API service on the map and its components become lifelines in the sequence. The wheel over the sequence zooms it (not the map), with + - F while the pointer is over it. Drag the divider to give either side more room; ✕ or V closes the sequence and the flow goes on playing on the map, Esc closes both. The URL carries it (#collab=*:upload&cstep=3&split=1).

The map and the sequence side by side: the upload flow played over the map at the container level on step 3, Web app → API service, the same step highlighted as row 3 of the sequence on the right, whose lifelines are the boxes the map draws

Labels in the boxes

By default the arrow labels are in the boxes (In the boxes in the labels ▾ menu; #labels=arrow puts them on the arrows). Every box with arrows lists them under its body in two sections, each on a tinted panel: OUT in violet (the arrows it sends, label → target) and IN in teal (the arrows it receives, label ← source), and each arrow runs from its OUT row to its IN row, on the side facing the other box. By default both are unfolded, so each box says what it calls and what calls it; fold IN to see each label once, at the box that makes the call (the arrows of a folded section meet at its header). Click a header to fold or unfold it in that box, or use ▾ IN / ▾ OUT in the labels ▾ menu for every box (#io=out). Each row reads box first by default, → API service · POST /orders, so who talks to whom reads at a glance; Each row reads in the same menu puts the label first, POST /orders → API service, when what is said matters more (#iorder=label). Rest the pointer on a row (or focus it with Tab) and a card shows the whole connection: both ends with their level, every relationship behind it and the flow steps along it; +2 on a row means it carries more labels. A click on a row selects that connection (next section). Selection, flows (the rows take the flow's colour and its step numbers), compare mode, hidden boxes and exports all follow; the Mermaid text keeps its labels on the arrows.

The example at the container level with the API service open and the labels in the boxes: each component lists its outgoing arrows as rows, "label → target", and the arrows leave from those rows

Selecting connections

Often what you want to point at is a call, not a box. A click on an arrow, or on an IN or OUT row, selects that connection (a click on it again lets it go): its arrow is drawn thicker in the accent colour, its rows are marked at both ends, both ends stay bright and the rest fades. Ctrl / Cmd / Shift + click adds another row or takes it out, and the same on a section's header (IN · 3, OUT · 2) selects all of that box's inputs or outputs (a plain click on a header still folds it). Ctrl / Cmd / Shift + click on an arrow or its label does the same, whatever the labels. A connection is remembered by the relationships it carries, so it stays selected when you open or close boxes, and boxes and connections can be selected together (Ctrl + click adds either kind; a plain click starts again).

The example at level 2 with the labels in the boxes and the connection Reviewer → Web app selected: its arrow drawn in the accent colour from the Reviewer's OUT row to the Web app's IN header, the rest faded; the panel lists the relationship behind it with its source lines, and the three steps of the review flow that travel along it

The connection Reviewer → Web app selected (#level=2&labels=box&rel=2). The panel lists the relationship behind the arrow, with where each end lives in the source, and the flow steps that travel along it, each a button to that step in the Dynamic view.

The panel lists, for each selected arrow, its label, its two ends, the relationships behind it (a merged +N arrow has several; click one to keep only it, × to take it out), the flows whose steps travel along it, and their images, with Show on map, Select the ends and Clear selection. The URL carries the selection as relationship indexes (#rel=2,7), and agents select connections with select_relationships.

Reading the map zoomed out

A whole system at L3 or L4 opens far out, below 34 % zoom, where a box's own text is too small to read. There the map changes how it shows the boxes:

  • Names, large. Each closed box shows only its name (and its icon when there is room), about 13 px on screen, split over two lines when that fits better. A name too long for its box runs past its sides on a halo, or is cut with "…". Open boxes' titles grow too. Names zoomed out: normal in the size ▾ menu (#names=normal) keeps the boxes' own small text instead.
  • The pointer on a box shows it at full size beside it, after a moment: its tag, name, sub-line, badges and IN / OUT rows, as drawn zoomed in. Focusing a box with Tab does the same.
  • A click collects. Click (or tap) a box: its large copy stays, with a ✕ and a line to the box, and the box joins the selection. Click more boxes to compare them side by side; the panel lists them all. Click a collected box again, or its ✕, to let it go; Esc or a click on the empty map clears them. A double-click still opens a box. Zoom in and the copies go away; the selection stays.

The example at L3, opened far out: every box shows its name large (Tasks routes, API client, ORM models + session); PostgreSQL and Tasks routes are collected, each with its copy at full size beside it, joined by a dashed line, and the panel lists the two boxes selected; the pointer on MinIO shows its copy with its IN rows

Data

When the model describes the data, a fourth tab, Data (A), draws it like a database diagram: one frame per schema (a relational database, a JSON Schema, an ontology, a JSON-LD context, an object store, a queue, an API's payloads), titled with the box it lives in, and one card per table, class, object, bucket or message, with a row per field. Lines join specific fields, the column that holds an identifier to the field it identifies, dashed when no store enforces the link (an object key in a column, an id in a job or a file). Select a table to see where it lives, the code that defines it, and every flow step that reads or writes it; paint flows on the tables with W. On the map, a box that holds a schema carries a data badge, and a Dynamic step lists the fields it reads and writes. Schemas and data covers it all, with the importer that reads SQL, JSON Schema, OpenAPI, OWL / SHACL and JSON-LD files.

The Data view of the example: seven schemas as frames, each table, class, object, bucket and message as a card with a row per field, and lines between the fields

Deployment

When the model says where it runs (a deployment, written from the repository's compose files, manifests or infrastructure code), a Deployment tab (Y) draws one C4 deployment diagram per environment: the deployment nodes as nested frames, the instances of the map's containers on them (×N), infrastructure nodes, and the map's relationships between the instances. A container's panel on the map lists where it is deployed. See Deployment diagrams.

Pinned board, variants, themes

  • Pinned board (B): pin any boxes from any level (P) and see only them and the relationships between them, each inside a frame for the box it belongs to (a component in its container's frame, code in its component's), in the map's order. Unpin some and the rest close up. Pan and zoom it like the map: drag, wheel or pinch, F to fit; a double-click zooms to a box.
  • Variants: when parts of the architecture exist only in some configurations (cloud or on-premises, a feature flag), a filter fades what a variant does not use.
  • Colour themes (T or the theme ▾ menu): light and dark following the operating system by default, plus contrast, paper, blueprint and graphite.

The Pinned board on the example: the Annotator on its own; the Image Annotation Tool's frame holding the Web app, the worker, PostgreSQL and the API service's frame, which holds the pinned Auth and Images routes and, in the Tasks routes' frame, the pinned claim_next_task(); the arrows between them carry their labels - Sizes (size ▾): make the toolbars and panel smaller, spread the boxes further apart without making them bigger, or make the arrow labels and arrows smaller or larger. Remembered per browser. When the model has icons, an Icons row picks mono, brand or off. Names zoomed out picks large (the default) or normal. Long text says what a text cut with "…" does (an IN / OUT row, a box's name, a name drawn large zoomed out, a chip beyond the view): hover (the default) slides its whole words by under the pointer or the keyboard's focus, always slides every cut text in view (at most 40, still while the map moves), cut keeps it cut. Nothing slides when your system asks for reduced motion. - Links to any view: the URL hash records what is open and selected, the scenario and step, the flows painted, the theme and more (see URL parameters), so any view can be shared, reloaded or screenshotted.

Export a diagram

export ▾ → This view saves the diagram on screen as an SVG, a PNG or an HTML page of its own: the whole map (not only the part in the window), the Pinned board, the scenario's collaboration or sequence diagram, or the whole Data view, in the colours on screen, icons included. On the map, This view also offers Mermaid (next section). export ▾ → The whole explorer → Everything (.zip) downloads it all at once: the page, model.js, the RDF graph, the map as Mermaid text, the view on screen as SVG, the image files and a README, in one ZIP (the editor's Download menu has it too, with your edits). Standalone HTML saves this interactive page as one file: every view, the model in effect (your edits included), and its relative images and icon files put inside. A page opened from disk cannot read its own folder, so there those images stay links (keep the folder next to the file); opened from a web server, they go inside. export ▾ → The model downloads the architecture as an RDF graph: JSON-LD, Turtle or .rete (see RDF export).

The export menu open: SVG, PNG, HTML page or Mermaid for the view on screen, Standalone HTML for the whole explorer, JSON-LD, Turtle or a rete graph for the model

Mermaid

The map can also be Mermaid text, for the places the page cannot go: a README, a pull request, an issue, a wiki. GitHub and GitLab draw ```mermaid blocks. On the map, export ▾ → This view → Mermaid, or G, opens the Mermaid panel next to the map; G, ✕ or Esc closes it. The panel exists only on the map.

The Mermaid panel open next to the map of the example at level 2: the flowchart text with line numbers, the syntax and direction buttons, Copy and the .mmd, .md and SVG downloads, and below the text the live preview drawn by mermaid.js; Apply to the model and Reset at the bottom

The example at level 2 with the Mermaid panel open and the details panel folded (#level=2&mmd=flowchart&panel=closed). The text is the map as drawn: the three people, the software system as a subgraph, its containers and stores, and the arrows between them, merged as on the map (proxies /api/ +11).

  • What it holds. One view of the map: the boxes drawn and the arrows between them, lifted to the boxes drawn and merged as the map merges them (first label +N), with the variant filter applied. Comment lines (%% c4-explorer: level=2 …) record the view and any ids Mermaid had to change, so the text maps back to the model.
  • Two syntaxes. flowchart (the default, TB or LR): open boxes are nested subgraphs, people rounded boxes, data stores cylinders, each type in the explorer's colours. C4: Mermaid's own C4 diagrams (C4Context, C4Container or C4Component, after the deepest level drawn) with technology and descriptions.
  • Edit it. The text is editable, with line numbers, and a live preview under it, redrawn as you type. A line Mermaid cannot read shows its error; the last good drawing stays. The preview is drawn by mermaid.js 11.17.2, which the page loads from jsDelivr the first time the panel opens, and only then. Offline (and always in the MCP view, which loads nothing) the preview says why it is missing, and the text, Copy and the downloads still work.
  • Copy and download. Copy; .mmd (the text); .md (a Markdown file with a title, the view and the diagram in a mermaid block, ready for a README or an issue); SVG (the preview as drawn); Reset (the text made again from the map).
  • It follows the map. Open or close boxes, change the level or the variant filter, or edit the model, and the text is made again. If you have edited it, a bar asks first: make it again from the map or keep my text.
  • Apply to the model. Apply to the model… reads the edited text back and lists what it would change, and what it cannot apply with the reason. Nothing changes until you confirm; then all the changes go in as one step that Ctrl+Z undoes. It applies renamed boxes; in C4, a box's description, technology and tag; new boxes (their type from the shape or C4 function and where they sit), boxes moved into another subgraph or boundary, removed boxes; new arrows; and an arrow that stands for exactly one relationship relabelled, dashed or drawn solid, or removed. It skips, and says why: arrows that are merged or lifted (change those in the editor, or open the boxes), a change of a box's type, a box placed where C4 does not put its type, a new box whose id is hidden inside a closed box, and any change the validator refuses (the features reference lists every case). Colours and layout statements only style the diagram and are not read back.

Limits: Mermaid's C4 layout is basic (shapes in rows, arrows may cross labels), so for more than about a dozen boxes the flowchart reads better. Mermaid's C4 cannot attach an arrow to a boundary, so arrows declared on an open box stay out of the C4 text, as commented-out Rel lines with a note (the flowchart draws them). The downloaded SVG uses HTML labels, as Mermaid draws them, so tools that read SVG without HTML support may not show the text.

Mermaid in your README

model-to-mermaid.mjs writes the same text from model.js (or from a page or an RDF graph), without a browser:

node <plugin>/skills/architecture-explorer/scripts/model-to-mermaid.mjs \
  communications/architecture-explorer/model.js --all --out docs/architecture.md

--all writes one Markdown file that GitHub renders: the system context, the containers, and what is inside each container, each diagram under a heading in a mermaid block (five diagrams for the example). --level N or --open a,b picks one view, --syntax flowchart|c4 and --direction TB|LR the form, --variant a variant, and without --out the text goes to standard output. For the example at level 1:

node skills/architecture-explorer/scripts/model-to-mermaid.mjs \
  examples/image-annotation-tool/communications/architecture-explorer/model.js --level 1
flowchart TB
  %% c4-explorer: level=1 syntax=flowchart direction=TB
  annotator("Annotator")
  reviewer("Reviewer")
  admin("Admin")
  iat["Image Annotation Tool"]
  admin -->|"uploads batches, exports"| iat
  annotator -->|"draws + submits boxes"| iat
  reviewer -->|"approves / rejects"| iat

  classDef person fill:#1d4f7a,stroke:#1d4f7a,color:#f4f6f9
  classDef system fill:#e2edf7,stroke:#1d4f7a,stroke-width:2px,color:#142231
  class annotator,reviewer,admin person
  class iat system
  linkStyle default stroke:#5a6878,color:#5a6878

GitHub draws that block as a flowchart in the explorer's colours. With --syntax c4 the same view is Mermaid's C4 diagram, with each box's description; this page draws it live with Mermaid (the site's theme restyles the text of flowchart boxes, so the live example here is the C4 one):

C4Context
  title Image Annotation Tool · System context
  %% c4-explorer: level=1 syntax=c4
  Person(annotator, "Annotator", "Claims a task, draws and labels bounding boxes on the image, submits it for review, and fixes rejected tasks.")
  Person(reviewer, "Reviewer", "Works through the review queue and approves each submitted task or rejects it with a mandatory comment.")
  Person(admin, "Admin", "Uploads batches of images and triggers exports of approved annotations. Role "admin" in the users table.")
  System(iat, "Image Annotation Tool", "Bounding-box annotation with a review step. Each uploaded image gets exactly one task; only approved tasks are exported as COCO-style JSON.")
  Rel(admin, iat, "uploads batches, exports")
  Rel(annotator, iat, "draws + submits boxes")
  Rel(reviewer, iat, "approves / rejects")

The text is generated: regenerate it when the model changes rather than keeping two copies. Its %% c4-explorer lines let a reader paste an edited version into the page's Mermaid panel and apply it to the model.

Issues: what does not add up

The coherence rules check that the parts of the model agree with each other: a step that no arrow carries, a step against its arrow or out of nowhere, data a step cannot reach, a queue with only one side, two containers that call each other, a front end on a database, a lifecycle state nothing leads to (the full list, and why each matters, is in Coherence checks). The chip next to export ▾ counts the open findings by severity (⚠ 5 i 6); a click opens the Issues area in the details panel: the findings grouped by severity and rule, with filters and a search. Each finding reads at a glance: a verdict in bold ("No arrow carries this step"), its boxes and step as chips in the box's colour (a click goes there), the plain sentence, the area as a tag; opened, a small diagram of what the rule found, with the real names (what is missing dashed in the severity's colour, what is there instead in grey), why it matters, how to fix it, and How this was found: the rule's logic in words, the values that matched, what was checked and not found, the facts and the SPARQL. A card on the map repeats the finding you are on. The Log tab shows what each run of the rules did: per rule, the candidates, the ones kept, the findings and the time (see How a finding is explained). On the map the boxes of the findings get a ring and a badge, their arrows a dashed halo and their steps a numbered chip; a click on a finding selects and fits just its parts, and Left / Right go through them. dismiss… records, with a reason, a finding that is right as it is (it goes into the model, view.coherence.ignore, and stays dismissed when the page is rebuilt). The findings come from the build (with rete-graph installed); ↻ Re-check runs the rules again on the model as it is now, edits included, and needs the network.

The Issues area on the example: the findings listed by severity and rule in the details panel, each with its verdict, its boxes and step as chips and its sentence; the current one opened with a diagram of the missing arrow, why it matters and how to fix it; a card at the map's top left repeats it; on the map the boxes of the findings ringed with a severity badge and the step no arrow carries drawn as a dashed line with a numbered chip

Edit the model in the page

The ✎ edit handle on the left edge of the map, the mirror of the details handle on the right, turns the page into an editor of its own model; while you edit it reads ‹ done and puts the editor away. A tool rail runs down the left of the views: the element types by C4 level (drag one onto the map, or press it to add one inside the selected box), the Relationship tool, the Outline and Properties, then undo, redo, the downloads, discard edits and ✓ done. Each button says what it does when you point at it, and the arrow keys move along the rail. The details panel stays on the right, as for readers. The rail's first button (or I) opens the drawer beside it, folded until you open it; its edge drags to make it wider, and on a phone the rail is a row along the bottom and the drawer a sheet above it. The drawer has three sections that fold open and closed and remember it:

Edit mode on the example: the tool rail on the left, its drawer open on the Add section (element types by C4 level), the selected box's card beside it on the map, and a dot on each side of the box under the pointer, to draw a connection from

  • Add: the element types by C4 level, each drawn as its box in the current theme. Drag one onto the map (into an open box, onto a closed one, or at the top level) or into the outline: while you drag, the boxes it may go into are outlined, and one it may not go into is marked in red with the reason (a component goes inside a container, a container inside a software system, and so on). Or press a type (or Enter), on the rail or in the drawer, to add one inside the selected box. The Relationship tool connects two boxes: pick the source, then the target.
  • Outline: the whole model as a tree, with the scenarios and their steps. Click a row to select the box and show it on the map; drag rows to reorder them or to move a box into another (checked against where it may go); rename in place (F2), duplicate, add inside, or delete (a bar in the drawer asks first). Every action also has keys: arrows, Enter, F2, Del, Alt + arrows to move, Shift+F10 for the menu.
  • Properties: the selected box's fields in groups (identity, description and notes, technology and tag, source, style with its icon, relationships, images, RDF); a scenario's name, colour on the map, icon, use case and steps; or, with nothing selected, the project, source links, RDF settings and opening view. Images come from a file (embedded in the model, scaled down if large), a path next to model.js or an https address, and need their alt text before they are added.

On the map itself you edit in place. The selected box gets a card beside it, which follows it as you pan and zoom: name, type, second line, technology, description and colour, then add inside, connect, icon, duplicate and delete (⋯ opens every field in the drawer; Esc closes it). The colours are swatches in the theme's own colours: the type's default look, eight tones, highlight, plain, and the look of another type under more; pick one with a click or the arrow keys. A tone gets a field for what it means, which goes into the legend. Select several boxes (Ctrl / Cmd / Shift + click) and their card colours them all in one step. Rename a box where it is: double-click its name, or press F2 (or Enter on the selected box); Enter keeps the name, Esc does not. A new box dropped on the map is named this way. To connect two boxes, point at one: a dot shows on each of its sides. Drag from a dot to the other box and let go, then type what happens along the arrow in the card that opens (Alt+drag from the box works too). A click on an arrow opens its card: label, colour swatches, dashed, reverse, delete; Ctrl + click on more arrows, and one row colours all the selected connections. Drag a box itself to move it. Every change is checked by the page's validator before it is made, and can be undone (Ctrl+Z, Ctrl+Y). The edits stay in the browser until you download them: model.js to rebuild from, the whole page with the new model inside, or the graph as JSON-LD, Turtle (.ttl) or .rete. Try it on the live example.

#edit=1 in the address opens the page in edit mode, with the edits kept in your browser already restored, and the address keeps it while you edit, so a reload brings you back where you were. A model with no boxes at all (nodes: []) is a valid start: the map then offers ✎ Add a box, an agent (Agents in the page), or Open a model… (a model.js, the MODEL as JSON, an explorer page, or an RDF graph as N-Triples).

Versions and compare mode

Built with the history of its model (--history, from the architecture-history skill), the page gets a history bar along the bottom of the views: step through the versions or play them, and compare two, with added boxes and arrows in green, removed ones as red ghosts and changed ones in amber, each change listed with who made it and when. Changes roll up: a closed box with changes anywhere inside carries a badge with their counts (+2 −1 ~3), so they are visible from the system context down. The Data view compares the same way: added tables and columns in green, removed ones as ghosts, changed ones in amber. ▴ History (or H) opens a drawer with every version, its message, authors, pull request and changes; click a change to go to it. See History and diffs.

Agent tools

The page offers its own tools to an AI agent: read the model, open levels and boxes, hide boxes, zoom, select connections, show a scenario or paint flows, arrange the boxes, open the Data view on a table or a field, get the map as Mermaid text, find icons, and change the model: add, connect, change, move, group and delete boxes and arrows, many at once, and undo. Every change waits for you to click Apply in a bar on the page (or, if you allow it for the tab, applies with a running count and a stop button), and is one undoable edit. A browser with WebMCP lists the tools to its agent; an agent that runs JavaScript in the page (Claude Code through Claude in Chrome, Playwright) calls window.archTools.call(…). See Agents in the page. The MCP server offers the same tools in its chat view, and the ones that read a model as server tools.

Hiding boxes

"Hide on the map" in a box's details panel, or X, leaves the selected boxes out of the map with what is inside them and their arrows, to make room for the part you are looking at; the model does not change. A chip in the status bar says how many (its ▾ lists them, with show for each) and show all (Shift+X). The URL carries them (#hide=web,minio), and the Mermaid text leaves them out too. The Pinned board and the Dynamic and Data views still show them.

Keyboard

Key Action
1 to 4 Open the map to that level
/ Search
F, +, - Fit, zoom in, zoom out (the map, or the Data view or the Dynamic view when it is shown; on the step table, the text size; beside the map, the sequence while the pointer is over it)
0 Dynamic: 100 %
M, B, D, A, Y Map, Pinned board, Dynamic, Data (only when the model has entities), Deployment (only when it has a deployment)
K Data view: keys only (identifiers, references, unique and referenced fields)
J Data view: every line, or back to the default (maps lines on demand)
P Pin or unpin the selected box (every selected box)
X, Shift+X Hide the selected boxes on the map; show every hidden box again
R Map: the arrange menu, to place the boxes so that fewer arrows cross (see Arranging the boxes, above)
Ctrl / Cmd / Shift + click, or + Enter on a focused box Add the box to the selection, or take it out (Map and Pinned board)
Click on an arrow, or click or Enter on an IN / OUT row Select that connection (again: let it go); with Ctrl / Cmd / Shift, add it or take it out
Click a box when zoomed out (below 34 %) Collect it: its large copy stays beside it and it joins the selection (again: let it go)
Ctrl / Cmd / Shift + click on an arrow, a row header or +K more Add that connection, or all of that box's inputs or outputs, to the selection (or take them out)
Tab, Enter, Space on a box Focus, select, open or close it
Left Right Up Down Map: move the selected box one place, when it is free to move (see Moving boxes, above)
S Map: the sequence inside the selected box, or its boxes again · Dynamic: the list of all scenarios
G Map: the Mermaid panel, open or closed
Left Right with the Issues area open Previous, next finding (Esc in the area closes it)
L, E, T Arrow labels (in the boxes, off, on the arrows), arrow style (squared or straight), next colour theme (the labels ▾, edges ▾ and theme ▾ menus list the choices)
W Map and Data view: the flows menu, to paint scenarios on the map or on the data
I Hide or show the details panel (the bottom sheet on a phone); in edit mode, open or fold the editor's drawer
O Minimize or restore the minimap
? How to explore: the keys and the legend, in a card over the map
Left Right Space Dynamic: previous step, next step, play
Left Right, Space Sequence inside a box: previous or next message; play, once a message is picked
Left Right, Space A flow inside a box (⇄ flow): previous or next step; play or pause
V The flow's sequence beside the map, in step with it (from the Dynamic view: that scenario and step); again: close it
Left Right Image viewer: previous or next picture
Esc Clear the selection (boxes and connections), then leave a flow played on the map; with the version list or the image viewer open, close it first
[ ], C, H With a history: previous or next version, compare mode on or off, the version list
Up Down Home End In the version list, a list of changes or the theme, labels or edges menu: move between the entries (Enter or Space activates)
Del, Ctrl+Z, Ctrl+Y (or Ctrl+Shift+Z) Edit mode: delete the selected boxes, undo, redo
F2, Enter Edit mode, on the map: rename the selected box in place (Enter keeps the name, Esc does not)
Alt + drag Edit mode: connect two boxes on the map (or drag from a dot on a box's side to the other box)
Esc Edit mode: cancel a drag from the rail or the Add section, a connection being drawn, or the Relationship tool; close the card on the map
Arrows, Home, End Edit mode, on the tool rail: move along it (Enter or Space presses a button)
Arrows, Home, End Edit mode, in the outline: move, open or close a branch
F2, Del Edit mode, in the outline: rename in place, delete (a bar in the drawer asks first)
Alt+Up Alt+Down, Alt+Left, Alt+Right Edit mode, in the outline: move among its siblings, out of its box, into the box above it
Shift+F10 Edit mode, in the outline: the item's actions (rename, add inside, duplicate, move, delete)

URL parameters

The part of the URL after # mirrors what is on screen and is read when the page opens, so any view can be linked, reloaded or screenshotted. Parameters are joined with &, for example index.html#open=api&zoom=api&theme=dark.

Parameter Meaning
level=3 Map opened to that level
open=api,orders Exactly these boxes open (and their ancestors)
sel=place-order, sel=a,b,c The selected box, or several
rel=3,7 The connections selected, as relationship indexes (MODEL.edges)
icons=brand, icons=mono, icons=off Icons in brand colours, in the colour of their text, or none (when it differs from the model's default)
names=normal Zoomed out, the boxes keep their own small text (default: their names drawn large)
marquee=off, marquee=always Long text: cut texts stay cut, or every cut text in view slides by (default: under the pointer)
variant=cloud The variant filter
hide=web,minio Boxes hidden on the map
edit=1 Edit mode, with the edits kept in this browser restored
labels=arrow, labels=0 Arrow labels on the arrows, or off (default: in the boxes)
io=out, io=in, io=none Labels in the boxes: the sections unfolded in every box (default: both)
iorder=label Labels in the boxes: each row reads label first (default: box first)
edges=straight, edges=orthogonal Arrow style, when it differs from the model's default
beyond=0 No chips in the map's border for the arrows that leave the view
around=0 Arrows may cross open boxes they have nothing in (the shortest way)
theme=paper Colour theme for this visit (auto or a theme name); not saved
view=pins, view=dynamic, view=data The Pinned board, the Dynamic view or the Data view (#pins, #dynamic, #data work too)
view=deploy&env=local&dsel=api The Deployment view, on an environment, with a node or an instance selected
entity=tasks, field=tasks.status, schema=pg, line=f:images.uploaded_by Data view: the entities selected, one field, one schema or one line
keys=1, lines=all, dzoom=pg Data view: keys only; the kinds of line drawn always (refs, struct, maps, all, none); open zoomed to a schema or entity
scenario=checkout&at=3&style=seq&step=4 Dynamic view: scenario id, level (1–4, map, pins), style (collab, seq, list), step from 1
dynzoom=2 Dynamic view: the zoom, as a multiple of the fitted view (the step table: its text size), centred on the current step
seq=api:checkout,worker Boxes showing the sequence inside, each with a scenario id (default: the first one through that box)
seqstep=api:3 The message picked in that box's sequence, from 1
collab=api:upload&cstep=3 A scenario played inside that box on the map (collab=*:upload: the whole map), on that step from 1; &cflow=lr: its boxes left to right
split=1 With collab=: its sequence beside the map
zoom=api Fit the camera to that box instead of the whole map (read only)
pins=a,b,c Use these pins for this visit (read only)
flows=upload,review Scenarios painted on the map, or on the data in the Data view
mmd=flowchart, mmd=flowchart-lr, mmd=c4 The Mermaid panel open on the map, with that syntax and direction
legend=min, legend=full The flows legend folded to one line, or unfolded (overrides the stored choice)
panel=closed, panel=open The details panel folded away, or open (overrides the reader's stored choice)
mm=min, mm=full The minimap minimized to its chip, or full (overrides the stored choice)
ver=4d60afd, cmp=a889a40 With a history: the version drawn, and the version it is compared with
hist=open, hx=4d60afd,f702ebd With a history: the version list open, and the entries unfolded in it
hshow=milestones, hlast=50, hkinds=merge,pr, hfrom=…, hto=…, hby=…, hchips=20 With a history: the History settings (which versions the bar walks)

How the page is built

communications/architecture-explorer/
  model.js              window.MODEL = { project, nodes, edges, scenarios, schemas, entities, ... };
  index.html            the template with model.js pasted between /* BEGIN MODEL */ and /* END MODEL */
  architecture.jsonld   the same model as an RDF graph
  architecture.ttl      the same graph in Turtle
  img/                  pictures the model shows, if any

A minimal model:

window.MODEL = {
  project: { name: 'Shoply', subtitle: 'acme/shoply', intro: 'Online shop backend. Start at the API service.' },
  nodes: [
    { id: 'shopper', type: 'person', name: 'Shopper', desc: 'Buys things through the web shop.' },
    { id: 'shoply', type: 'system', name: 'Shoply', desc: 'Takes orders and charges customers.' },
    { id: 'api', parent: 'shoply', type: 'container', name: 'API service', path: 'api/', desc: 'Only entry point.' },
    { id: 'db', parent: 'shoply', type: 'store', name: 'Orders DB', desc: 'System of record.' }
  ],
  edges: [
    { from: 'shopper', to: 'api', label: 'POST /orders', kind: 'accent' },
    { from: 'api', to: 'db', label: 'INSERT order' }
  ],
  scenarios: [
    { id: 'checkout', name: 'Checkout', desc: 'A shopper pays for a basket.', steps: [
      { from: 'shopper', to: 'api', label: 'POST /orders' },
      { from: 'api', to: 'db', label: 'INSERT' },
      { from: 'api', to: 'shopper', label: '201 · order id', reply: true }
    ] }
  ]
};

The full schema (use cases, flow colours, images, the data layer and extension terms included) is in the data model reference, and the features reference covers layout, colour themes, switching features off, and how to make a good diagram (what the levels mean, how many boxes, naming, edges, scenarios).

Build and check

node <plugin>/skills/architecture-explorer/scripts/build-explorer.mjs \
  communications/architecture-explorer/model.js \
  communications/architecture-explorer/index.html --root .

The build copies the template, inserts the model, writes architecture.jsonld and architecture.ttl, and runs check-model.mjs:

  • schema errors (unknown ids, duplicates, overlapping positions) and warnings (text that will not fit, missing descriptions, crowded groups);
  • with --root, every path exists and every line is inside its file (boxes, and schemas, entities and fields);
  • modelling hints (HINT): a model that looks like one of the usual C4 mistakes, such as a library drawn as a container, a data store that calls, a reply drawn as an arrow back, or scenario steps that name a container instead of its parts. They are information, never warnings; each names the section of Modelling with C4 that explains it (--no-hints leaves them out);
  • every relative image exists next to the model; it is copied next to the page, or put inside it with --embed-images;
  • a layout report per group of boxes: arrows that bend around a box, cross, or still pass behind one;
  • with a data layer, a DATA line: schemas, entities, fields, lines by kind, crossings, and any line that crosses a card;
  • every icon: the library icons it names are written into the page (ICONS lines say from where; --no-fetch, --icon-cache <dir>), an icon that cannot be found is a warning, and an unsafe custom SVG an error.

import-schema.mjs turns SQL migrations, JSON Schema, OpenAPI, OWL / RDFS / SHACL and JSON-LD contexts into the data layer of a model, and --check reports where a model has drifted from them (see Schemas and data).

--history history.json embeds the model's versions (see History and diffs). A graph (.ttl, .jsonld, .nt, .rete) can stand in for model.js: the page is then recreated from it (see RDF export).

scripts/screenshot.mjs captures any view with headless Chrome or Edge, using the URL parameters:

node <plugin>/skills/architecture-explorer/scripts/screenshot.mjs index.html shots \
  "level=2" "open=api&zoom=api" "view=dynamic&scenario=checkout&style=seq&at=3" \
  "level=2&seq=api:checkout&zoom=api" "level=2&flows=checkout&theme=dark"