English

Developer guide Internals

Library format

The JSON format of reference architectures, and how the insurer entry is built.

On this page

A reference architecture is one JSON file in the library folder: server/library/ by default, or the folder in ARCHIPELEGO_LIBRARY. The server code is server/src/library.ts.

The entry

ts
interface LibraryEntry {
  id: string;
  title: string;
  description?: string;
  tags?: string[];
  canvas: {
    title: string;
    layers?: { id: string; name: string; height: number }[];
    blocks: { id: string }[];
    links: { id: string }[];
    notes?: { id: string }[];
  };
}

The canvas object is a full canvas file: format: 'archipelego', version: 1, title, layers, blocks, links and notes, as in Data model. Generated entries also carry a source field that names the research file they come from.

Validation

  • The file name without .json is the entry id. It must match ^[a-z0-9-]{1,64}$.
  • The file must parse as JSON and have a canvas.blocks array. Anything else is skipped.
  • The list is sorted by title.

A minimal entry

json
{
  "id": "two-tier-web",
  "title": "Two-tier web app",
  "description": "A browser, one application and its database.",
  "tags": ["web"],
  "canvas": {
    "format": "archipelego",
    "version": 1,
    "title": "Two-tier web app",
    "layers": [
      { "id": "experience", "name": "Experience", "height": 288 },
      { "id": "apps", "name": "Applications & Agents", "height": 288 },
      { "id": "data", "name": "Data & Platforms", "height": 288 }
    ],
    "blocks": [
      { "id": "b_user", "kind": "persona", "x": 0, "y": 72, "w": 168, "h": 96, "title": "Customer" },
      { "id": "b_app", "kind": "application", "x": 0, "y": 360, "w": 168, "h": 96, "title": "Web app", "subtitle": "node 24" },
      { "id": "b_db", "kind": "database", "x": 0, "y": 648, "w": 168, "h": 96, "title": "Orders", "subtitle": "postgres 17" }
    ],
    "links": [
      { "id": "l_0", "from": "b_user", "to": "b_app", "kind": "sync", "label": "HTTPS" },
      { "id": "l_1", "from": "b_app", "to": "b_db", "kind": "sync", "label": "reads, writes" }
    ],
    "notes": []
  }
}

Save it as server/library/two-tier-web.json. The library picks it up on the next request, without a restart.

The API

GET /api/library returns one summary per entry:

ts
export interface LibrarySummary {
  id: string;
  title: string;
  description: string;
  tags: string[];
  layers: string[];
  blocks: number;
  links: number;
  notes: number;
}

POST /api/library/<id>/open calls openLibraryEntry. It creates a new canvas id (32 random bytes, URL-safe base64), builds a Y.Doc, and writes it as <id>.yjs in the data folder. The meta map gets title, version 1.0.0, source (the entry id) and, when the entry has layers, layers as JSON. Blocks, links and notes go into their maps as they are. The response is 201 with { "id": "<new canvas id>" }, or 404 for an unknown entry.

Building the insurer entry

server/library/agentic-insurer.json is generated. Rebuild it with:

bash
npm run library

scripts/build-library.mjs reads docs/research/agentic-insurer-reference.json and lays out the canvas.

The input

Field Shape
id, title, description The entry's identity.
layers { id, name, description }, top to bottom.
blocks { key, layer, kind, proposedKind?, title, subtitle, domain, ... }. domain is shared or a business line.
links { from, to, kind, label }, with block keys.
stickies { text, attachTo? }. attachTo is a block key.

A block uses proposedKind when it is a known kind, then kind, then falls back to application. Block ids become b_<key>.

The layout

Constant Value
GRID 24
W 168, the block width
H 96, the block height
  • The layers stack top to bottom as guided bands. Each band's height is rounded up to whole grid rows.
  • In each band, shared blocks come first.
  • Then each business line gets one dashed zone: P&C (IARD), Health, Life & savings, Wealth management and Asset management. Zone ids are z_<layer>_<line>.
  • A business line keeps the same column in every layer, so a workshop reads one line straight down.
  • A zone is as wide as the busiest layer of its line needs, at most four blocks across.
  • Post-its with attachTo are pinned to their block. The others line up to the right of the canvas. Colours cycle through blue, pink, yellow, green and violet.

The script prints the number of layers, blocks, zones, links, broken links and post-its, and the rows per layer.