C4 diagrams and ADRs as code
Agents read everything. Humans read what matters.
Describe your C4 architecture in strict JSON, or design it with Claude. Get one self-contained HTML page of SVG diagrams, and architecture decision records linked to the model.
A model in 30 lines
{
"$schema": "../schema/c4.schema.json",
"version": 1,
"name": "Example",
"model": {
"people": [
{ "id": "user", "name": "User" }
],
"softwareSystems": [
{
"id": "app",
"name": "Application",
"containers": [
{ "id": "web", "name": "Web App", "description": "User interface", "technology": "React" },
{ "id": "api", "name": "API", "description": "Business logic", "technology": "Node.js" }
]
}
],
"relationships": [
{ "from": "user", "to": "web", "description": "Uses" },
{ "from": "web", "to": "api", "description": "Calls", "technology": "HTTPS/JSON" }
]
},
"views": [
{ "type": "systemContext", "key": "context", "scope": "app", "title": "Context" },
{ "type": "container", "key": "containers", "scope": "app", "title": "Containers" }
]
}The C4 model is the work of Simon Brown: see c4model.com. The JSON format borrows its concepts from Structurizr, also by Simon Brown. This project only implements them; read the original for the full method.
Highlights
Designed with Claude
A Claude Code plugin: design the model in a conversation, record its decisions, diff it against the code. See Claude Code plugin.
ADRs linked to the model
One Markdown file per decision, listing the element ids it concerns. Never edited, only superseded or deprecated. c4-drift flags those the model contradicts.
Strict schema
Closed objects and enums: an agent writes a valid model without guessing. Errors point to a JSON Pointer.
One model, every view
Declare elements and relationships once. Context, container, component and dynamic views are derived and never contradict each other.
One HTML file
Inline SVG, embedded font, no JavaScript, CSP default-src 'none'. Open it anywhere, commit it next to the code.
Readable without pixels
inspect lists what each view shows, so an agent checks its diagrams without seeing them.
Quick start
You need Node.js 24 or later.
With Claude Code
/plugin marketplace add deka/c4-architecture
/plugin install c4-architecture@c4-architecture
Then ask Claude "Let's design the architecture of an online shop", or run /c4-architecture:c4-design. See Claude Code plugin.
From the command line
git clone https://github.com/deka/c4-architecture.git
cd c4-architecture
npm install
node src/cli.ts render examples/online-banking.json diagrams.html
Open diagrams.html in a browser. See Command line.
Where to go next
- New to C4? Read The C4 model.
- Write your first model step by step in the Tutorial.
- Look up a field in the JSON schema reference.
- Record architecture decisions with
c4-adr. - Coming from Structurizr? See Compared to Structurizr.