Data model¶
Everything project-specific lives in one block of the explorer HTML:
It is a JavaScript object literal, not strict JSON: single quotes, trailing commas and // comments are fine. Never write the literal text </script> inside it. Nothing outside the two markers needs editing.
The model shipped in the template carries placeholder: true. A real model must not have that field; the validator warns while it is present.
The page validates the model at boot. Errors replace the page with a list of what is wrong; warnings go to the browser console. scripts/check-model.mjs runs the same validator from the command line.
Top-level fields¶
| Field | Required | What it drives |
|---|---|---|
project |
yes | Toolbar title, document title, intro text, pin storage key |
nodes |
yes | Every box on the map, at every level. [] is allowed (a warning): the page then shows an empty map with ways to start (features.md, "An empty map") |
edges |
no, but expected | Arrows, the "Uses / Used by" lists, pinned-board arrows, automatic layout |
scenarios |
no | The Dynamic tab (hidden when absent or empty) |
schemas |
no | Data models and where each lives (a database, a bucket, a queue, an API, an ontology): the clusters of the Data tab. See "Data: schemas, entities, relations" |
entities |
no | Tables, classes, objects, buckets, messages with their fields: the cards of the Data tab (hidden when absent or empty) |
relations |
no | Links between entities and fields that are not a field's ref: nesting, inheritance, the same thing in two schemas |
deployment |
no | Where the containers run, one diagram per environment: the Deployment tab (hidden when absent). See "Deployment" |
variants |
no | The filter group in the toolbar, the dots on each box, coloured chips (hidden when absent) |
source |
no | "Source" links in the details panel |
view |
no | What is open when the page loads, the arrow style, the default colour theme |
defaultPins |
no | Initial contents of the Pinned board and its "default pins" button |
levelNames |
no | Rename the four levels |
legend |
no | Override legend labels, name hand-picked colours |
icons |
no | Custom icons by key, named by an element's icon (see "Icons") |
rdf |
no | Base IRI, vocabulary and extension prefixes of the RDF export (see rdf-graph.md) |
Everything in the model goes into the page's RDF graph (Turtle, JSON-LD, .rete), in the terms of the plugin's ontology (${CLAUDE_PLUGIN_ROOT}/ontology/c4.ttl and c4-view.ttl, plus c4-data.ttl for the data layer), and a page can be recreated from that graph alone. Fields not listed in this guide are not exported.
project¶
| Field | Required | Notes |
|---|---|---|
name |
yes | Project name. Used in the document title and in text. |
subtitle |
no | Small line above the title, typically org/repo. Defaults to name. |
title |
no | Big toolbar title. Default Architecture map. |
intro |
no | One or two sentences shown first in the panel when nothing is selected. Say what the system is and where a reader should start. |
id |
no | Stable key for remembering pins in localStorage. Defaults to name. |
nodes[]¶
One entry per box. The hierarchy comes from parent; the level comes from type.
| Field | Required | Notes |
|---|---|---|
id |
yes | Unique. Referenced by parent, edges, steps, pins. Keep it short and stable (api, orders-db). |
type |
yes | See the type table. Decides level, box size, shape and default colour. |
name |
yes | Label on the box. Text that does not fit is cut with "…" on the box (the panel always shows it in full) and the validator warns. See "What fits on a box". |
parent |
for everything below level 1 | id of the containing box. Omit for top-level boxes. |
desc |
strongly recommended | One to three sentences for the details panel. Missing desc is a warning. |
sub |
no | Second line on the box, in monospace: a five-word summary (REST · business rules). Hidden when zoomed far out. |
tag |
no | Small caps line above the name. Defaults by type (CONTAINER, COMPONENT, …). Use it for the technology or the code construct: CONTAINER · FASTAPI, CLASS, GET /orders/{id}. |
notes |
no | Array of strings, shown as a bullet list under desc. For constraints, gotchas, config flags. |
tech |
no | String or array of strings, shown as chips under "Technology" and matched by search. |
path |
no | Repository-relative path, shown under "Source". A trailing / means a directory. '' means the repository root. |
line |
no | Line number for path; appended to the path and to the link. |
url |
no | Explicit link (http(s) or relative). Wins over path for the link target. Use for external docs. |
kind |
no | Colour override, see below. |
initial, final |
no | true on a state: the start state gets a dot with a stub, an end state a double border. |
dashed |
no | true gives a dashed border: optional, planned, or conditional elements. |
variants |
no | Array of variant ids this element exists in. Omit for "all". |
at |
no | [column, row] inside its parent, see Layout. |
images |
no | Pictures of it: screenshots of what a user sees, diagrams, photos, or clearly labelled mock-ups. See "Images" below. A box with images gets a small picture badge; its panel shows them. |
icon, iconColor |
no | A small icon in the box's header: a built-in name (user, database), a technology logo (si:postgresql), any Tabler icon (tabler:cloud-upload), a key of icons, or a file. See "Icons" below. |
rdf |
no | Extension terms for the RDF graph: an object of property name → value, in a namespace declared in rdf.prefixes. See "Extension terms" below. |
Types¶
type |
Level | Meaning | Default look |
|---|---|---|---|
person |
1 | A human role or client that uses the system | Solid accent box |
system |
1 | The system being documented (there can be more than one) | Accent-tinted, thick border |
ext |
1 | External system you do not own | Grey |
sibling |
1 | A separate system you do own, outside this one's boundary | White, dashed |
container |
2 | Separately running or deployable unit: service, app, worker, CLI, job | White, accent border |
store |
2 | Database, queue, bucket, cache, index | Grey cylinder |
component |
3 | Module or package inside a container | White, light border |
code |
4 | Function, class, endpoint, constant, file | White, monospace name |
state |
parent + 1 | One state of a lifecycle; see "State machines" | Pill |
What fits on a box¶
Closed boxes have a fixed size per type. The numbers are characters; longer text is cut on the box and reported by the validator.
type |
Box (w × h, px) | name |
tag |
sub |
|---|---|---|---|---|
person, sibling |
250 × 104 | 25 | 31 | 32 |
system |
300 × 124 | 30 | 38 | 40 |
container |
260 × 108 | 26 | 32 | 34 |
store |
240 × 108 | 24 | 30 | 31 |
component |
264 × 96 | 26 | 33 | 34 |
code |
272 × 84 | 30 | 34 | 35 |
ext |
224 × 96 | 22 | 27 | 28 |
state |
200 × 68 | 19 | 24 | 25 |
When the reader puts the arrow labels in the boxes (features.md, "Labels in the boxes"), a box grows by its IN and OUT rows (its width stays), and a row holds label → target in about (w − 46) / 6.3 characters: 35 on a container, 33 on a person, 23 on a state, 4 fewer when the row carries a +N. A label of up to about 20 characters leaves room for the other box's name; longer text is cut with "…", the name first.
A child should have a deeper level than its parent (system → container/store → component → code). Top-level boxes should be person, system, ext or sibling. Both are warnings, not errors. Levels that have no nodes disappear from the toolbar, the stats and the pinned board, so a model with only levels 1 and 2 is valid.
kind (colour)¶
Defaults to the type's look. Override to make a point:
kind |
Effect |
|---|---|
highlight |
Accent-tinted with a thick border. Mark the two or three elements a reader must not miss (entry point, orchestrator). |
plain |
White with a light border. |
person, system, container, store, code, ext, sibling |
Borrow another type's look. |
teal, orange, green, violet, rose, blue, gold, brown |
A tone. Use the tone of a variant for elements specific to that variant, or give the colour its own meaning with legend. |
edges[]¶
Always declare an edge between the most specific elements you know (code to code if you have it). The engine lifts each edge to whatever is currently visible, so a closed container automatically shows the relationships of everything inside it, and parallel edges merge into one arrow labelled first label +N.
| Field | Required | Notes |
|---|---|---|
from, to |
yes | Node ids. Direction is "uses / calls / sends to". |
label |
yes | Verb phrase: reads orders, POST /orders, publishes OrderPlaced. Up to 16 characters stay on one line and fit between two neighbouring boxes. Longer labels wrap to two lines at the space nearest the middle, each line up to 20 characters. Anything beyond that is cut, and the validator warns. |
summary |
no | Label to show instead when the arrow is drawn from or to a closed ancestor of its ends. See "Labels on merged arrows". |
kind |
no | ink (grey, default), accent (entry points, user-facing), or a tone. An edge limited to some variants takes the first variant's tone automatically. |
dashed |
no | true for asynchronous, optional or indirect relationships. Edges limited to some variants are dashed automatically. |
variants |
no | Array of variant ids in which the relationship exists. Omit for "all". |
images |
no | Pictures of the relationship (a message format, a protocol diagram), as on nodes. The panel of either end box shows them. |
reads, writes |
no | What the relationship reads and writes in general, without a scenario: arrays of '<entity id>' or '<entity id>.<field name>'. See "reads and writes". |
icon, iconColor |
no | An icon at the start of the arrow's label (a small badge on the arrow when labels are off), as on nodes: sql, stack-push for a queue, world-www for HTTP. |
rdf |
no | Extension terms for the RDF graph, as on nodes. |
An edge between a box and its own ancestor or descendant is never drawn (warning). The one exception is a state pointing at itself, drawn as a loop.
Labels on merged arrows¶
When a box is closed, all edges of its contents that reach the same other box merge into one arrow. Its label is chosen like this:
- If any of the merged edges has a
summary, the arrow shows that summary. Several different summaries show asfirst summary +N. - Otherwise it shows the label of the first edge in declaration order, plus
+Nfor the other distinct labels.
Without summary, declaration order decides what a reader sees at container level. Put the same summary on the edges that belong to one higher-level relationship (one edge carrying it is enough): five code-level calls from the web app into the API can all say summary: 'JSON over HTTPS'. An edge drawn between exactly the two boxes it names always shows its own label.
State machines¶
A lifecycle is modelled with nodes of type state inside the box that owns it, and ordinary edges between the states as transitions.
// nodes
{ id: 'order', parent: 'orders', type: 'code', name: 'Order', tag: 'CLASS · STATE MACHINE', desc: '…' },
{ id: 'st-pending', parent: 'order', type: 'state', initial: true, name: 'pending', desc: '…' },
{ id: 'st-paid', parent: 'order', type: 'state', name: 'paid', desc: '…' },
{ id: 'st-done', parent: 'order', type: 'state', final: true, name: 'delivered', desc: '…' },
// edges
{ from: 'st-pending', to: 'st-paid', label: 'payment captured' },
{ from: 'st-pending', to: 'st-pending', label: 'basket edited' }, // self-transition, drawn as a loop
{ from: 'place-order', to: 'st-pending', label: 'creates order' } // the code that causes a state
- The owning box can be any type: the component or class that holds the status field, or a box made for the purpose. Put only states in it (a mix is a warning). Its badge reads
+ N states. - Mark one state
initial: true(missing is a warning) and end statesfinal: true. - Transition labels are the event or action that causes the move.
- A state is one level below its owner, never deeper than 4. The last level button opens every box, so lifecycles are visible there.
- In the details panel a state lists "Transitions to" and "Reached from" instead of "Uses" and "Used by".
- Layout is automatic: the initial state comes first and the rest follows the transitions.
- Edges from code to a state ("creates", "sets") are allowed; scenario steps can point at states too.
scenarios[]¶
Each scenario is an ordered list of interactions between nodes of the static model. The Dynamic tab draws it as a collaboration diagram, a sequence diagram or a step table, at any level: steps are lifted to the chosen level, steps that stay inside one box are folded away, and consecutive steps between the same two boxes merge.
| Field | Required | Notes |
|---|---|---|
id |
yes | Unique. |
name |
yes | Shown in the scenario picker and as the panel title. |
desc |
no | One or two sentences of context. |
actor |
no | Use case: the node id of the person whose goal the scenario serves (usually the one who starts it). Any other type is an error. |
goal |
no | Use case: what that person wants, in one sentence. |
trigger |
no | Use case: the event that starts it (a click, a request, a schedule). |
preconditions |
no | Use case: what must hold before it starts. A string, or an array of strings. |
outcome |
no | Use case: what holds when it has succeeded (its success guarantee). |
steps |
yes | Non-empty array, in execution order. |
color |
no | Its flow colour: a tone (teal, orange, green, violet, rose, blue, gold, brown). Without it, each scenario gets a tone of its own by order. See "Flow colours". |
images |
no | Pictures of the whole flow, as on nodes. The Dynamic panel shows them under the use case. |
icon, iconColor |
no | An icon for the scenario in the picker and the Dynamic panel, as on nodes. |
rdf |
no | Extension terms for the RDF graph, as on nodes. |
Each step:
| Field | Required | Notes |
|---|---|---|
from, to |
yes | Node ids, as specific as possible. Must differ. Write each step in the direction the message travels: caller → callee, and callee → caller with reply: true for an answer. |
label |
yes | What happens: validate basket, 201 · order id. |
reply |
no | true for a return/response message; drawn dashed, and ignored when ordering participants. |
variants |
no | Array of variant ids in which this step happens. Selecting a variant in the toolbar removes the other steps. |
images |
no | What the user sees at this step: a screenshot of that screen, or a wireframe marked illustrative. The Dynamic panel shows them while the step is current (and so does the panel of the sequence inside a box). |
reads, writes |
no | The entities and fields this step reads and writes: arrays of '<entity id>' or '<entity id>.<field name>'. Shown with the step and gathered per entity in the Data tab. See "reads and writes". |
Steps do not need a matching entry in edges, but a call that appears in a scenario normally deserves one.
Use cases¶
The five use-case fields are optional and shown as a short list under the scenario's description (Dynamic tab and the sequence inside a box). Fill them only from evidence in the code or the project's docs, and say where it comes from when it is not obvious: the role check on a route (require_role("admin")) gives the actor and a precondition; the route or button that starts the flow gives the trigger; error answers give preconditions (404 "no pending tasks"); the last writes give the outcome. Leave a field out rather than guess.
{ id: 'export', name: 'Export approved tasks (COCO)', desc: '…',
actor: 'admin',
goal: 'Download every approved annotation as one COCO-style JSON file.',
trigger: 'The admin clicks "Export approved annotations" on the admin page.',
preconditions: 'Signed in with the admin role: POST /api/exports and GET /api/exports/{id} require it.',
outcome: 'The worker writes exports/export-<id>.coco.json to MinIO and marks the export done; the page shows a download URL.',
steps: [ … ] }
Flow colours¶
Every scenario has a colour of its own, its flow colour: the Dynamic view draws its arrows, step numbers and current step in it, the map's flows overlay paints its steps in it (features.md, "Flows on the map"), and the scenario picker, the panel and the history's change lists show it as a swatch. Set it with color (a tone) or leave it out: scenarios without one take, in order, the next of blue, gold, violet, teal, brown, rose, orange, green that no scenario names, so the same model always gets the same colours and four or five flows never repeat. The compare-mode colours (green, rose, orange) come last, so they rarely meet a flow. A step that exists only in some variants keeps its variant's tone.
The same scenarios also draw the sequence inside a box on the map (the ⇅ sequence button of an open box; see features.md). Nothing extra goes in the model. A box offers it as soon as some step crosses its border or runs between two of its children.
Data: schemas, entities, relations¶
Optional. The data the system keeps and passes around (tables, payloads and files, ontology classes, JSON-LD terms, object keys, queue messages), drawn in the Data tab DB-diagram style: a cluster per schema, a card per entity with a row per field, lines between rows. A schema lives in a node of the map, an entity names the code that defines it, a column can point at its lifecycle (states), and steps and edges say what they reads and writes. The tab appears only when entities is non-empty. The graph writes all of it in the terms of ontology/c4-data.ttl (c4d:, rdf-graph.md).
From the example project (examples/image-annotation-tool), shortened:
schemas: [
{ id: 'pg', name: 'PostgreSQL schema', kind: 'relational', format: 'sql', in: 'postgres', path: 'db/migrations/001_init.sql', desc: '…' }
],
entities: [
{ id: 'tasks', schema: 'pg', name: 'tasks', code: 'models', path: 'db/migrations/001_init.sql', line: 23, desc: '…',
fields: [
{ name: 'id', type: 'SERIAL', pk: true, line: 24 },
{ name: 'image_id', type: 'INTEGER', required: true, unique: true, ref: 'images.id', onDelete: 'cascade', line: 25 },
{ name: 'status', type: 'TEXT', required: true, default: "'pending'", values: ['pending', 'in_progress', 'submitted', 'approved', 'rejected'], states: 'lifecycle' }
],
indexes: [{ name: 'tasks_status_idx', fields: ['status', 'created_at'] }] },
{ id: 'images', schema: 'pg', name: 'images', code: 'models', desc: '…', fields: [
{ name: 'id', type: 'SERIAL', pk: true },
{ name: 'storage_key', type: 'TEXT', required: true, ref: 'bucket-images.key', refLabel: 'object key', soft: true } ] } // a key in MinIO
],
relations: [{ from: 'tasks', to: 'iat-task', kind: 'maps' }], // the table and the ontology class it stores
// on a scenario step
{ from: 'thumb', to: 'postgres', label: 'UPDATE images: thumbnail_key, w, h', writes: ['images.thumbnail_key', 'images.width', 'images.height'] }
A reference is '<entity id>' or '<entity id>.<field name>', split at the first .: entity ids have none, field names may (bbox.0), never first. Entity ids are a namespace of their own (the table images and the component images coexist); prefix them when two schemas share a name (bucket-images, coco-image). A reference that names nothing is an error.
schemas[]¶
| Field | Required | Notes |
|---|---|---|
id, name |
yes | id unique, without .. name: PostgreSQL schema, COCO export file. |
kind |
yes | relational · document · json-schema · ontology · object-store · queue · api · other. Sets the colour, the wording and the default entity kind. |
in |
strongly recommended | Node id of where it lives: a store; a container or component for payloads and in-process formats; the system for documentation nothing loads. Missing is a warning. |
desc |
recommended | One to three sentences. |
format |
no | sql, json-schema, openapi, owl, rdfs, shacl, jsonld-context, prisma, graphql, protobuf, avro, orm, other (a free string). |
namespace |
no | Ontologies and JSON-LD contexts: the namespace IRI. |
path, line, url, tech, color, notes, images, icon, iconColor, rdf |
no | As on nodes; color is a tone. The icon marks the schema's cluster in the Data view (without one, the cluster shows the icon of its in box). |
entities[]¶
| Field | Required | Notes |
|---|---|---|
id, schema, name |
yes | id unique, without .; schema a schema id; name as written in the source (tasks, iat:Annotation, CocoImage), about 39 characters show. |
kind |
no | table · view · class · object · enum · collection · document · bucket · message · type. Default from the schema: relational → table, ontology → class, json-schema / api / document → object, object-store → bucket, queue → message, other → type. |
fields |
expected | In source order (below). An enum has values instead. |
indexes |
no | [{ name, fields: ['status', 'created_at'], unique }]. |
code |
no | Node id(s) of the code that defines or maps it (ORM model, serialiser, producer and consumer): "Defined in". |
iri |
no | The class IRI, or a JSON Schema $id (…#/$defs/CocoImage). |
desc, path, line, url, at, dashed, notes, images, icon, iconColor, rdf |
no | As on nodes; path / line is the definition (the CREATE TABLE, the line building an object key); at is inside the schema's cluster; icon goes on the entity's card. |
fields[]¶
| Field | Notes |
|---|---|
name |
Required, unique in its entity. |
type |
As written: TIMESTAMPTZ, integer \| null, CocoImage[], xsd:dateTime, a key layout <image_id>.jpg. Name and type share about 37 characters on a row. |
pk, required, unique, many |
Part of the identifier (primary key, @id, object key; implies required) · NOT NULL, JSON required (present: nullable goes in type), sh:minCount 1 · UNIQUE · holds a list. |
default, values |
As written (now(), "'pending'") · allowed values (CHECK … IN, enum, sh:in, Literal[…]). |
ref |
Holds the identifier of that entity (its pk field, or its header if it has none) or the value of that field. The line starts at this row. |
refLabel, soft, onDelete |
Line label, 22 characters show · true when nothing enforces the reference (drawn dashed; the default across two schemas) · cascade, set null, restrict, no action, set default. |
states |
Node id of the box owning the state nodes its values are (tasks.status → lifecycle). |
iri, desc, line |
Property IRI (ontology, JSON-LD) · line in the entity's path. |
Cardinality of a ref line: 0..1 on the field's side when unique, else 0..*; 1 on the target's side when the field is required or pk, else 0..1.
relations[]¶
{ from, to, kind, label, card, soft, desc, rdf }, with references as from and to. kind: ref (the default: a composite key, a many-to-many) · contains (nesting, the file inside a bucket) · extends (child → parent: subclass, allOf) · maps (the same thing in another schema; dotted, no direction) · assoc (a named association with no row of its own). card: [from side, to side], each 1, 0..1, 0..*, 1..* or *. label: 22 characters show.
reads and writes¶
On scenario steps and on edges: arrays of references; writes covers insert, update and delete. Name the whole entity for an INSERT, a DELETE, a full row load or an object PUT / GET, and fields for what a statement names (the SELECT list and WHERE, the SET). Put them on the step that touches the data: the ORM or SQL call, the S3 call, the enqueue and the dequeue, the serialiser that builds a payload (it writes the payload), the signing of a URL (reads the key, writes the URL field), a request carrying a modelled body (writes it), a reply carrying one (reads it). When a scenario folds the database work into a handler step, put it on that step; lazy loads a serialiser triggers are reads. On edges, for relationships no scenario shows (login → models reads users.email, users.password_hash, users.role).
Modelling each kind of source¶
- SQL migrations, ORM models, Prisma.
kind: 'relational',format: 'sql'(prisma,ormwhen that is the only definition),inthe database. Atableper table (viewfor views), columns in order withtype,pk(each part of a composite key),required,unique,default,valuesfromCHECK;refwithonDeleteperREFERENCES(a composite foreign key: arefrelation withcard);indexesfromCREATE INDEX, not the implicit ones;codethe ORM model. The migration is what holds: say indescwhat only the ORM does (onupdate). A status column getsstates; a shared enum type is an entitykind: 'enum'. Prisma:@relation(fields, references, onDelete)goes on the scalar field. dbt: the tests giverequired,unique,values,ref. - JSON Schema, OpenAPI, Pydantic, Zod, TypeScript, dict serialisers. A file format:
kind: 'json-schema',inwhere the files live; payloads:kind: 'api'(format: 'openapi'with a spec),inwhat serves them,codethe serialiser and the client types. An entity per object schema or model,iriits$id; properties withrequired, nullable written intype, arrays asmanywith an item type,enum/const/Literalasvalues. Nesting: acontainsrelation from the field to the nested entity;allOfor a base model:extends; an id from another store, or into the same document: softref. Draw only payloads that add something (nesting, ids crossing stores, URLs). - OWL, RDFS, SHACL.
kind: 'ontology',format: 'owl','rdfs'or'shacl',namespace,inwhere the graph is loaded (the system when nothing loads it). Aclassper class,nameprefixed (iat:Annotation) withiri; fields are the properties with thatrdfs:domain(or the shape'ssh:path), named prefixed,typethe range. An object property:refto the range class (ending at its header), orassocwhen it has no domain;rdfs:subClassOf:extends;owl:oneOfor a SKOS scheme:kind: 'enum'. SHACL:sh:minCount 1→required,sh:maxCountabove 1 →many,sh:in→values,sh:class→ref. - JSON-LD context.
kind: 'other',format: 'jsonld-context',namespace,inthe container whose JSON it annotates. One entity per context (kind: 'document', the file name) with a field per term:namethe key,typewhat it expands to (iat:status · @vocab,@reverse iat:task),iri; prefixes are not fields.mapsfrom the payload entity to the context (label: '@context') and from each term to its property; keys it drops go innotes. - Object store (S3, MinIO, GCS, a directory layout).
kind: 'object-store',inthe store, abucketper bucket withpath/linewhere the key is built. Fields:key(pk,typethe layout as built:<batch_name>/<uuid hex>-<filename>), the key segments that carry an id (softref,refLabel: 'in the key'),Content-Typewithvalues,body(containsthe entity of its file format). The column holding a key: softrefto<bucket>.key,refLabel: 'object key'; a presigned URL in a payload: softrefto the bucket. - Queues and topics (RQ, Celery, BullMQ, Kafka; protobuf, Avro).
kind: 'queue'(format: 'protobuf'or'avro'with a schema file),inthe broker. Amessageper job or event type, named as written (generate_thumbnail(image_id)),codethe producer and the consumer; fields: the queue or topic (withvalues), the function or event name, the arguments (an id: softref). An Avro union with null is notrequired; protobufrepeatedismany. - Document stores, GraphQL. Like JSON Schema:
collectionentities, embedded documents ascontains, ids as softref; GraphQL!→required,[T]→many,implements→extends.
ref, relations, soft or maps?¶
refwhen one field holds the identifier or the value of another: a foreign key, an object key, an id copied into a file, a job or a URL, an IRI-valued property.relationswhen no single field does: a composite key, nesting, inheritance, the same thing in two schemas, an association without a row.soft: truewhen nothing enforces it (across stores, inside JSON; the default across schemas, but write it). Hard only for what the store checks (REFERENCES).mapsfor the same thing described twice: a table and its class, a column and its property, a JSON-LD term and its property, an API object and its row. Not "holds the id of":coco-image.idrefsimages.id,tasks.statusmapsiat:status. Map the identifiers, keys and the fields a reader looks for, not every timestamp.
Importing. scripts/import-schema.mjs takes one or more schema files and prints a MODEL fragment (schemas, entities, relations); node scripts/import-schema.mjs --help lists its formats and options. Then add by hand what no file says: in, code, states, soft refs across stores, maps, and the steps' reads and writes (SKILL.md, "Data layer").
variants¶
An optional filter dimension for things that exist only in some configurations: runtime modes, editions, deployment targets, feature flags, tenants.
variants: { label: 'Deployment', items: [
{ id: 'cloud', name: 'cloud', tone: 'teal' },
{ id: 'onprem', name: 'on-prem', short: 'prem', tone: 'orange' }
] }
| Field | Required | Notes |
|---|---|---|
label |
no | Name of the dimension, shown in the toolbar and panel. Default Variant. |
items[].id |
yes | Referenced by variants: [...] on nodes, edges and steps. |
items[].name |
no | Display name. Defaults to id. |
items[].short |
no | Shorter name for the sequence diagram margin. |
items[].tone |
no | teal, orange, green, violet, rose, blue, gold, brown. Defaults in that order. |
Two to five items work. Omit variants entirely when the architecture has no such dimension: the filter, the dots and the chips all disappear.
source¶
| Field | Notes |
|---|---|
repoUrl |
Repository web URL. Without it, paths are shown but not linked. |
branch |
Default main. |
host |
github, gitlab or bitbucket. Auto-detected from repoUrl; set it for self-hosted instances. |
fileTemplate, dirTemplate, lineTemplate |
Override the URL shape for other hosts. Placeholders: {repo}, {branch}, {path}, {line}. Example: fileTemplate: '{repo}/src/branch/{branch}/{path}', lineTemplate: '#L{line}'. |
linkLabel |
Link text. Default Open on GitHub / GitLab / Bitbucket, else Open source. |
view¶
| Field | Notes |
|---|---|
startLevel |
1–4. The map opens with everything above this level expanded. Default 2 (containers visible). |
open |
Array of node ids to open instead (their ancestors open too). Use it to start on the one interesting container rather than on all of them. |
edges |
Arrow style on the map: 'orthogonal' (default; right-angled arrows in the gutters, one lane each) or 'straight' (centre to centre, bending round boxes). The reader can switch with the edges button or E. See features.md, "Arrow styles". |
theme |
Default colour theme: 'auto' (default; light, or dark when the reader's OS is dark), 'light', 'dark', 'contrast', 'paper', 'blueprint' or 'graphite'. Any other value is an error. It is only a default: a reader's own pick (remembered per browser) and #theme= in the URL win over it. See features.md, "Colour themes". |
icons |
How icons are coloured by default: 'mono' (default; each in the colour of its box's or arrow's text, or its iconColor) or 'brand' (logos in their brand colours). The reader can switch. See "Icons". |
showIcons |
false opens the page with icons hidden (default true). |
defaultPins, levelNames, legend¶
defaultPins: array of node ids. Pick 5 to 10 across levels that together tell the core story; the Pinned board draws only those and the relationships between them.levelNames: array of exactly four strings replacingSystem context,Containers,Components,Code.legend: object mapping a kind (person,system/highlight,container,store,code/plain,ext,sibling,state, a tone, ordashed) to its legend label. Required in practice for any tone you use that is not a variant's tone.rdf:{ base, vocab, prefixes }, all optional.baseis the prefix of every element IRI in the RDF export. Default:source.repoUrl+#when set, elseurn:architecture:<project-slug>:.vocabreplaces thec4:namespace of the published ontology; leave it out (with another vocabulary the graph no longer uses the ontology and the SHACL shapes do not apply).prefixesmaps prefix names to the namespaces of extension terms. See rdf-graph.md.
Deployment¶
Optional. Where the containers run, as C4 deployment diagrams (https://c4model.com/diagrams/deployment): one diagram per environment (production, staging, a developer's machine), each a tree of deployment nodes (physical, virtual or containerised infrastructure, or an execution environment: a server, a VM, a Docker host, a Kubernetes cluster or namespace, a database server) that hold instances of the model's containers and software systems, and infrastructure nodes (a load balancer, DNS, a firewall). With a deployment the explorer has a Deployment tab (features.md, "Deployment view").
Write it only from deployment files of the repository: docker-compose files, Kubernetes manifests or Helm charts, Terraform or other infrastructure code, Dockerfiles, Procfiles, CI deploy jobs, platform configs (fly.toml, render.yaml, app.yaml, vercel.json). One environment per real target those files describe. Never invent an environment, a node, a replica count or a load balancer.
deployment: {
environments: [
{ id: 'prod', name: 'Production', desc: 'AWS eu-west-1, from infra/main.tf and k8s/.',
nodes: [
{ id: 'aws', name: 'Amazon Web Services', tech: 'eu-west-1', path: 'infra/main.tf', line: 1,
nodes: [
{ id: 'eks', name: 'Kubernetes cluster', tech: 'AWS EKS 1.30', path: 'infra/eks.tf', line: 4,
nodes: [
{ id: 'web-pods', name: 'web', tech: 'Deployment · 2 replicas', instances: 2, path: 'k8s/web.yaml', line: 1,
containers: [{ of: 'web', tech: 'nginx 1.27 image' }] },
{ id: 'api-pods', name: 'api', tech: 'Deployment · HPA 3–10', instances: 3, path: 'k8s/api.yaml', line: 1,
containers: [{ of: 'api', tech: 'python:3.12-slim · uvicorn' }] } ] },
{ id: 'rds', name: 'Amazon RDS', tech: 'db.t3.medium', path: 'infra/rds.tf', line: 1, containers: [{ of: 'postgres', tech: 'PostgreSQL 16' }] } ],
infra: [{ id: 'alb', name: 'Load balancer', tech: 'AWS ALB', path: 'infra/alb.tf', line: 1 }] } ],
relationships: [{ from: 'alb', to: 'web-pods', label: 'forwards HTTPS', tech: 'HTTPS' }] }
]
}
| Field | Where | Notes |
|---|---|---|
environments[] |
deployment |
Required, at least one. id (unique), name (required), desc, nodes (required, at least one), relationships |
nodes[] |
an environment, or a node (nested) | A deployment node: id, name (required), tech (one string: "Docker Engine", "Kubernetes · AWS EKS", "Ubuntu 22.04"), desc, instances (×N: how many such nodes), icon, path, line, url, and inside it nodes, containers, systems, infra. Nested at most 8 deep |
containers[] |
a node | Instances of containers and data stores: of (required: a container or store id of the model), instances (×N copies running here), tech (how it runs here: the image, the runtime, the port; else the box's own tech), id, path, line, url |
systems[] |
a node | Instances of software systems (system, ext, sibling), same fields; typically an external system you host yourself, or a neighbouring one |
infra[] |
a node | Infrastructure nodes: id, name (required), tech, desc, icon, path, line, url |
relationships[] |
an environment | Only what the model does not already say: from, to (ids of this environment: nodes, infrastructure nodes, instances), label, tech, dashed |
- Ids. Deployment nodes, infrastructure nodes and instances share one set of ids per environment. An instance's id is its
id, else the id of the box it runs (of): giveidonly when the same box runs in two places of one environment (two regions), and then to each of them. - Relationships come from the model. Between the instances, the explorer draws the model's own edges, lifted to the boxes the instances run (an edge from a component of
apitopostgresbecomes an arrow from theapiinstance to thepostgresinstance), sorelationshipsholds only what the deployment adds: a load balancer forwarding to an instance, replication, a CDN in front. - Rules the validator checks: environment ids unique;
nameon environments, nodes and infrastructure nodes;ofis a box of the right type (containers: container or store;systems: system, ext or sibling); a box at most once per node (useinstances); ids unique per environment;instancesa whole number of at least 1; relationship ends resolve; unknown fields are warned about.check-model.mjs --rootcheckspathandlinelike a box's, and prints aDEPLOYline per environment (with the boxes no environment runs). - Edits keep it in step. Deleting a box (edit mode, the agent tools, the Mermaid text applied back) drops its instances and the relationships that named them; changing a box's id moves its instances.
- RDF.
c4:DeploymentEnvironment,c4:DeploymentNode(nested byc4:deployedIn),c4:ContainerInstanceandc4:SoftwareSystemInstance(c4:instanceOfthe element,c4:instancesfor ×N),c4:InfrastructureNode, andc4:DeploymentRelationship(c4:deploymentSource,c4:deploymentTarget); rdf-graph.md has the mapping. The round trip is lossless. - Mermaid.
model-to-mermaid.mjs --deployment [env]writes an environment as MermaidC4Deployment; the page's Mermaid panel shows it in the Deployment view.
Images¶
An optional images list on a node, an edge, a scenario or a step: pictures that show what an element is, what a user sees at a step, or how a flow looks.
{ id: 'annotate-page', type: 'component', name: 'AnnotatePage', /* … */
images: [{ src: 'img/annotate-page.png', alt: 'The Annotate page: the image with two labelled boxes and a Submit for review button.',
caption: 'The Annotate page after drawing two boxes.', credit: 'Screenshot of v1.2, 2026-05-02', kind: 'screenshot' }] }
// on a step: what the user sees there
{ from: 'annotator', to: 'annotate-page', label: 'Submit for review',
images: [{ src: 'img/annotate-wireframe.svg', alt: '…', kind: 'illustration', illustrative: true,
caption: 'Illustrative wireframe drawn from AnnotatePage.tsx, not a screenshot.' }] }
| Field | Required | Notes |
|---|---|---|
src |
yes | A path next to model.js, in its folder or below it (img/annotate-page.png: forward slashes, no .., no spaces); an https:// URL; or a data:image/png, jpeg, gif, webp, svg+xml or avif URI. A file must be .png, .jpg, .jpeg, .gif, .webp, .svg or .avif. javascript:, file: and other schemes are errors; http:// is a warning (blocked on https pages). |
alt |
yes | What the image shows, for readers who cannot see it (the text alternative). Say what matters for this architecture ("the review queue with three tasks and a disabled Reject button"), not "screenshot". About 250 characters at most (a warning above 300); put the rest in the caption. |
caption |
no | Shown under the image to everyone. |
credit |
no | Who made it, or where it comes from. |
kind |
no | screenshot (a capture of the running software), diagram, photo or illustration. |
illustrative |
no | true for a mock-up or wireframe that is not a capture of the real thing. The page labels it "illustrative"; say so in the caption too. kind: 'screenshot' with illustrative: true is a warning: a mock-up is not a screenshot. |
The list keeps its order; the badge opens the first. A data URI over 512 KB of text is a warning, and so are embedded images adding up to more than 4 MB in the whole model: they make the page, its RDF graph and every version in a history heavy. Keep large screenshots as files (about 1600 px wide is plenty).
Where they show. A box with images gets a picture badge with the count (bottom left of a closed box, in the header of an open one). Its details panel has a gallery with the captions, credits, kind and the "illustrative" label; a click on a picture or on the badge opens a lightbox (← → move, Esc closes and gives the focus back). An edge's images are in the panel of both its end boxes, a scenario's in the Dynamic panel under the use case, a step's in the Dynamic panel while that step is current.
Files. build-explorer.mjs checks that every relative path exists next to model.js (an error otherwise) and copies the files next to the page at the same path, so img/ sits beside index.html; --embed-images puts them into the page as data URIs instead, for a page that has to travel as one file. check-model.mjs checks that they are next to the page. The plugin's MCP view draws data URIs only (it loads nothing from outside); see features.md, "Images".
Where images come from (SKILL.md, "Images"): reuse what the repository has (README and docs screenshots, design files); capture screenshots with headless Chrome only when the app runs locally and the user agrees; otherwise draw clearly labelled illustrative wireframes, never passed off as screenshots. Never capture secrets or personal data.
Icons¶
An optional icon on a node, an edge, a scenario, a schema or an entity: a small picture in the box's header (before the tag), at the start of an arrow's label, on a schema's cluster and an entity's card in the Data view, in the scenario picker, and wherever the page names the element (panel, Pinned board, Dynamic view, search hits, exports).
{ id: 'postgres', type: 'store', name: 'PostgreSQL', icon: 'si:postgresql', /* … */ } // the logo of its technology
{ id: 'admin', type: 'person', name: 'Admin', icon: 'user', /* … */ } // a built-in icon
{ from: 'models', to: 'postgres', label: 'SQL (SQLAlchemy)', icon: 'sql' } // on an arrow
{ id: 'gpu', type: 'ext', name: 'GPU farm', icon: 'gpu', iconColor: 'violet', /* … */ } // a key of MODEL.icons, in a tone
icons: { gpu: { svg: '<svg viewBox="0 0 24 24">…</svg>', title: 'GPU', source: 'Drawn for this project', license: 'CC0-1.0' } }
icon |
What it draws | Where it comes from |
|---|---|---|
'database' |
a built-in icon: about 90 infrastructure glyphs of Tabler Icons (user, users, server, database, stack for a cache, stack-push for a queue, bucket, cloud, api, browser, fingerprint, lock, mail, clock, terminal, sql, json …) |
the page itself: it works offline, in the MCP view and in the editor, whose icon picker and the search_icons tool list them |
'tabler:<name>' |
any of about 5,000 Tabler Icons (tabler:cloud-upload; tabler:<name>-filled for the filled style). tabler:database is the built-in database. |
resolved by build-explorer.mjs (below) |
'si:<slug>' |
a brand logo of Simple Icons, about 3,500 (si:postgresql, si:redis, si:minio, si:fastapi, si:react, si:nginx, si:python, si:docker, si:kubernetes); the slug is the one on simpleicons.org |
resolved by build-explorer.mjs |
'<key>' |
the entry of MODEL.icons with that key, looked up first whatever the reference looks like |
the model |
'img/icons/gpu.svg', 'https://…', 'data:image/svg+xml,…' |
a file next to model.js (.svg, .png, .jpg, .gif, .webp, .avif), a URL, a data URI |
as images: the build checks the file and copies it next to the page, or embeds it with --embed-images; the MCP view draws data URIs only |
A bare name that is not built in is read as the Tabler icon of that name; check-model.mjs warns about it (write tabler:<name> when that is meant). A reference that names nothing (a malformed si: slug, an unknown prefix, a key MODEL.icons lacks) is an error.
iconColor: 'brand' (a logo in its own colours) or a tone (teal, orange, …). Without it the icon takes the colour of its box's or arrow's text, unless the page shows icons in brand colours (view.icons: 'brand', or the reader's toggle). An iconColor without an icon is a warning.
MODEL.icons maps a key (a letter or a digit, then letters, digits, -, _, . or :, at most 80 characters) to { svg, title, source, license }: custom icons, and library icons the editor picked, kept with the model so that a downloaded model or page draws them offline. svg is the markup, starting with <svg, at most 64 KB (a warning above 16 KB: icons are drawn at 11 to 22 px). The page draws only shapes from it (svg, g, path, circle, ellipse, rect, line, polyline, polygon, with their geometry, fill and stroke) and leaves out the rest; the validator lists what. A script, an event attribute (on…) or a link (href) in it is an error of check-model.mjs: the page would never draw it, but the model and its RDF graph would carry it as written. Give source and license for anything you did not draw yourself.
Library icons in the page. build-explorer.mjs resolves every tabler: and si: reference (and every bare name that is not built in) that MODEL.icons does not have and writes them into the page's <script id="icon-data"> block, never into the model (the reference is enough to resolve them again, so the RDF graph holds the reference only):
- from a local npm package (
simple-icons,@tabler/icons) in anode_modulesfolder above the working directory, the output folder, the model's folder or the script; - otherwise from jsDelivr, at pinned versions (Simple Icons 16.37.0, Tabler Icons 3.51.0, the versions the editor's picker loads too), cached on disk per version:
%LOCALAPPDATA%\c4-model-agentic-plugin\Cache\iconson Windows,~/Library/Caches/c4-model-agentic-plugin/iconson macOS,$XDG_CACHE_HOME/c4-model-agentic-plugin/icons(~/.cache/…) elsewhere;--icon-cache <dir>orC4_ICON_CACHEchoose another folder; - otherwise the page draws a placeholder glyph with the reference in its tooltip, and
check-model.mjswarns.
--no-fetch keeps the build off the network: a local package and the cache only. The build's ICONS lines say where each icon came from and why one could not be resolved.
Licences. Built-in and tabler: icons: MIT (Tabler Icons by Paweł Kuna; the page carries the notice). si: logos: the SVG data is CC0-1.0, and each logo stays a trademark of its owner, shown only to identify the technology (it says nothing about endorsement); a few logos name a licence of their own, which the build adds to the icon's licence note. Vendor cloud icon sets (the AWS, Azure and Google Cloud architecture icons) are not open source: they are neither bundled nor fetched. A model may point icon at such a file of its own when its terms allow it.
Suggestions. scripts/suggest-icons.mjs model.js proposes an icon per box and per schema: the Simple Icons logo of its technology (the tag after ·, the name, then tech), else a built-in icon from its words (queue, bucket, cache, auth, …) or its type (person → user, store → database). It prints a table and a snippet; --apply-to <copy.js> writes a copy of the model with the icons added (SKILL.md, "Icons").
Extension terms¶
Facts the explorer has no field for (deployment, ownership, data classification, compliance) go into the RDF graph through an rdf object on a node, an edge or a scenario. Declare each namespace once in rdf.prefixes, in a namespace of your own, never c4::
rdf: { prefixes: { dep: 'https://example.org/ontology/deployment#' } },
// on a node
{ id: 'postgres', type: 'store', name: 'PostgreSQL', /* … */
rdf: { 'dep:hostPort': 5432, 'dep:classification': { '@id': 'dep:Confidential' } } }
| Value | Meaning |
|---|---|
'text', 42, 1.5, true |
a literal |
{ '@id': 'prefix:name' }, { '@id': 'https://…' } |
an IRI |
{ '@id': ':api' } |
the node api of this model |
{ '@value': '2026-01-31', '@type': 'xsd:date' }, { '@value': 'Bonjour', '@language': 'fr' } |
a typed or language-tagged literal |
[ … ] |
several values (a set: the order is not kept) |
'rdf:type': { '@id': 'prefix:Class' } |
an extra class of your own, a subclass of a c4: class |
Keys are prefix:name with a declared prefix (or the built-in rdf, rdfs, xsd, dcterms, schema, sh) or a full IRI. The validator rejects unknown prefixes, malformed values, and properties the export already writes from the model's own fields (rdfs:label, dcterms:*, schema:position, schema:image, schema:contentUrl, schema:caption, schema:creditText, any c4: or c4v: term). The page does not draw these terms; they are for the graph. Ship an ontology file and SHACL shapes with them: ${CLAUDE_PLUGIN_ROOT}/ontology/EXTENDING.md.
Layout: at¶
at: [column, row] places a node on a grid inside its parent. Columns and rows are sorted ordinals, not pixels: gaps are ignored, and each column is as wide as its widest box. Two siblings may not share a cell.
Within one group of siblings, either give at to every node or to none. A group with none (or only some) is laid out automatically:
- Top level: three bands, people on top, systems and siblings in the middle, externals at the bottom. The system row is centred; people and externals are then slid sideways to sit above or below the boxes they talk to (including boxes inside an open system), so their arrows run close to vertical. This is recomputed whenever a box opens or closes.
- Inside a box: boxes are ranked by who uses whom, then several grids are tried and the one with the fewest arrows behind boxes and the fewest crossings wins. Boxes reached from outside the group are pulled to the top row, boxes that only reach out to the bottom.
Start without at, then read the LAYOUT section printed by check-model.mjs: it lists, per group, arrows that bend around a box and arrows that cross. Add at to a group only when that list shows something a different grid would fix. Moving a box in the page's edit mode writes at for its whole group, renumbered from 0.
With explicit at at the top level, each row is centred on its own and columns only give the left-to-right order within a row. The automatic alignment applies only when no top-level node has at.
Complete example¶
window.MODEL = {
project: { name: 'Shoply', subtitle: 'acme/shoply', intro: 'Online shop backend. Start at the API service.' },
source: { repoUrl: 'https://github.com/acme/shoply', branch: 'main' },
variants: { label: 'Edition', items: [{ id: 'cloud', name: 'cloud' }, { id: 'onprem', name: 'on-prem' }] },
view: { startLevel: 2 },
nodes: [
{ id: 'shopper', type: 'person', name: 'Shopper', icon: 'user', sub: 'places orders', desc: 'Buys things through the web shop.' },
{ id: 'shoply', type: 'system', name: 'Shoply', sub: 'orders from basket to warehouse', path: '',
desc: 'Takes orders, charges customers and notifies the warehouse.' },
{ id: 'psp', type: 'ext', name: 'Payment provider', sub: 'card payments', url: 'https://example.com/psp-docs',
desc: 'Authorises and captures payments.' },
{ id: 'bi', type: 'sibling', name: 'BI warehouse', sub: 'reporting', variants: ['cloud'],
desc: 'Separate product that receives order events.' },
{ id: 'api', parent: 'shoply', type: 'container', kind: 'highlight', name: 'API service', icon: 'si:fastapi', tag: 'CONTAINER · FASTAPI',
sub: 'REST · business rules', tech: ['Python', 'FastAPI'], path: 'api/',
desc: 'Only entry point. Owns all writes.', notes: ['Auth: bearer token on every route except /health.'] },
{ id: 'db', parent: 'shoply', type: 'store', name: 'Orders DB', icon: 'si:postgresql', tag: 'DATA STORE · POSTGRES', sub: 'orders · customers',
desc: 'System of record.' },
{ id: 'orders', parent: 'api', type: 'component', name: 'Order service', sub: 'place · cancel', path: 'api/orders/',
desc: 'Order lifecycle rules.' },
{ id: 'repo', parent: 'api', type: 'component', name: 'Repository', sub: 'SQL access', path: 'api/repo.py',
desc: 'All SQL lives here.' },
{ id: 'place', parent: 'orders', type: 'code', name: 'place_order()', tag: 'FUNCTION', sub: 'validate → charge → save',
path: 'api/orders/service.py', line: 40, desc: 'Validates the basket, charges, stores the order.' }
],
edges: [
{ from: 'shopper', to: 'place', label: 'POST /orders', kind: 'accent' },
{ from: 'place', to: 'psp', label: 'charge card' },
{ from: 'place', to: 'repo', label: 'save order' },
{ from: 'repo', to: 'db', label: 'SQL', icon: 'sql' },
{ from: 'api', to: 'bi', label: 'order events', variants: ['cloud'], dashed: true }
],
scenarios: [
{ id: 'checkout', name: 'Checkout', desc: 'A shopper pays for a basket.', steps: [
{ from: 'shopper', to: 'place', label: 'POST /orders' },
{ from: 'place', to: 'psp', label: 'charge card' },
{ from: 'psp', to: 'place', label: 'payment id', reply: true },
{ from: 'place', to: 'repo', label: 'save order' },
{ from: 'repo', to: 'db', label: 'INSERT', reads: ['customers.id'], writes: ['orders'] },
{ from: 'api', to: 'bi', label: 'publish OrderPlaced', variants: ['cloud'] }
] }
],
schemas: [
{ id: 'orders-sql', name: 'Orders schema', kind: 'relational', format: 'sql', in: 'db', path: 'db/schema.sql',
desc: 'Tables of the orders database.' }
],
entities: [
{ id: 'customers', schema: 'orders-sql', name: 'customers', code: 'repo', desc: 'People who have ordered.',
fields: [{ name: 'id', type: 'BIGINT', pk: true }, { name: 'email', type: 'TEXT', required: true, unique: true }] },
{ id: 'orders', schema: 'orders-sql', name: 'orders', code: 'repo', desc: 'One row per placed order.',
fields: [
{ name: 'id', type: 'BIGINT', pk: true },
{ name: 'customer_id', type: 'BIGINT', required: true, ref: 'customers.id', onDelete: 'restrict' },
{ name: 'payment_id', type: 'TEXT', desc: 'The id the payment provider returned.' },
{ name: 'total', type: 'NUMERIC(10,2)', required: true }
] }
],
defaultPins: ['shopper', 'psp', 'api', 'db', 'place']
};
Source
This page is skills/architecture-explorer/references/data-model.md, the guide the skill reads while it works. Edit it there; the documentation includes it as is.