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.
An analytics platform, stage by stage
Section titled “An analytics platform, stage by stage”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"] } ]}columnsare the top-level grid. A top-level zone or item takes a cell withat: acolumn(an index or a column id), and optionallyspan,rowandrows. Column widths and row heights come from what they hold, so cells in one row line up.- A zone’s members take
ininstead ofatand flow in the order you wrote them into the zone’scolscolumns: its zones first, then its items. Aspanlets a member cover several of them. A zone withstyle: "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;styleissolid,dashed,filledornone;iconputs a badge on the zone’s top edge.- An item’s
formischip(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) orlist(a bullet or check list oflistentries).iconnames one of 26 built-in glyphs, such asdatabase,stream,apiordashboard. - A flow joins items, zones or columns. A zone or column end attaches to its side, not to a member.
stepdraws a numbered badge,noteadds that step to the legend below the map,bothdraws an arrowhead at each end, andaroundroutes the flow outside the whole grid. roletakes the built-in roles, as on flowcharts. Without arole, each top-level zone takes the next series tone;--no-auto-toneturns that off.
Render it, and one view of it:
merlion render --architecture analytics.json -o analytics.svgmerlion render --architecture analytics.json --view reporting -o analytics-reporting.svgFrom 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 run in the gutters
Section titled “Flows run in the gutters”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.
Reading it without a mouse
Section titled “Reading it without a mouse”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 platformZone: Analytics platform / RawAnalytics platform / Raw: Landed tablesOrders database → Raw (step 1)Curated → Reports [SQL]Step 1: Change data capture lands ordersIn <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.
Errors name their path
Section titled “Errors name their path”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
spanwider 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.