MODEL_GUIDE.md
2,648 words · 12 min read · 1 diagram
title
Model guide for Stillcurrent
audience
LLMs and agents that build architecture models
updated
2026-10-22

Model guide for Stillcurrent#

How to build and change an architecture model in Stillcurrent through MCP: what a model holds, the strict rules it keeps, every operation of apply_model_changes, and the YAML format. Read it once before you change a model.

important

A model never holds an invented reference. Every type is a key of the model, every sequence step calls a registered method or follows a declared relationship. If a change would break that, nothing is saved and the error names the operation and what to add first.

1. What a model is#

A model describes one software system as data, with the people and the other systems it talks to, from the people who use it down to the classes and methods in the code. Diagrams are generated from it: you never write Mermaid for a model. Where models fit in a project, and in what order to build them next to the documents and Product, is in the workflow guide's section 0, "Setting up a project" (get_workflow_guide).

Level Element kinds Lives inside
Context person, software_system the model
Container container a software system
Contract contract a container
Component component a container
Code class, interface, enum, record a component
Data table a container
Types external_type the model

A container holds components (it runs code) or tables (it stores data, like a database), never both.

Every element has a key: lower-case words joined by hyphens, unique in the model (order-service, place-order-command). Operations and answers use keys; ids exist but you rarely need them.

One model per System#

A project is organised by Systems, one per software system (list_systems, get_system, save_system). A model exists only inside a System, and every document of the project belongs to one. Each System is:

Placement What it holds
owned exactly one model, made with the System and named after it, and the documents about the system
linked no model of its own: it shows the working model of a System another project of the account maintains
third_party someone else runs it; it may have a small model of the contracts it publishes (withModel)

save_system creates an Owned System with its empty model; renaming the System renames the model. create_model and import_model take the System (projectId and system) and work only for a System that has no model yet, such as a Third-party System that publishes an OpenAPI spec.

An owned System's model describes one software system of its own; every other system it talks to is an external: true software system in that model, a stub. A stub stands for another System of the project: bind it with bind_stub, so the project landscape (the Systems page) can join the Systems. Don't model two systems of your own in one model: split_model turns such a model into one System per system, and migrate_project_systems gives an older project its Systems.

A linked System shows another project's System (link_system): its working model, read-only, and its containers and their contracts copied under every stub that stands for it, keyed <stub>-<key> (backend-orders-api). The copy follows every change of the other model. Point your relationships and types at the copy as at your own contracts: at its contracts always, at its containers only while the project's Strict contracts is off. Pins and breaking changes still compare against the other System's shipped versions. A third-party System with a model of its contracts is copied under the stubs bound to it the same way; without a model, describe what you use of it under its stub yourself (containers and contracts only).

