c4 schema (v0.5)
The models/c4.json file is validated by the normative JSON Schema published at its canonical URL:
- $id: https://contextbrew.dev/schemas/c4/v0.5/schema.json
- Format version:
0.5.0 - Schema dialect: draft-07
- Validate with:
ctx schema c4or any JSON Schema validator (ajv, VS Code, …)
Root object: C4File
Section titled “Root object: C4File”| Property | Type | Required | Description |
|---|---|---|---|
kind | "c4-file" | yes | |
schemaVersion | C4SchemaVersion | yes | |
persons | C4Person[] | yes | People/actors (Context level). |
softwareSystems | C4SoftwareSystem[] | yes | Top-level software systems (Context level). |
containers | C4Container[] | yes | Deployable units (Container level). |
components | C4Component[] | yes | Components — drill-down (Container→Component). |
relationships | C4Relationship[] | yes | Directed relationships between elements (endpoints may also be deployment instance/infrastructure ids — 0.4.0). |
invariants | C4Invariant[] | yes | Optional cross-cutting architecture rules. |
groups | C4Group[] | no | Optional named element groupings (0.3.0 — C4-004). |
views | C4AnyView[] | no | Saved views — filtered (0.3.0) + dynamic/deployment/custom (0.4.0). |
deploymentEnvironments | C4DeploymentEnvironment[] | no | Deployment topology (0.4.0 — Structurizr parity). |
styles | C4Styles | no | Styling — tag-matched element/relationship styles + theme (0.4.0). |
impliedRelationships | boolean | no | When true, renderers/exporters add IMPLIED relationships (0.4.0): a relationship between nested elements (component/container/system) implies the same relationship between every ancestor pair, unless an explicit relationship already exists. Derived — never persisted. |
regeneratedAt | string | no | ISO timestamp of the last regenerate-from-models action. Set by the regenerate endpoint; absent on hand-authored files. Used by the idempotency check (T4) — a regenerate call returns 409 Conflict if the file has been hand-edited since this timestamp, unless ?force=1. |
regeneratedFrom | string | no | Source models used for the last regenerate (e.g. "sim+ddd+dsm+scm"). |
visualisationSetup | VisualisationSetup | no | Canvas viewport, zoom, etc. |
Definitions
Section titled “Definitions”C4AnimationStep
Section titled “C4AnimationStep”One animation step: elements revealed together, in order sequence.
| Property | Type | Required | Description |
|---|---|---|---|
order | number | yes | 1-based step number. |
elementIds | | yes | Element ids revealed by this step. |
C4AnyView
Section titled “C4AnyView”Any saved view (0.4.0 union — old files only ever carry C4View).
Type: C4View | C4DynamicView | C4DeploymentView | C4CustomView
C4Component
Section titled “C4Component”Component — internal module of a container.
| Property | Type | Required | Description |
|---|---|---|---|
kind | "component" | yes | |
id | string | yes | Stable identifier (canvas-unique). Often the slugified name. |
name | string | yes | Human-readable display name (e.g. "Web App", "Stripe"). |
description | string | no | Optional longer-form description of the element's responsibility. |
technology | string | no | Technology label (e.g. "Next.js", "PostgreSQL 15"). |
tags | | no | Tags for filtering, styling, and cross-model linking. |
position | object | no | Canvas position. |
externalId | string | no | Cross-model links (e.g. ddd:Aggregate:orders). Optional. |
properties | Record<string, string> | no | Structurizr-compatible key-value bag (e.g. { "cbrl:REQ-001": "orders" }). |
url | string | no | Drill-down link (docs, source, tests). |
documentation | string | no | Long-form element documentation (markdown). |
containerId | string | yes | Owning container (id reference). |
C4Container
Section titled “C4Container”Container — deployable unit inside a system.
| Property | Type | Required | Description |
|---|---|---|---|
kind | "container" | "container-db" | yes | |
id | string | yes | Stable identifier (canvas-unique). Often the slugified name. |
name | string | yes | Human-readable display name (e.g. "Web App", "Stripe"). |
description | string | no | Optional longer-form description of the element's responsibility. |
technology | string | no | Technology label (e.g. "Next.js", "PostgreSQL 15"). |
tags | | no | Tags for filtering, styling, and cross-model linking. |
position | object | no | Canvas position. |
externalId | string | no | Cross-model links (e.g. ddd:Aggregate:orders). Optional. |
properties | Record<string, string> | no | Structurizr-compatible key-value bag (e.g. { "cbrl:REQ-001": "orders" }). |
url | string | no | Drill-down link (docs, source, tests). |
documentation | string | no | Long-form element documentation (markdown). |
systemId | string | yes | Owning software system (id reference). |
technologyBucket | C4Technology | no | Bucketed technology (drives icon/color on canvas). |
monthlyCost | C4MonthlyCost | no | Declared monthly running cost (0.5.0 — M25 cost overlays). |
C4ContainerInstance
Section titled “C4ContainerInstance”An instance of a container deployed inside a deployment node.
| Property | Type | Required | Description |
|---|---|---|---|
kind | "container-instance" | yes | |
id | string | yes | |
containerId | string | yes | Owning container (id reference). |
instanceNumber | number | no | |
deploymentGroups | | no | |
tags | | no | |
properties | Record<string, string> | no | |
url | string | no | |
healthChecks | C4HealthCheck[] | no |
C4CustomView
Section titled “C4CustomView”Authored custom view (0.4.0) — an arbitrary explicit subset.
| Property | Type | Required | Description |
|---|---|---|---|
key | string | yes | Stable slug (unique within the file) — e.g. "security". |
title | string | yes | |
description | string | no | |
isDefault | boolean | no | When true, the recipe prompt renders this view by default. |
kind | "custom-view" | yes | |
elementIds | | yes | |
relationshipIds | | no | When absent, all relationships between the included elements show. |
C4DeploymentEnvironment
Section titled “C4DeploymentEnvironment”A named deployment environment (e.g. “Development”, “Live”).
| Property | Type | Required | Description |
|---|---|---|---|
kind | "deployment-environment" | yes | |
id | string | yes | |
name | string | yes | Environment name — referenced by deployment views. |
description | string | no | |
deploymentNodes | C4DeploymentNode[] | yes |
C4DeploymentNode
Section titled “C4DeploymentNode”A deployment node — physical/virtual infrastructure that hosts instances. Recursive: nodes nest (data center → cluster → machine → container runtime).
| Property | Type | Required | Description |
|---|---|---|---|
kind | "deployment-node" | yes | |
id | string | yes | |
name | string | yes | |
description | string | no | |
technology | string | no | |
instances | number | no | Number of instances of this node (default 1). |
tags | | no | |
properties | Record<string, string> | no | |
url | string | no | |
position | object | no | |
children | C4DeploymentNode[] | yes | Nested deployment nodes. |
infrastructureNodes | C4InfrastructureNode[] | yes | |
softwareSystemInstances | C4SoftwareSystemInstance[] | yes | |
containerInstances | C4ContainerInstance[] | yes |
C4DeploymentView
Section titled “C4DeploymentView”Authored deployment view (0.4.0) — projects one deployment environment.
| Property | Type | Required | Description |
|---|---|---|---|
key | string | yes | Stable slug (unique within the file) — e.g. "security". |
title | string | yes | |
description | string | no | |
isDefault | boolean | no | When true, the recipe prompt renders this view by default. |
kind | "deployment-view" | yes | |
environment | string | yes | Deployment environment name this view projects. |
softwareSystemId | string | no | Optional explicit software-system filter (id). |
includeIds | | no | |
excludeIds | | no |
C4DynamicStep
Section titled “C4DynamicStep”One ordered interaction in a dynamic view (0.4.0).
| Property | Type | Required | Description |
|---|---|---|---|
order | number | yes | 1-based display order (numbered on the diagram). |
relationshipId | string | no | Reference an existing relationship — inherits endpoints + label. |
sourceId | string | no | Inline endpoints (used when relationshipId is absent). |
targetId | string | no | |
label | string | no | Label override (or the inline step's label). |
technology | string | no |
C4DynamicView
Section titled “C4DynamicView”Authored dynamic view (0.4.0) — an ordered list of interaction steps. scopeId mirrors Structurizr (* | system id | container id).
| Property | Type | Required | Description |
|---|---|---|---|
key | string | yes | Stable slug (unique within the file) — e.g. "security". |
title | string | yes | |
description | string | no | |
isDefault | boolean | no | When true, the recipe prompt renders this view by default. |
kind | "dynamic-view" | yes | |
scopeId | string | no | |
steps | C4DynamicStep[] | yes |
C4ElementStyle
Section titled “C4ElementStyle”Per-tag element style — first matching tag wins (later tags lose).
| Property | Type | Required | Description |
|---|---|---|---|
tag | string | yes | The element tag this style applies to. |
background | string | no | Fill color (hex like "#3b82f6" or CSS color name). |
color | string | no | Text color. |
stroke | string | no | Border color. |
strokeWidth | number | no | Border width, 1–10. |
shape | C4Shape | no | |
border | C4LineStyle | no | |
fontSize | number | no | |
icon | string | no | Icon URL. |
width | number | no | |
height | number | no | |
opacity | number | no | 0–100. |
metadata | boolean | no | Show the technology/metadata line. |
description | boolean | no | Show the description line. |
C4Group
Section titled “C4Group”Named grouping of elements — first-class in 0.3.0 (C4-004).
| Property | Type | Required | Description |
|---|---|---|---|
kind | "group" | yes | |
id | string | yes | |
name | string | yes | |
elementIds | | yes | Element ids belonging to this grouping (persons/systems/containers). |
C4HealthCheck
Section titled “C4HealthCheck”A health check attached to a container/software-system instance.
| Property | Type | Required | Description |
|---|---|---|---|
id | string | yes | |
name | string | no | |
url | string | yes | URL the instance is pinged on (http/https). |
interval | number | yes | Interval between checks, in seconds. |
timeout | number | yes | Timeout for each check, in seconds. |
headers | Record<string, string> | no | Request headers (e.g. { Authorization: "Basic …" }). |
C4InfrastructureNode
Section titled “C4InfrastructureNode”Infrastructure element inside a deployment node (load balancer, DNS, …).
| Property | Type | Required | Description |
|---|---|---|---|
kind | "infrastructure-node" | yes | |
id | string | yes | |
name | string | yes | |
description | string | no | |
technology | string | no | |
tags | | no | |
properties | Record<string, string> | no | |
url | string | no |
C4Invariant
Section titled “C4Invariant”| Property | Type | Required | Description |
|---|---|---|---|
kind | "invariant" | yes | |
id | string | yes | |
name | string | yes | |
expression | string | yes | Human-readable assertion, e.g. "no direct DB access from the SPA". |
involvedElements | | yes | Element ids the invariant spans. |
severity | C4InvariantSeverity | yes | |
category | C4InvariantCategory | yes |
C4InvariantCategory
Section titled “C4InvariantCategory”Type: "performance" | "security" | "scalability" | "compliance" | "resilience"
C4InvariantSeverity
Section titled “C4InvariantSeverity”Type: "warning" | "error" | "critical"
C4LineStyle
Section titled “C4LineStyle”Border / line style shared by element borders and relationship lines.
Type: "solid" | "dashed" | "dotted"
C4MonthlyCost
Section titled “C4MonthlyCost”Declared monthly running cost of a deployable unit (0.5.0 — M25 cost overlays; the Vantage/CloudZero “$/container” lens). Optional and OMITTED when unknown, so cost-free models produce byte-identical files. Observed costs arrive separately via the M4 live-state collector convention — this is the declared, authored number.
| Property | Type | Required | Description |
|---|---|---|---|
amount | number | yes | Monthly amount in currency (e.g. 420, 1240.5). |
currency | string | yes | ISO 4217 code (e.g. "USD", "EUR"). |
source | string | no | Where the number came from (e.g. "aws-cost-explorer", "estimate"). |
C4Person
Section titled “C4Person”Person — external actor (user, system owner).
| Property | Type | Required | Description |
|---|---|---|---|
kind | "person" | yes | |
id | string | yes | Stable identifier (canvas-unique). Often the slugified name. |
name | string | yes | Human-readable display name (e.g. "Web App", "Stripe"). |
description | string | no | Optional longer-form description of the element's responsibility. |
technology | string | no | Technology label (e.g. "Next.js", "PostgreSQL 15"). |
tags | | no | Tags for filtering, styling, and cross-model linking. |
position | object | no | Canvas position. |
externalId | string | no | Cross-model links (e.g. ddd:Aggregate:orders). Optional. |
properties | Record<string, string> | no | Structurizr-compatible key-value bag (e.g. { "cbrl:REQ-001": "orders" }). |
url | string | no | Drill-down link (docs, source, tests). |
documentation | string | no | Long-form element documentation (markdown). |
C4Relationship
Section titled “C4Relationship”Directed relationship between two C4 elements.
| Property | Type | Required | Description |
|---|---|---|---|
kind | "relationship" | yes | |
id | string | yes | |
sourceId | string | yes | |
targetId | string | yes | |
type | C4RelationshipType | yes | |
label | string | no | Optional human-readable label overriding type. |
protocol | string | no | Optional technology of the connection (HTTP, gRPC, JDBC, NATS, …). |
description | string | no | Optional explanation of WHY the relationship exists. |
tags | | no | Tags for filtering and styling (0.4.0 — Structurizr parity). |
properties | Record<string, string> | no | Structurizr-compatible key-value bag (0.4.0). |
url | string | no | Drill-down link (0.4.0). |
C4RelationshipStyle
Section titled “C4RelationshipStyle”Per-tag relationship style — first matching tag wins.
| Property | Type | Required | Description |
|---|---|---|---|
tag | string | yes | |
color | string | no | |
thickness | number | no | Line thickness. |
style | C4LineStyle | no | |
routing | "direct" | "orthogonal" | "curved" | no | |
fontSize | number | no | |
width | number | no | Label width. |
position | number | no | Label position along the line, 0–100. |
opacity | number | no | 0–100. |
C4RelationshipType
Section titled “C4RelationshipType”Relationship verb between two C4 elements.
Type: "calls" | "reads-from" | "writes-to" | "publishes-event" | "subscribes-to" | "uses" | "depends-on" | "delivers-to" | "interacts-with"
C4SchemaVersion
Section titled “C4SchemaVersion”Schema versions the parser accepts. Save/serialize always emits the latest. 0.5.0 (M25 cost overlays) adds the optional per-container monthlyCost — purely additive, so 0.1.0–0.4.0 files keep parsing and validating (the generated JSON schema carries the version as an enum; old schemas stay under schemas/c4/v0.4/ for existing readers).
Type: "0.1.0" | "0.2.0" | "0.3.0" | "0.4.0" | "0.5.0"
C4Shape
Section titled “C4Shape”Element shapes (kebab-case; mapped to Structurizr CamelCase on export).
Type: "box" | "rounded-box" | "circle" | "ellipse" | "hexagon" | "diamond" | "cylinder" | "bucket" | "pipe" | "person" | "folder" | "component" | "web-browser" | "window" | "mobile-device" | "terminal"
C4SoftwareSystem
Section titled “C4SoftwareSystem”Software System — top-level system boundary.
| Property | Type | Required | Description |
|---|---|---|---|
kind | "software-system" | yes | |
id | string | yes | Stable identifier (canvas-unique). Often the slugified name. |
name | string | yes | Human-readable display name (e.g. "Web App", "Stripe"). |
description | string | no | Optional longer-form description of the element's responsibility. |
technology | string | no | Technology label (e.g. "Next.js", "PostgreSQL 15"). |
tags | | no | Tags for filtering, styling, and cross-model linking. |
position | object | no | Canvas position. |
externalId | string | no | Cross-model links (e.g. ddd:Aggregate:orders). Optional. |
properties | Record<string, string> | no | Structurizr-compatible key-value bag (e.g. { "cbrl:REQ-001": "orders" }). |
url | string | no | Drill-down link (docs, source, tests). |
documentation | string | no | Long-form element documentation (markdown). |
isScope | boolean | no | True if this is the system currently being modeled (vs. external dep). |
C4SoftwareSystemInstance
Section titled “C4SoftwareSystemInstance”An instance of a software system deployed inside a deployment node.
| Property | Type | Required | Description |
|---|---|---|---|
kind | "software-system-instance" | yes | |
id | string | yes | |
softwareSystemId | string | yes | Owning software system (id reference). |
instanceNumber | number | no | 1-based instance number within the environment (Structurizr parity). |
deploymentGroups | | no | Deployment groups — disambiguates multiple instances in one node. |
tags | | no | |
properties | Record<string, string> | no | |
url | string | no | |
healthChecks | C4HealthCheck[] | no |
C4Styles
Section titled “C4Styles”File-level styling block (0.4.0).
| Property | Type | Required | Description |
|---|---|---|---|
theme | string | no | Theme name (e.g. "default", "dark") or https URL. |
elements | C4ElementStyle[] | yes | |
relationships | C4RelationshipStyle[] | yes |
C4Technology
Section titled “C4Technology”C4 technology buckets — populate the “technology” label on a container.
Type: "web-app" | "spa" | "mobile" | "api" | "service" | "database" | "message-bus" | "queue" | "cache" | "cdn" | "function" | "external-system" | "browser" | "cli" | "library"
C4View
Section titled “C4View”A saved filtered view (0.3.0): tag-include/exclude filter + optional level cut + optional animation steps (0.4.0, Structurizr parity).
| Property | Type | Required | Description |
|---|---|---|---|
key | string | yes | Stable slug (unique within the file) — e.g. "security". |
title | string | yes | |
description | string | no | |
isDefault | boolean | no | When true, the recipe prompt renders this view by default. |
kind | "view" | yes | |
level | C4ViewLevel | no | |
includeTags | | no | Element is kept if it has ANY of these tags (empty/undefined = all). |
excludeTags | | no | Element is dropped if it has ANY of these tags. |
animation | C4AnimationStep[] | no | Ordered reveal steps (0.4.0). |
C4ViewLevel
Section titled “C4ViewLevel”Which C4 level a view projects. Undefined = all levels.
Type: "landscape" | "context" | "container" | "component"
VisualisationSetup
Section titled “VisualisationSetup”INTERNAL: Context Studio canvas state only; never emitted to coding agents.
| Property | Type | Required | Description |
|---|---|---|---|
nodePositions | Record<string, object> | yes | |
zoomLevel | number | yes | |
viewport | object | no | |
updatedAt | string | no |
Sample documents
Section titled “Sample documents”Representative models/c4.json files committed under samples/c4/. Each demo shows three views — pick the one you want: Canvas (rendered through the same SvelteFlow component the IDE uses), Mermaid (a static-flowchart fallback), or Raw JSON. All assets are locally served; no GitHub redirect.
Open the raw JSON in a new tab(demo-01-context-level.c4.json). The full source is also expanded in the <details> below this preview.
Demo 1 — C4 System Context level: external actors + the system-under-design + immediate external dependencies. Exercises person, software-system (with isScope flag), and relationship nodes.
demo-01-context-level.c4.json — Demo 1 — C4 System Context level: external actors + the system-under-design + immediate external dependencies. Exercises person, software-system (with isScope flag), and relationship nodes. (expand for full JSON)
{ "kind": "c4-file", "schemaVersion": "0.3.0", "persons": [ { "kind": "person", "id": "traveler", "name": "Traveler", "description": "End user searching and booking flights.", "tags": ["external", "primary-actor"], "position": { "x": 0, "y": 0 } }, { "kind": "person", "id": "ops", "name": "Ops Engineer", "description": "Internal operator monitoring bookings.", "tags": ["internal", "secondary-actor"], "position": { "x": 0, "y": 200 } } ], "softwareSystems": [ { "kind": "software-system", "id": "booking-system", "name": "Travel Booking System", "description": "The system under design.", "isScope": true, "tags": ["scope", "internal"], "position": { "x": 400, "y": 100 } }, { "kind": "software-system", "id": "stripe", "name": "Stripe", "description": "External payment processor.", "tags": ["external", "saas"], "position": { "x": 800, "y": 0 } }, { "kind": "software-system", "id": "sendgrid", "name": "SendGrid", "description": "External email delivery service.", "tags": ["external", "saas"], "position": { "x": 800, "y": 200 } } ], "containers": [], "components": [], "relationships": [ { "kind": "relationship", "id": "r-traveler-uses", "sourceId": "traveler", "targetId": "booking-system", "type": "uses", "label": "Books flights", "protocol": "HTTPS", "description": "Web + mobile clients." }, { "kind": "relationship", "id": "r-ops-monitors", "sourceId": "ops", "targetId": "booking-system", "type": "uses", "label": "Monitors bookings", "protocol": "HTTPS" }, { "kind": "relationship", "id": "r-stripe-charge", "sourceId": "booking-system", "targetId": "stripe", "type": "calls", "label": "Charges cards", "protocol": "HTTPS/REST" }, { "kind": "relationship", "id": "r-sendgrid-email", "sourceId": "booking-system", "targetId": "sendgrid", "type": "calls", "label": "Sends confirmation emails", "protocol": "HTTPS/REST" } ], "invariants": []}Open the raw JSON in a new tab(demo-02-container-level.c4.json). The full source is also expanded in the <details> below this preview.
Demo 2 — C4 Container level: deployable units inside the booking system (SPA, API, DB, message bus). Exercises person, software-system, container, container-db (with systemId + technologyBucket + technology), relationship, and invariant nodes.
demo-02-container-level.c4.json — Demo 2 — C4 Container level: deployable units inside the booking system (SPA, API, DB, message bus). Exercises person, software-system, container, container-db (with systemId + technologyBucket + technology), relationship, and invariant nodes. (expand for full JSON)
{ "kind": "c4-file", "schemaVersion": "0.3.0", "persons": [ { "kind": "person", "id": "traveler", "name": "Traveler", "tags": ["external"], "position": { "x": 0, "y": 0 } } ], "softwareSystems": [ { "kind": "software-system", "id": "booking-system", "name": "Travel Booking System", "isScope": true, "tags": ["scope"] } ], "containers": [ { "kind": "container", "id": "spa", "name": "Web SPA", "description": "Customer-facing single-page app.", "systemId": "booking-system", "technologyBucket": "spa", "technology": "Next.js 15 + React 19", "tags": ["frontend", "public"], "position": { "x": 200, "y": 0 } }, { "kind": "container", "id": "api", "name": "Booking API", "description": "Backend REST/GraphQL API.", "systemId": "booking-system", "technologyBucket": "api", "technology": "SvelteKit 2 + Bun", "tags": ["backend"], "position": { "x": 500, "y": 0 } }, { "kind": "container", "id": "worker", "name": "Booking Worker", "description": "Async worker processing events.", "systemId": "booking-system", "technologyBucket": "service", "technology": "Bun + PostgreSQL 15", "tags": ["backend", "async"], "position": { "x": 500, "y": 200 } }, { "kind": "container-db", "id": "primary-db", "name": "Primary Database", "description": "PostgreSQL primary.", "systemId": "booking-system", "technologyBucket": "database", "technology": "PostgreSQL 15", "tags": ["data"], "position": { "x": 800, "y": 0 } }, { "kind": "container", "id": "bus", "name": "Message Bus", "description": "Event bus for async fan-out.", "systemId": "booking-system", "technologyBucket": "message-bus", "technology": "NATS JetStream", "tags": ["infra", "events"], "position": { "x": 500, "y": 400 } } ], "components": [], "relationships": [ { "kind": "relationship", "id": "r-spa-api", "sourceId": "spa", "targetId": "api", "type": "calls", "protocol": "HTTPS/JSON", "description": "REST + GraphQL over HTTPS." }, { "kind": "relationship", "id": "r-api-db", "sourceId": "api", "targetId": "primary-db", "type": "reads-from", "label": "Reads/writes bookings", "protocol": "JDBC" }, { "kind": "relationship", "id": "r-api-bus", "sourceId": "api", "targetId": "bus", "type": "publishes-event", "label": "Emits BookingConfirmed", "protocol": "NATS" }, { "kind": "relationship", "id": "r-worker-bus", "sourceId": "worker", "targetId": "bus", "type": "subscribes-to", "label": "Listens for BookingConfirmed" }, { "kind": "relationship", "id": "r-worker-db", "sourceId": "worker", "targetId": "primary-db", "type": "writes-to", "protocol": "JDBC" }, { "kind": "relationship", "id": "r-traveler-spa", "sourceId": "traveler", "targetId": "spa", "type": "uses", "protocol": "HTTPS" } ], "invariants": [ { "kind": "invariant", "id": "inv-no-spa-db", "name": "No direct DB access from the SPA", "expression": "no edge(spa -> primary-db)", "involvedElements": ["spa", "primary-db"], "severity": "error", "category": "security" }, { "kind": "invariant", "id": "inv-worker-events", "name": "Worker must consume events, not call APIs", "expression": "worker.in == bus", "involvedElements": ["worker"], "severity": "warning", "category": "resilience" } ]}Open the raw JSON in a new tab(demo-03-component-level.c4.json). The full source is also expanded in the <details> below this preview.
Demo 3 — C4 Component level: drill-down into the Booking API container. Exercises container + component (with containerId) nodes, plus relationships between components.
demo-03-component-level.c4.json — Demo 3 — C4 Component level: drill-down into the Booking API container. Exercises container + component (with containerId) nodes, plus relationships between components. (expand for full JSON)
{ "kind": "c4-file", "schemaVersion": "0.3.0", "persons": [], "softwareSystems": [ { "kind": "software-system", "id": "booking-system", "name": "Travel Booking System", "isScope": true, "tags": ["scope"] } ], "containers": [ { "kind": "container", "id": "api", "name": "Booking API", "systemId": "booking-system", "technologyBucket": "api", "technology": "SvelteKit 2" } ], "components": [ { "kind": "component", "id": "comp-ctrl-booking", "name": "BookingController", "description": "REST routes for bookings.", "containerId": "api", "technology": "SvelteKit endpoints", "tags": ["public-api"], "position": { "x": 0, "y": 0 } }, { "kind": "component", "id": "comp-svc-pricing", "name": "PricingService", "description": "Computes fares and discounts.", "containerId": "api", "technology": "TypeScript", "tags": ["domain"], "position": { "x": 200, "y": 0 } }, { "kind": "component", "id": "comp-repo-booking", "name": "BookingRepository", "description": "Postgres-backed bookings store.", "containerId": "api", "technology": "Drizzle ORM", "tags": ["data"], "position": { "x": 400, "y": 0 } }, { "kind": "component", "id": "comp-validator", "name": "BookingValidator", "description": "Validates booking domain rules.", "containerId": "api", "technology": "TypeScript", "tags": ["domain"], "position": { "x": 200, "y": 200 } } ], "relationships": [ { "kind": "relationship", "id": "r-ctrl-validator", "sourceId": "comp-ctrl-booking", "targetId": "comp-validator", "type": "calls", "label": "Validates booking" }, { "kind": "relationship", "id": "r-ctrl-pricing", "sourceId": "comp-ctrl-booking", "targetId": "comp-svc-pricing", "type": "calls", "label": "Computes price" }, { "kind": "relationship", "id": "r-ctrl-repo", "sourceId": "comp-ctrl-booking", "targetId": "comp-repo-booking", "type": "calls", "label": "Persists booking" }, { "kind": "relationship", "id": "r-validator-pricing", "sourceId": "comp-validator", "targetId": "comp-svc-pricing", "type": "uses", "label": "Price-aware validation" } ], "invariants": []}Open the raw JSON in a new tab(demo-04-groups-and-views.c4.json). The full source is also expanded in the <details> below this preview.
Demo 4 — C4 groups + views: named element groupings and tag-filtered named views (security view excludes frontend). Exercises C4Group, C4View, cross-model externalId links, and regenerated provenance.
demo-04-groups-and-views.c4.json — Demo 4 — C4 groups + views: named element groupings and tag-filtered named views (security view excludes frontend). Exercises C4Group, C4View, cross-model externalId links, and regenerated provenance. (expand for full JSON)
{ "kind": "c4-file", "schemaVersion": "0.3.0", "persons": [ { "kind": "person", "id": "traveler", "name": "Traveler", "externalId": "usm:persona:traveler", "tags": ["external"] } ], "softwareSystems": [ { "kind": "software-system", "id": "booking-system", "name": "Travel Booking System", "isScope": true, "tags": ["scope"], "externalId": "ddd:domain:booking" } ], "containers": [ { "kind": "container", "id": "spa", "name": "Web SPA", "systemId": "booking-system", "technologyBucket": "spa", "tags": ["frontend", "public"] }, { "kind": "container", "id": "api", "name": "Booking API", "systemId": "booking-system", "technologyBucket": "api", "tags": ["backend"] }, { "kind": "container-db", "id": "primary-db", "name": "Primary Database", "systemId": "booking-system", "technologyBucket": "database", "tags": ["data"] } ], "components": [], "relationships": [ { "kind": "relationship", "id": "r-spa-api", "sourceId": "spa", "targetId": "api", "type": "calls" }, { "kind": "relationship", "id": "r-api-db", "sourceId": "api", "targetId": "primary-db", "type": "reads-from" } ], "invariants": [ { "kind": "invariant", "id": "inv-no-direct-db", "name": "No direct DB access from the SPA", "expression": "no edge(spa -> primary-db)", "involvedElements": ["spa", "primary-db"], "severity": "error", "category": "security" } ], "groups": [ { "kind": "group", "id": "g-frontend", "name": "Frontend Boundary", "elementIds": ["spa", "traveler"] }, { "kind": "group", "id": "g-internal", "name": "Internal Boundary", "elementIds": ["api", "primary-db"] } ], "views": [ { "kind": "view", "key": "security", "title": "Security View", "level": "container", "includeTags": ["backend", "data", "frontend"], "isDefault": true }, { "kind": "view", "key": "backend-only", "title": "Backend Only", "level": "container", "excludeTags": ["frontend", "public"] }, { "kind": "view", "key": "system-context", "title": "System Context", "level": "context", "includeTags": ["scope", "external"] } ], "regeneratedAt": "2026-09-14T09:00:00.000Z", "regeneratedFrom": "ddd+dsm+scm+sim"}Open the raw JSON in a new tab(demo-05-deployment-and-styles.c4.json). The full source is also expanded in the <details> below this preview.
Demo 5 — C4 0.4.0 Structurizr parity: deployment environments (nodes, infrastructure, instances, health checks), tag-matched styles + theme, implied relationships, and the authored view kinds (animated filtered view, dynamic, deployment, custom). Round-trips through the Structurizr DSL exporter/importer.
demo-05-deployment-and-styles.c4.json — Demo 5 — C4 0.4.0 Structurizr parity: deployment environments (nodes, infrastructure, instances, health checks), tag-matched styles + theme, implied relationships, and the authored view kinds (animated filtered view, dynamic, deployment, custom). Round-trips through the Structurizr DSL exporter/importer. (expand for full JSON)
{ "kind": "c4-file", "schemaVersion": "0.4.0", "persons": [ { "kind": "person", "id": "admin", "name": "Platform Admin", "description": "Operates the deployment.", "tags": ["internal", "ops"] } ], "softwareSystems": [ { "kind": "software-system", "id": "orders", "name": "Orders Platform", "isScope": true, "description": "The system under design.", "tags": ["scope"] }, { "kind": "software-system", "id": "payments", "name": "Payments Provider", "description": "External PSP.", "tags": ["external"] } ], "containers": [ { "kind": "container", "id": "api", "name": "Orders API", "systemId": "orders", "technology": "NestJS", "technologyBucket": "api", "tags": ["service", "critical"] }, { "kind": "container-db", "id": "db", "name": "Orders DB", "systemId": "orders", "technology": "PostgreSQL 16", "technologyBucket": "database", "tags": ["data"] }, { "kind": "container", "id": "worker", "name": "Fulfilment Worker", "systemId": "orders", "technology": "BullMQ", "technologyBucket": "function", "tags": ["service"] } ], "components": [ { "kind": "component", "id": "pricing", "name": "Pricing Engine", "containerId": "api", "technology": "module" } ], "relationships": [ { "kind": "relationship", "id": "r1", "sourceId": "admin", "targetId": "api", "type": "uses", "protocol": "HTTPS", "tags": ["critical"], "properties": { "sla": "99.95%" }, "url": "https://docs.example.com/admin-api" }, { "kind": "relationship", "id": "r2", "sourceId": "api", "targetId": "payments", "type": "calls", "protocol": "HTTPS/REST", "description": "Charges cards.", "tags": ["critical"] }, { "kind": "relationship", "id": "r3", "sourceId": "pricing", "targetId": "db", "type": "reads-from", "protocol": "SQL" }, { "kind": "relationship", "id": "r4", "sourceId": "api", "targetId": "worker", "type": "publishes-event", "protocol": "BullMQ" } ], "invariants": [], "deploymentEnvironments": [ { "kind": "deployment-environment", "id": "env-production", "name": "Production", "description": "Customer-facing live estate.", "deploymentNodes": [ { "kind": "deployment-node", "id": "edge", "name": "Edge", "technology": "CDN", "children": [], "infrastructureNodes": [ { "kind": "infrastructure-node", "id": "lb", "name": "Load Balancer", "technology": "nginx", "tags": ["critical"] } ], "softwareSystemInstances": [], "containerInstances": [] }, { "kind": "deployment-node", "id": "cluster", "name": "App Cluster", "technology": "Kubernetes", "instances": 3, "children": [], "infrastructureNodes": [], "softwareSystemInstances": [ { "kind": "software-system-instance", "id": "orders-1", "softwareSystemId": "orders", "instanceNumber": 1, "healthChecks": [ { "id": "hc-orders", "name": "orders ping", "url": "https://orders.example.com/health", "interval": 30, "timeout": 5 } ] } ], "containerInstances": [ { "kind": "container-instance", "id": "api-1", "containerId": "api", "instanceNumber": 1, "deploymentGroups": ["eu"] }, { "kind": "container-instance", "id": "db-1", "containerId": "db", "instanceNumber": 1 } ] } ] } ], "styles": { "theme": "default", "elements": [ { "tag": "critical", "stroke": "#ef4444", "border": "dashed" }, { "tag": "data", "background": "#22c55e", "shape": "cylinder" } ], "relationships": [ { "tag": "critical", "color": "#ef4444", "thickness": 3, "style": "dashed" } ] }, "impliedRelationships": true, "views": [ { "kind": "view", "key": "services", "title": "Services only", "level": "container", "includeTags": ["service"], "animation": [ { "order": 1, "elementIds": ["api"] }, { "order": 2, "elementIds": ["worker"] } ] }, { "kind": "dynamic-view", "key": "charge-flow", "title": "Card charge flow", "scopeId": "orders", "steps": [ { "order": 1, "relationshipId": "r3" }, { "order": 2, "relationshipId": "r2" }, { "order": 3, "sourceId": "worker", "targetId": "db", "label": "persists results" } ] }, { "kind": "deployment-view", "key": "prod", "title": "Production estate", "environment": "Production", "isDefault": true }, { "kind": "custom-view", "key": "pricing-slice", "title": "Pricing slice", "elementIds": ["pricing", "db", "api"], "relationshipIds": ["r3"] } ]}What this model produces
Section titled “What this model produces”The c4 model is one of the richly-curated records — every downstream surface (CLI, MCP, docs, tests) reads from one record. The pasteable snippet below is the Door 1 anchor a downstream agent should see before touching this model.
- **C4 v0.5.0** — `models/c4.json`. Produces: Mermaid C4 diagrams, Structurizr DSL, C4-PlantUML, and a claude-md architecture section. Oracle: diagrams are generated, never hand-drawn — code-vs-diagram drift is a generation gap, not an opinion. Downstream: `ctxbrew semantics c4` · `ctxbrew://semantics/c4/v0.5.0` — read the record first.The full record (every door — anchor template, tool description hint, response annotations, behavior tripwire, and the complete produced-surface list) is served as JSON at:
- CLI —
ctxbrew semantics c4 --schema-version 0.5.0 - MCP —
ctxbrew://semantics/c4/v0.5.0 - HTTP —
https://contextbrew.dev/schemas/c4/v0.5/semantics.json
See the schemas overview for the versioning policy and how these files are generated and kept in sync.










