Write architecture diagrams in Python. Render with a Rust-powered engine. Get publication-ready SVG output, every time.
JSON IR works from Python, TypeScript, Kotlin, or any language. Write once, render anywhere.
Deterministic layout and rendering. Same input always produces the exact same output.
Clean, professional themes out of the box. No design work needed for presentation-ready diagrams.
# Just describe your architecture title: Web Service direction: LR Client >> Load Balancer >> API Server >> Database cluster AWS VPC { Load Balancer API Server Database }
from archflow import Diagram, Node, Cluster with Diagram("Web Service", direction="LR") as d: with Cluster("vpc", "AWS VPC"): web = Node("web", "Web Server") app = Node("app", "App Server") db = Node("db", "Database") web >> app >> db d.save_svg("output.svg")
Archflow is a Diagram-as-Code platform that turns code into beautiful architecture diagrams.
Write diagrams in a simple, readable syntax:
# Metadata
title: My Architecture
direction: LR
# Edges (use >> or ->)
Client >> API Gateway >> Auth Service
API Gateway >> User Service
# Edge with label
Auth Service >> Database : SQL queries
# Clusters (groups)
cluster Kubernetes {
API Gateway
Auth Service
User Service
}
cluster Storage {
Database
Redis
}
Nodes are automatically created when referenced in edges or clusters. Node IDs are generated from labels.
pip install archflow
from archflow import Diagram, Node, Cluster
with Diagram("My Service", direction="LR") as d:
with Cluster("vpc", "VPC"):
web = Node("web", "Web Server")
db = Node("db", "Database")
web >> db
d.save_svg("output.svg")
archflow render diagram.json -o output.svg
The core contract between any DSL and the rendering engine.
| Field | Type | Required | Description |
|---|---|---|---|
version | string | Yes | Schema version ("1.0.0") |
metadata.title | string | No | Diagram title |
metadata.direction | string | No | "TB" (top-bottom) or "LR" (left-right) |
metadata.theme | string | No | Theme name (default: "default") |
nodes[] | array | Yes | List of node definitions |
nodes[].id | string | Yes | Unique node identifier |
nodes[].label | string | Yes | Display label |
edges[] | array | Yes | List of edge definitions |
edges[].from | string | Yes | Source node ID |
edges[].to | string | Yes | Target node ID |
edges[].label | string | No | Edge label text |
clusters[] | array | No | List of cluster (group) definitions |
clusters[].id | string | Yes | Unique cluster identifier |
clusters[].label | string | Yes | Display label |
clusters[].children | string[] | Yes | List of child node/cluster IDs |
Any node, edge, or cluster can include an optional style object:
{
"style": {
"fill": "#FF6B6B",
"stroke": "#C92A2A",
"stroke_width": 2,
"stroke_dasharray": "5,5",
"font_color": "#FFFFFF"
}
}
Python DSL / TS DSL / Any Language
|
Diagram IR (JSON)
|
Rust Core Engine
+------+------+
| | |
Layout Theme Scene Graph
|
Renderer
+------+------+------+
| | | |
SVG PNG CLI WASM
|
React / Web