2. How to work#

  1. list_models (or list_systems, each Owned System with its model); note the version.
  2. Build top-down in one or more apply_model_changes batches: systems and people, containers, components, then types, members, relationships, views and sequences. Later operations of a batch may use keys created earlier in it.
  3. Pass the version you last saw as expectedVersion. Each successful batch returns the new version.
  4. Read the issues a change returns, or call validate_model. Fix them in the next batch.
  5. Read the model with get_model (tree, views), get_model_element (signatures, relationships, usage) and get_model_view (generated Mermaid). get_model_map draws the whole model as one nested diagram: closed elements are single boxes, open takes the keys to expand, or "all" for every level at once.
  6. To show a model diagram in a document of the same project, embed it with a ```model fence instead of pasting Mermaid (see the authoring guide, "Model views"): it is drawn from the model each time the document is read, and its shapes link into the model. graph: all (or a list of elements to open) embeds the live graph, which readers explore by opening elements in place.

On a version conflict, call get_model, check what changed, and send your batch again with the new version.

Descriptions#

The model and every element, member, relationship and view can have a description of up to 10,000 characters. Descriptions are Markdown, written like a document (see the authoring guide): callouts, code, tables and Mermaid diagrams all work. Start with one plain sentence that says what the thing is: diagrams show only that first sentence, and the full text appears on the element's page. Headings inside a description sit below the element's own heading, so start at ## or lower. validate_model checks descriptions the way check_markdown checks documents.

3. Types#

Types are written as text with keys: string, order, list<order-line>, map<string, list<order>?>?. A trailing ? means nullable. Every name must be a key of a type in the model.

Kind of type Examples Where it comes from
Built-in string, int, long, decimal, boolean, date, datetime, uuid, bytes, void every model
Built-in generic list<T>, set<T>, map<K, V> every model
Your types classes, interfaces, enums, records add_element in a component
Library types money, http-request add_element with kind external_type
Type parameters repository-t typeParameters on a generic element

Generic arity is checked: list needs one argument, string none. A type parameter can only be used inside the element that declares it. Use void for methods that return nothing.

4. Operations#

apply_model_changes takes { id, expectedVersion, operations: [...] }. Each operation has an op field.

Elements#

JSON
[
  { "op": "add_element", "kind": "software_system", "key": "shop", "name": "Web shop" },
  {
    "op": "add_element",
    "kind": "container",
    "key": "api",
    "parent": "shop",
    "name": "API",
    "technology": "Java 21, Spring Boot"
  },
  {
    "op": "add_element",
    "kind": "container",
    "key": "db",
    "parent": "shop",
    "name": "Database",
    "technology": "PostgreSQL",
    "tags": ["database"]
  },
  { "op": "add_element", "kind": "component", "key": "orders", "parent": "api", "name": "Orders" },
  {
    "op": "add_element",
    "kind": "interface",
    "key": "repository",
    "parent": "orders",
    "name": "Repository",
    "typeParameters": ["T"]
  },
  { "op": "add_element", "kind": "class", "key": "order-service", "parent": "orders", "name": "OrderService" }
]
  • kind: person, software_system, container, component, class, interface, enum, record, external_type.
  • external: true for people and systems outside the scope; abstract: true for abstract classes.
  • Tag containers database or queue to draw them as databases or queues.
  • role makes a container infrastructure (broker, gateway, proxy, load_balancer) or shared code (library); other roles are refused. layer and shared place a component in its container's layers. See Gateways, proxies and brokers, and Dependency direction.
  • color: "#0b6e73" gives an element a colour that every view of the model shows: Focus, the views, the map, the graph, 3D and model views in documents. It is a hue, not a fill: each view derives readable shades from it for the reader's light or dark theme, keeping the difference between people, systems, containers and components. Use one colour per meaning (a team, a bounded context, a part being replaced) and say what the colours mean in the model's description. update_element with color: null clears it; elements without one keep the reader's diagram colour.
  • transparency: 40 (0 to 100) sets how see-through the frame of a software system, container or component is in the 2D view when it is open: 0 is a solid fill, 100 no fill at all. Lines are always drawn over frames, so a solid frame hides nothing. Leave it out to let each reader's own setting decide; update_element with transparency: null clears it. Other kinds of element are refused.
  • update_element changes name, key, description, technology, tags, colour or flags; move_element moves it to another parent; remove_element removes it.

Members#

JSON
[
  { "op": "add_member", "element": "order", "kind": "field", "name": "id", "type": "uuid" },
  { "op": "add_member", "element": "order", "kind": "field", "name": "lines", "type": "list<order-line>" },
  {
    "op": "add_member",
    "element": "order-service",
    "kind": "method",
    "name": "placeOrder",
    "parameters": [{ "name": "command", "type": "place-order-command" }],
    "type": "order-id"
  },
  { "op": "add_member", "element": "status", "kind": "enum_value", "name": "PAID" }
]
  • Methods default to void; fields need a type; enum values have none.
  • visibility is public (default), protected, private or package; static and abstract are flags.
  • implements: "repository.find" links a method to the interface method it implements; the signatures must match.
  • Members are referred to as "element-key.name". For overloaded methods use { "element": "order-service", "name": "find", "parameters": ["uuid"] }.
  • update_member replaces what you pass (parameters replaces all of them); remove_member removes one.

Relationships#

Kind From To
uses person, system, container, component person, system, container, component, contract
uses contract (a gateway's) contract
implements class, record, enum interface
implements component, class contract (it serves it)
extends class or interface the same kind
depends_on class, interface, enum, record those, an external type, or a contract
association, composition, aggregation class, interface, enum, record those, or an external type
references table table (also itself)
stored_in class, record table
renders component, class component, class (see Dependency direction)
JSON
[
  {
    "op": "add_relationship",
    "kind": "uses",
    "source": "api",
    "target": "db",
    "label": "Reads and writes",
    "technology": "JDBC"
  },
  {
    "op": "add_relationship",
    "kind": "implements",
    "source": "jpa-order-repository",
    "target": "repository"
  },
  { "op": "add_relationship", "kind": "depends_on", "source": "order-service", "target": "repository" },
  {
    "op": "add_relationship",
    "kind": "uses",
    "source": "api",
    "target": "event-bus",
    "label": "Publishes order events",
    "technology": "Kafka",
    "interaction": "async"
  }
]

A uses relationship between two components also counts between their containers and systems: you only declare it once, at the lowest level that is true. Refer to a relationship as { "kind", "source", "target", "label" }.

A uses relationship is a call that waits for an answer unless you set "interaction": "async": a message sent through a queue, a topic or an event, where the sender carries on. Set it on every relationship to and from a queue (a container tagged queue) and on events. Only uses can be async; change it with update_relationship. Diagrams add "async" to the technology line, the map and the graph draw messages dotted, and a line that stands for several relationships is async only when all of them are.

Contracts#

A contract is the API a container offers: an OpenAPI, AsyncAPI, GraphQL or gRPC interface. It lives inside its container, has a style (openapi, asyncapi, graphql, grpc), a semantic version (1.4.0) and a status (active, deprecated, retired). Its members are its operations (methods, each with a binding such as GET /orders/{id}, send orders.placed, query order or rpc Orders/Get); the types they take and return are records and enums inside the contract.

Don't write contracts by hand when the code has a spec: import_contract reads the spec file (OpenAPI 3, AsyncAPI 2 or 3, a GraphQL schema, a .proto file) and creates or updates the contract, keeping the spec text with its sourcePath and sourceCommit. Importing again changes only what differs, so whatever points at an operation or type keeps working. Without a spec yet (design first), add the contract and its operations yourself:

JSON
[
  {
    "op": "add_element",
    "kind": "contract",
    "key": "orders-api",
    "name": "Orders API",
    "parent": "api",
    "style": "openapi",
    "version": "1.0.0"
  },
  {
    "op": "add_element",
    "kind": "record",
    "key": "orders-api-order",
    "name": "Order",
    "parent": "orders-api"
  },
  {
    "op": "add_member",
    "element": "orders-api",
    "kind": "method",
    "name": "getOrder",
    "binding": "GET /orders/{id}",
    "type": "orders-api-order",
    "parameters": [{ "name": "id", "type": "uuid" }]
  }
]

How the rest of the model connects through it:

  • Consumers point their uses at the contract, not at the container: { "kind": "uses", "source": "web", "target": "orders-api" }. Diagrams name the contract and its major version on the line ("Orders API (OpenAPI v1)"), and the container's component view draws its contracts.
  • Code in another container only reaches a contract's operations and types: a client class depends_on the contract and its methods return orders-api-order, never a class of the other container.
  • Servers: the component (or class) that serves the contract implements it, and its methods may implements the contract's operations.
  • Versions: a new major version is a new contract element with the same name and a higher major version (orders-v2 next to orders-v1); a minor change updates version. Consumers are pinned to the major version they point at.
  • Events: the producer owns the AsyncAPI contract; consumers uses it with "interaction": "async".

Versions and breaking changes#

An owned System ships read-only versions (list_system_versions, get_system_version): a copy of its model, documents and contracts under a semantic version. A release ships the Systems it lists; ship_system_version ships one outside a release. get_system_changes compares the model with the last version and classifies each contract's changes:

Class Means Next version
breaking an operation, parameter, field or enum value removed, a type changed, a new required input, a moved binding major
compatible only additions, an input made optional, an output made required minor
internal no contract changed patch

The diff is the minimum. When a change of meaning is invisible to it (a field that means something else, an endpoint that paginates now), raise the class with classify_contract_change. Never lower it: only the owner lowers a class, with a reason. A breaking change to a contract that has consumers can't ship in the same major version: add the next major version as a new contract element next to the old one, move the consumers, deprecate_contract the old one (its consumers get migration items) and retire_contract it once nothing uses it.

Gateways, proxies and brokers#

Infrastructure is a container with a role: broker, gateway, proxy or load_balancer (shared code is a library, see Dependency direction) ("role": "gateway" on add_element). A relationship keeps saying what it means, from the caller to what it calls; via lists the containers it goes through, in order:

JSON
[
  {
    "op": "add_relationship",
    "kind": "uses",
    "source": "web",
    "target": "orders-api",
    "label": "reads orders",
    "via": ["api-gateway"]
  },
  {
    "op": "add_relationship",
    "kind": "uses",
    "source": "billing",
    "target": "order-events",
    "interaction": "async",
    "via": ["kafka"]
  }
]

Diagrams name the path on the line ("via API gateway"); a ```model fence with via: expand (or get_model_view with via: "expand") draws it hop by hop. A sequence step may travel one hop: from the caller to the gateway, or from the broker on. A gateway's own contract uses the contracts behind it; for events, the producer owns the AsyncAPI contract and consumers subscribe with an async uses to it, through the broker. Proxies' and load balancers' details (TLS, health checks, policies) wait for a deployment view.

