ADR-0019: Architecture maps from a native grid spec, with Mermaid block and architecture sources as later adapters
- Status: Proposed
- Date: 2026-12-02
Context
Section titled “Context”Vendor reference architectures share one form: stage columns with headers, a platform boundary holding panels under header bars, dense lists and two-column icon grids, cards with an icon over a title over a subtitle, arrows between neighbouring cells, numbered steps, a feedback arrow routed under the whole map, and highlighted-path variants of the same base map. Every one of them is an author-placed grid with flows drawn over it. The positions carry the meaning: Sources sits left of Ingest, which sits left of the platform, and the reader follows the stages left to right.
Three existing paths each lose part of that:
- A flowchart’s layered layout places nodes by graph rank to shorten and uncross edges (layout.md). It reorders the stages the diagram exists to show: automatic orientation stacks the columns vertically, zones swap places by edge rank, a panel whose items have no edges becomes a loose vertical list, an edge to a subgraph attaches to its first member, and a feedback edge cuts through the platform instead of running around it.
- The layer map (ADR-0016) holds authored order and column alignment, and its spec scopes out exactly what this genre needs: edges, column headers, spans, nested zones and icons.
- Mermaid has two inputs close to the genre.
block-betaplaces blocks on an authored grid withcolumns N,id:spanand nestedblock … end, with arrows and labels, but has no icons, column headers, views or step badges.architecture-betahas groups, services with icons, junctions and side-anchored edges, but it is beta, places services with a force-directed layout that is not deterministic without a seed, and has no stage columns or views. Both sit outside Merlion’s 1.0 scope (roadmap.md).
Decision
Section titled “Decision”The core renders a fourth input format, the merlion-architecture/1 JSON spec (architecture-map.md): a top-level grid of titled columns whose cells hold zones and items with column and row spans; zones nested up to four deep whose members flow in authored order into the zone’s columns; items in five forms (chip, icon, row, card, list) with 26 original built-in icons; flows routed orthogonally through the gutters by a deterministic lattice search, with parallel tracks, labels, numbered steps, a step legend and routes around the grid; and views that light a path and dim the rest, one SVG per view. It is exposed as render_architecture and check_architecture, the WASM exports of the same names, the JS functions renderArchitecture and checkArchitecture, and merlion render --architecture / merlion check --architecture with --view. Titled zones are cluster groups, items node groups and flows edge groups, so the embedded style, roles, palettes and the viewer’s pin, path highlighting, keyboard walk and collapse apply with no change to interact.js. The spec reuses the chart’s JSON reader, its codes E020 and E021, and the layer map’s E025, and adds E026 for placement and E027 for an unknown id.
Mermaid block-beta and architecture-beta become adapters onto this model, not the model itself: block-beta’s columns, spans and nested blocks map onto the grid nearly one to one, and architecture-beta’s groups, services, icons and junctions map onto zones and items once a placement rule is chosen.
Options considered
Section titled “Options considered”| Option | Buys | Costs |
|---|---|---|
Flowchart recipes only (subgraphs, classDef, invisible links) |
Nothing new to build; Mermaid sources render everywhere | The layered layout reorders stages by design; panel grids collapse into lists; a subgraph edge attaches to a member; a feedback edge cannot be routed around the map; there is no view |
| Extending the layer map in place with spans, nesting, column headers, icons and edges | One JSON format for both genres; the layer map’s reader and width fitting carry over | The layer map’s model is rows of cards in a fixed column count per zone, chosen to compare layers; spans, nested grids, flows and views would replace that model rather than extend it, and every layerMap: 1 member and test would carry a second contract |
Mermaid block-beta as the input |
Portable source; an authored grid with spans and nesting; flowchart shapes and classDef |
No icons, column headers, views or step badges; outside 1.0; mermaid’s routing between blocks is not a contract Merlion can match pixel for pixel |
Mermaid architecture-beta as the input |
Groups, services with icons, junctions, side-anchored edges | Beta; force-directed placement, non-deterministic without a seed and positioned by align lines only since v11.16; no stage columns or views; outside 1.0 |
A native spec, merlion-architecture/1, rendered by the core |
Exact author control of the grid; deterministic gutter routing with fixed tie-breaks; the views the references use; unknown members fail with a JSON Pointer path; the core’s determinism, measurement, theming, roles, outline and viewer contract apply; the Mermaid forms remain open as adapters | A fourth input format to maintain; GitHub shows the spec as code, as for charts and layer maps |
Criteria
Section titled “Criteria”Faithful stage order, determinism, author control, viewer budget and maintenance. Stage order ruled out flowchart recipes. Determinism ruled out architecture-beta as the model. Author control over headers, icons, steps and views ruled out block-beta as the model. Maintenance ruled out folding a second model into the layer map. A native spec whose output reuses the node, cluster and edge markup met the viewer budget with zero bytes added to interact.js, and keeps both Mermaid forms reachable as adapters.
Consequences
Section titled “Consequences”- Easier: an author or an agent writes columns, zones, items and flows as data, and every Merlion host draws a reference architecture that matches its diagrams’ fonts, colours, themes and interaction, at the density of the published references. A scenario is one more view over the same map, not a redrawn copy.
- Harder: four input formats share the core. The router’s lattice and the gutter widening that keeps maps compact are maintained with their own tests, and changes to the node, cluster or edge markup must keep architecture maps working in the viewer.
- Expensive to reverse: the member names, the placement and member-order rules, the id and role grammars, the classes and
data-merlion-*attributes in architecture-map.md, the outline line format the keyboard walk matches, the icon names, and the JS namesrenderArchitectureandcheckArchitecture. Breaking changes needarchitecture: 2. - Unmeasured: the compactness constants (item padding 6, member gaps 6, zone padding 8, the per-form widths) come from measuring the reference diagrams and fixture review, not from a reader study; no automated accessibility scan (axe-core) runs on architecture maps.
- Follow-ups: a
block-betaadapter, then anarchitecture-betaadapter, onto this model; a view switcher in the viewer that changes classes without re-rendering; brand and cloud logos through the caller icon hook; junction items for fan-in and fan-out.
References
Section titled “References”- M. Wybrow, K. Marriott and P. J. Stuckey. Orthogonal connector routing. Graph Drawing 2009, LNCS 5849 — routing over an orthogonal visibility graph with a bend penalty, then nudging shared segments apart.
- E. W. Dijkstra. A note on two problems in connexion with graphs. Numerische Mathematik 1, 1959.
- Mermaid. Block diagrams and Architecture diagrams syntax.