Skip to content

Architecture maps

An architecture map draws the diagrams that platform reference architectures use: stage columns, a platform boundary holding panels under header bars, lists and grids of components with icons, numbered flows, a feedback flow around the map, and highlighted-path variants of one base map. A merlion-architecture/1 JSON spec places every zone and item on a grid you choose, so the stages stay in the order you wrote them, and Merlion routes the flows through the gaps between them. The full contract is in specs/architecture-map.md.

Two sources feed a platform with a raw and a curated layer, which serves two consumers; forecasts feed back to the orders database under the map:

{
"architecture": 1,
"title": "Order analytics platform",
"columns": [
{ "id": "sources", "title": "Sources" },
{ "id": "platform", "title": "Platform" },
{ "id": "consumers", "title": "Consumers" }
],
"zones": [
{ "id": "lake", "title": "Analytics platform", "header": "bar", "role": "accent", "cols": 2, "at": { "column": "platform", "rows": 2 } },
{ "id": "raw", "title": "Raw", "header": "bar", "style": "dashed", "in": "lake" },
{ "id": "curated", "title": "Curated", "header": "bar", "style": "dashed", "in": "lake" }
],
"items": [
{ "id": "orders-db", "label": "Orders database", "icon": "database", "form": "icon", "at": { "column": "sources", "row": 0 } },
{ "id": "clickstream", "label": "Clickstream", "icon": "stream", "form": "icon", "at": { "column": "sources", "row": 1 } },
{ "id": "landed", "label": "Landed tables", "icon": "table", "form": "row", "in": "raw" },
{ "id": "events", "label": "Event log", "icon": "queue", "form": "row", "in": "raw" },
{ "id": "orders", "label": "Order facts", "icon": "warehouse", "form": "row", "in": "curated" },
{ "id": "sessions", "label": "Sessions", "icon": "users", "form": "row", "in": "curated" },
{ "id": "reports", "label": "Reports", "detail": "Daily and weekly", "icon": "dashboard", "at": { "column": "consumers", "row": 0 } },
{ "id": "models", "label": "Forecasts", "detail": "Demand models", "icon": "model", "at": { "column": "consumers", "row": 1 } }
],
"flows": [
{ "id": "load", "from": "orders-db", "to": "raw", "step": 1, "note": "Change data capture lands orders" },
{ "from": "clickstream", "to": "raw" },
{ "id": "refine", "from": "raw", "to": "curated", "step": 2, "note": "Nightly jobs refine raw tables" },
{ "id": "serve", "from": "curated", "to": "reports", "label": "SQL" },
{ "from": "curated", "to": "models" },
{ "from": "models", "to": "orders-db", "around": "bottom", "label": "Reorder signals" }
],
"views": [
{ "id": "reporting", "title": "Reporting path", "lit": ["orders-db", "raw", "curated", "reports", "load", "refine", "serve"] }
]
}
  • columns are the top-level grid. A top-level zone or item takes a cell with at: a column (an index or a column id), and optionally span, row and rows. Column widths and row heights come from what they hold, so cells in one row line up.
  • A zone’s members take in instead of at and flow in the order you wrote them into the zone’s cols columns: its zones first, then its items. A span lets a member cover several of them. A zone with style: "none" is an invisible container, for side-by-side panels or a list beside a box.
  • header: "bar" draws the zone’s title in a filled strip; style is solid, dashed, filled or none; icon puts a badge on the zone’s top edge.
  • An item’s form is chip (a box with a label and a detail line), icon (a large icon over its label), row (a small icon beside a short label), card (an icon over a bold title over a subtitle) or list (a bullet or check list of list entries). icon names one of 26 built-in glyphs, such as database, stream, api or dashboard.
  • A flow joins items, zones or columns. A zone or column end attaches to its side, not to a member. step draws a numbered badge, note adds that step to the legend below the map, both draws an arrowhead at each end, and around routes the flow outside the whole grid.
  • role takes the built-in roles, as on flowcharts. Without a role, each top-level zone takes the next series tone; --no-auto-tone turns that off.

Render it, and one view of it:

Terminal window
merlion render --architecture analytics.json -o analytics.svg
merlion render --architecture analytics.json --view reporting -o analytics-reporting.svg

From JavaScript, through the WASM package:

import { initSync, renderArchitecture } from "@fractalboxdev/merlion-wasm";
const { svg, outline, diagnostics } = renderArchitecture(spec, { view: "reporting" });

renderArchitecture accepts the spec as an object or as JSON text.

Flows are orthogonal and run only through the gaps between cells and members: never through an item they do not join, never across a title, and never through a zone that holds neither end. Where the facing sides of two ends overlap, the flow is a straight line. Flows that share a run move apart onto parallel tracks, and a gap that carries flows, arrowheads, labels or badges widens just enough to hold them; the rest stay tight, so a map keeps the density of a hand-drawn reference diagram. The routes are a pure function of the spec and the options: the same spec draws the same bytes on every machine.

When the map’s natural width is above the target width, it keeps its layout and its SVG scales down in its container; below it, columns widen by up to a quarter.

A view lights a path through the map and dims everything else, as the scenario pages of reference architectures do. lit lists items, zones and flow ids; a listed zone lights everything inside it, and a flow lights when both of its ends do. Each view is its own SVG, with no script: render one per view and place them where the story needs them.

The outline, returned as outline and written into the SVG’s <desc>, names every zone, every item with its zones, and every flow:

Architecture map. Order analytics platform. 3 columns, 3 zones, 8 items, 6 flows.
Columns: Sources, Platform, Consumers.
Zone: Analytics platform
Zone: Analytics platform / Raw
Analytics platform / Raw: Landed tables
Orders database → Raw (step 1)
Curated → Reports [SQL]
Step 1: Change data capture lands orders

In <merlion-view>, a tap on an item pins it and lights its flows and the items at their other ends; Shift and a tap lights the whole path upstream and downstream. The arrow keys walk the items and announce each one’s outline line, and a tap on a zone title collapses the zone.

These fail with an error that names the JSON path, line and column:

  • A member the spec does not define, such as "colour", or a header without a title (E021).
  • An id used twice (E025): the message names the first use.
  • A cell outside the columns or overlapping another, a span wider than its zone, or zones nested more than four deep (E026).
  • An id that in, a flow or a view names and no element has (E027).

An unknown icon name is a warning (W027), and the item draws without an icon. merlion check --architecture and checkArchitecture report every problem at once.