Two rules keep containers talking through their contracts: contract-bypass (a uses into a container that offers contracts, around them) and contract-boundary (code, or a member's type, that reaches into another container). They are warnings, and errors in a project with strict contracts (new projects are). validate_model marks errors with "severity": "error".

Dependency direction#

A model's diagrams should read one way: every arrow is a dependency (who calls or imports whom, not where the data goes), and no arrow comes back (ADR-86, ADR-89). Three things let a model say how the code is layered.

Library containers. Shared code that is compiled into other containers, never deployed or called on its own, is a container with "role": "library". It is drawn with a dashed outline. The other containers of its System may depend on it without a contract (no contract-boundary or contract-bypass for them); a library may depend on another library, but not on the containers that use it.

JSON
[
  {
    "op": "add_element",
    "kind": "container",
    "key": "shared-lib",
    "parent": "shop",
    "name": "Shared library",
    "role": "library"
  }
]

renders. A server component that renders a client component imports it, but that is the framework's composition, not a dependency. Say it with a renders relationship from a component or class to a component or class. It is drawn dashed, labelled "renders", and counts for none of the rules below, nor for contract-boundary.

JSON
[{ "op": "add_relationship", "kind": "renders", "source": "order-page", "target": "order-form" }]

Layers. A component may declare a layer, a whole number from 0 (the top) to 99, and shared: true when the other components of its layer share it. Set them on add_element or update_element; layer: null clears one. Container and component views are laid out top to bottom, and declared layers are their ranks: a lower layer is drawn below a higher one, so a dependency that points up shows as an arrow pointing up.

JSON
[
  { "op": "update_element", "element": "orders-page", "layer": 0 },
  { "op": "update_element", "element": "orders", "layer": 1 },
  { "op": "update_element", "element": "ui-kit", "layer": 1, "shared": true },
  { "op": "update_element", "element": "order-repository", "layer": 2 }
]

validate_model checks the direction. A dependency is a uses, depends_on, association, extends or implements relationship between anything inside two elements, rolled up to them (a class in component A depending on a class in component B is A depending on B); renders, composition and aggregation don't count.

Rule Reported when How to fix it
dependency-cycle the containers of a System, or the components of a container, depend on each other in a cycle. Reported once per cycle, with its members and one relationship per edge. Every model gets it. Make the dependencies point one way: move what both use into a library container (or a shared component) below them, invert one dependency through an interface, or turn it into an event the other subscribes to.
upward-dependency in a container whose components declare layers, a component depends on one in a higher layer (a smaller number): order-repository (2) → orders (1). Move what the lower component needs down a layer, or let the higher component call the lower one instead.
sibling-dependency in such a container, a component depends on another of the same layer and neither is shared: orders (1) → billing (1). Move what both need into a shared component below them, or mark the one they share shared: true.
library-dependency a library container depends on a sibling container that isn't a library. Move what the library needs into it, or drop the role if it is deployed on its own.
missing-layer some components of a container declare a layer and others don't; reported once per container. The layer rules skip the components without one. Give every component of the container a layer.

A container whose components declare no layers gets only the cycle rule. The first four rules are warnings, and errors in a project with strict contracts, like the contract rules; missing-layer is always a warning.

Data models#

A database is a container that holds tables. Tables have columns (members of kind column) with a type, like fields; mark key columns with primaryKey: true (one or more columns) or unique: true. A nullable column has a nullable type (uuid?). Database-specific types are external types ({ "op": "add_element", "kind": "external_type", "key": "jsonb" }).

A references relationship goes from the table that holds the key to the table it points at, optionally naming that column. cardinality says how many rows each end stands for: exactly_one, zero_or_one, zero_or_more or one_or_more. By default the source is zero_or_more and the target exactly_one (zero_or_one when the key column is nullable): many revisions per document, one document per revision. A stored_in relationship says which table a class or record is persisted in.

JSON
[
  { "op": "add_element", "kind": "table", "key": "orders-table", "name": "orders", "parent": "db" },
  { "op": "add_element", "kind": "table", "key": "lines-table", "name": "order_lines", "parent": "db" },
  {
    "op": "add_member",
    "element": "orders-table",
    "kind": "column",
    "name": "id",
    "type": "uuid",
    "primaryKey": true
  },
  {
    "op": "add_member",
    "element": "orders-table",
    "kind": "column",
    "name": "placed_at",
    "type": "datetime"
  },
  {
    "op": "add_member",
    "element": "lines-table",
    "kind": "column",
    "name": "id",
    "type": "uuid",
    "primaryKey": true
  },
  { "op": "add_member", "element": "lines-table", "kind": "column", "name": "order_id", "type": "uuid" },
  {
    "op": "add_relationship",
    "kind": "references",
    "source": "lines-table",
    "target": "orders-table",
    "label": "belongs to",
    "column": "order_id",
    "cardinality": { "source": "one_or_more", "target": "exactly_one" }
  },
  { "op": "add_relationship", "kind": "stored_in", "source": "order", "target": "orders-table" },
  { "op": "add_view", "kind": "data", "key": "orders-data", "title": "Orders data", "scope": "db" }
]

A data view, scoped to a container with tables, is drawn as an ER diagram; readers who click into a database see it as the database's inside. A table without a primary key is reported by validate_model.

Views#

JSON
[
  { "op": "add_view", "kind": "context", "key": "context", "title": "System context" },
  { "op": "add_view", "kind": "container", "key": "containers", "title": "Containers", "scope": "shop" },
  {
    "op": "add_view",
    "kind": "component",
    "key": "api-components",
    "title": "Inside the API",
    "scope": "api"
  },
  { "op": "add_view", "kind": "code", "key": "orders-code", "title": "Orders", "scope": "orders" },
  { "op": "add_view", "kind": "sequence", "key": "place-order", "title": "Placing an order" }
]

Container views are scoped to a system, component and data views to a container, code views to a component. Views show their contents automatically; elements (or set_view_elements) limits one to a list. Keep each to about nine C4 elements or twelve classes; split bigger ones.

You don't need a view for every element: readers can click from any element into its inside, and the app makes up the levels the model has no view for. Add views for the pictures worth naming and putting into documents. For one picture of everything, use get_model_map rather than a large view; it is meant for small models or a few open elements, since more than about 60 shapes is hard to read.

Sequences#

JSON
[
  { "op": "add_step", "view": "place-order", "from": "web-app", "to": "api" },
  { "op": "add_step", "view": "place-order", "from": "api", "to": "order-service", "method": "placeOrder" },
  { "op": "add_fragment", "view": "place-order", "kind": "alt", "sections": ["in stock", "sold out"] },
  {
    "op": "add_step",
    "view": "place-order",
    "from": "order-service",
    "to": "repository",
    "method": "save",
    "in": { "fragment": { "view": "place-order", "fragment": 1 }, "section": 1 }
  },
  { "op": "add_step", "view": "place-order", "kind": "return", "from": "order-service", "to": "api" }
]
  • Steps add their participants; add_participant sets order or an alias first.
  • kind is call (default), async or return. A return answers the latest open call in the other direction, or the one in replyTo.
  • A call to a C4 element follows its uses relationship, found automatically when there is exactly one.
  • Fragments are alt, opt, loop and par, with one guard per section; only alt and par have several sections. Put steps or other fragments inside with in.
  • Steps are numbered as the diagram shows them: refer to one as { "view": "place-order", "number": 3 } in update_step (its note) and remove_step. Removing a call removes its return.

5. Sequence rules#

A sequence can only show what the model allows:

Step Must
Call to a class or interface Name one of its methods: its own, inherited, or from an interface it implements
Caller of a class, if a class Have a code relationship to it (or to a supertype it is called through)
Caller of a class, if a C4 element Contain it, or use its component
Call to a person, system, container or component Follow a uses relationship from the caller (or its component)
Return Answer an earlier call, go back the way it came, once, never from void

A generated sequence looks like this:

sequenceDiagram
  autonumber
  participant p_web_app as Web app
  participant p_api as API
  participant p_order_service as OrderService
  p_web_app->>p_api: Places order [JSON/HTTPS]
  p_api->>p_order_service: placeOrder(command)
  p_order_service-->>p_api: OrderId
  p_api-->>p_web_app: done

6. Consistent and complete#

Consistency is checked after every batch, and a batch that breaks it is refused: unknown keys, types that are not types, wrong generic arity, duplicate overloads, implements links whose signatures differ, uses between an element and its own container, inheritance cycles, view elements a view can't show, and sequence steps against the rules above.

Completeness is reported, never refused, because models are built step by step: a class still missing methods of an interface it implements, abstract methods in a concrete class, containers or components without relationships, tables without a primary key, dependency cycles and dependencies against declared layers (see Dependency direction), descriptions with Markdown problems, empty sequences and oversized views. Aim for a model with no issues.

7. Removing things#

Removing something still in use is refused with the list of users. cascade: true also removes what is inside or uses it: children of an element, steps that call a method or follow a relationship, steps of a participant, contents of a fragment. A type that members elsewhere still use is never removed: change those types first.

8. History, export and import#

  • Every model keeps recorded versions (list_model_revisions); restore_model_revision brings one back as a new version, and can be undone the same way.
  • export_model returns the model as YAML: keys as references, types as text, views and sequences in drawing order. import_model reads it, to create a new model or to replace one's content, with the same validation as apply_model_changes.
YAML
format: stillcurrent-model/1
elements:
  - key: shop
    kind: software_system
    name: Web shop
  - key: api
    kind: container
    name: API
    parent: shop
    technology: Java 21, Spring Boot
members: []
relationships: []

9. Proposed changes#

A feature or fix that changes the architecture proposes its model changes before anyone applies them. propose_model_changes saves a list of the same operations apply_model_changes takes, for one model of the item's project, without applying them. Stillcurrent checks them against the current model, keeps those that no longer apply and says why, and draws the result as an overlay in the item's review: every level the change touches after the change (the system context, then the containers, components or tables, and code it reaches), with every new, changed or removed element and relationship marked so in its name or label, and a class whose members changed marked as changed. The project owner reviews the overlay in Review.

  • The overlay shows the system context and, for each changed element, member or relationship end, the containers of its system, the components (or tables) of its container and the code of its component, up to eight levels; every change is also listed.
  • Pass expectedVersion (the proposal's) to replace an existing proposal; otherwise a new one is saved. Once part of it is applied, it can't change.
  • Nothing is applied before the owner approves the item. Then the operations are applied by the worker that syncs the model, with complete_step listing the operations it applied (all or nothing, like one apply_model_changes call), or by the owner on the item's page.
  • People write proposals too. In the app nobody edits a model's facts directly: the model page's Propose a change opens a feature's or fix's proposal, where each change (an element's name, description or technology, adding inside, connecting, fields and methods, removing) is checked against the model and the proposal so far before it is added. Expect proposals written this way next to your own, and apply them like any other when you implement the item. The owner can also apply an approved item's proposal from its page (Apply to the model). Only presentation is changed without a proposal: colours, frame transparency and saved views.

10. Checklist#

  • Read the model first (get_model), and use its version as expectedVersion.
  • Every element has a key in lower-case-with-hyphens and the right parent.
  • Every type is a key: built-in, your own, an external_type you registered, or a type parameter.
  • Classes that implement an interface have all its methods.
  • Every sequence step names a method of the callee or follows a uses relationship.
  • Databases hold their tables, with keys, references between them and stored_in from the classes they persist.
  • Dependencies point one way: no dependency-cycle; shared code is a library container or a shared component; server components that render client components say so with renders.
  • Every element you add has a description whose first sentence says what it is for.
  • validate_model reports no issues before you say the model is done.