mkdir my-architecture && cd my-architecture
bausteinsicht init
bausteinsicht sync
Bausteinsicht User Manual
Bausteinsicht is an architecture-as-code tool that keeps a JSONC model and draw.io diagrams in bidirectional sync. You define your architecture in a text file, and Bausteinsicht generates and updates visual diagrams automatically.
Installation
See Installation: download a release for Linux, macOS or Windows, put it on your PATH, and install draw.io to open the diagrams. Go is only needed to build from source.
Quick Start
New words are explained in the glossary; what sync does with a change on either side is in How sync works.
This creates a sample Online Shop architecture with three views.
Open architecture.drawio in draw.io to see the generated diagrams.
The model, its diagram (architecture.drawio) and its sync state (.bausteinsicht-sync) form one unit: use one model per directory. Several perspectives on one architecture are views (one page per view), not several models. If a directory has to hold more models, give each its own files: bausteinsicht sync --model a.jsonc --drawio a.drawio --sync-state a.state. The sync state remembers its model; syncing another model against it fails with a message that names the two flags.
For a detailed walkthrough, see the Getting Started Tutorial or the online tutorial.
Daily Workflow
The typical workflow alternates between editing the model and arranging diagrams:
┌─────────────────┐ sync ┌─────────────────┐ │ architecture │ ───────────► │ architecture │ │ .jsonc │ ◄─────────── │ .drawio │ │ (text editor) │ │ (draw.io) │ └─────────────────┘ └─────────────────┘
Forward Sync (Model → Diagram)
-
Edit
architecture.jsoncin your text editor -
Run
bausteinsicht sync -
Reload the
.drawiofile — new elements appear with a red dashed border -
Drag elements to arrange the layout, then save
Reverse Sync (Diagram → Model)
-
Open
architecture.drawioin draw.io -
Edit element text — each element contains child text cells for title, technology, and description that can be edited independently
-
Save the
.drawiofile -
Run
bausteinsicht sync -
Check
architecture.jsonc— your changes are reflected
Watch Mode
For continuous synchronization while you work:
bausteinsicht watch
Bausteinsicht watches both files and syncs automatically on save. Press Ctrl+C to stop.
The Architecture Model
The model file (architecture.jsonc) is a JSONC file with four sections.
Specification
Defines the element kinds and relationship kinds available in your model. This is like a vocabulary for your architecture:
"specification": {
"elements": {
"actor": { "notation": "Actor", "description": "A person or external system" },
"system": { "notation": "Software System", "container": true },
"container": { "notation": "Container", "container": true },
"component": { "notation": "Component", "container": true }
},
"relationships": {
"uses": { "notation": "uses" },
"async": { "notation": "async", "dashed": true }
}
}
Set container: true for kinds that can hold children.
Model
Defines your architecture elements in a hierarchy. Element keys are unique IDs, children nest naturally:
"model": {
"customer": {
"kind": "actor",
"title": "Customer",
"description": "End user of the webshop"
},
"webshop": {
"kind": "system",
"title": "Webshop",
"children": {
"api": {
"kind": "container",
"title": "REST API",
"technology": "Go"
}
}
}
}
Nested elements are referenced with dot notation: webshop.api.
Relationships
Connections between elements:
"relationships": [
{
"from": "customer",
"to": "webshop.api",
"label": "uses",
"kind": "uses",
"description": "Sends HTTP requests"
}
]
Views
Views define which elements appear on each diagram page. See Multi-View Architecture for details.
Adding Elements and Relationships
Via Text Editor
Edit architecture.jsonc directly, then run bausteinsicht sync.
Via CLI
Add elements without editing JSON:
bausteinsicht add element \
--id emailservice \
--kind container \
--title "Email Service" \
--technology "Go" \
--parent onlineshop \
--description "Sends transactional emails"
Add relationships:
bausteinsicht add relationship \
--from onlineshop.api \
--to onlineshop.emailservice \
--label "sends emails" \
--kind uses
After adding, run bausteinsicht sync to update the diagram.
Multi-View Architecture
Views control which elements appear on each diagram page. Each view becomes a tab in the draw.io file.
Basic View
A simple view lists elements to include:
"context": {
"title": "System Context",
"include": ["customer", "webshop"]
}
Wildcard Includes
Use .* to include all direct children of an element:
"containers": {
"title": "Container View",
"include": ["customer", "webshop.*"]
}
webshop.* matches webshop.api, webshop.frontend, webshop.db — but not webshop itself.
Scope and Bounding Boxes
The scope property renders the parent element as a visual boundary (swimlane) with its children nested inside:
"containers": {
"title": "Container View",
"scope": "webshop",
"include": ["customer", "webshop.*"]
}
This renders webshop as a labeled box containing its children, with customer outside as an external actor.
Exclude
Remove specific elements from a view:
"overview": {
"title": "Overview",
"include": ["webshop.*"],
"exclude": ["webshop.db"]
}
Relationship Lifting
When a relationship endpoint is not on a view page but its parent is, the connector is automatically "lifted" to the parent.
Example: the model has customer → webshop.frontend, but the System Context view only includes customer and webshop. Bausteinsicht renders this as customer → webshop on the context page.
This happens automatically — no configuration needed.
Landscape from several models
Every team keeps its own model in its own directory (one model per directory: model, diagram and sync state belong together). A workspace puts the models of several teams side by side in one landscape without copying them.
You write one configuration file, landscape.jsonc, next to the team directories:
{
"workspace": { "name": "Landscape" },
"models": [
// team A: the whole model, its elements get the prefix team_a
{ "id": "team_a", "path": "team-a/architecture.jsonc" },
// team B: only the system "onlineshop", as a black box (depth 1)
{ "id": "team_b", "path": "team-b/architecture.jsonc", "prefix": "b", "elements": ["onlineshop"], "depth": 1 }
],
"crossModelRelationships": [
{ "id": "buys", "from": "team_a:customer", "to": "team_b:onlineshop", "label": "buys from", "kind": "uses" }
],
"views": {
"landscape": { "title": "Landscape", "include-from": ["team_a", "team_b"], "include-kinds": ["actor", "system"] }
}
}
-
pathpoints at a model file, relative to the configuration.prefix(default: theid) is put in front of the element IDs of that model in the merged model, socustomerof team A becomesteam_a_customerandonlineshopof team B becomesb_onlineshop. -
elementsanddepthimport only part of a model: the listed top-level elements, each cut off atdepth(1is the element alone, a black box). A partly imported model brings neither its views nor its constraints. -
crossModelRelationshipsconnect elements of different models, written as<model id>:<element>. -
viewsselect elements from several models (include-from,include-kinds,exclude-kinds); they become ordinary views of the merged model.
The configuration is JSONC like the models. A key that does not exist (a typo such as depthh) is reported by workspace validate. Point $schema at schemas/bausteinsicht-workspace.schema.json and the editor completes the keys.
Check the configuration and write the merged model:
bausteinsicht workspace validate landscape.jsonc
bausteinsicht workspace list landscape.jsonc
bausteinsicht workspace merge landscape.jsonc landscape-model.jsonc
validate checks every model and what the models cannot check alone: duplicate IDs or prefixes, cross-model relationships to elements that do not exist, and workspace views. merge refuses to replace an existing output file unless you give --force, and it never overwrites the configuration, its lock file or the input models. The merged model is an ordinary model: bausteinsicht validate --model landscape-model.jsonc, sync and the exports work on it (keep it in a directory of its own, because of "one model per directory", or give it its own --drawio and --sync-state).
Models from other repositories
Two ways to use a model that lives in another repository:
-
Check it out (for example as a git submodule or a CI step) and point
pathat the checkout. No network access by the tool. -
Remote source. A model reference with
sourceinstead ofpathis anhttpsURL of a model file, pinned by a tag or a commit in the URL. Remote sources are off until you list the host inworkspace.allowedHosts:{ "workspace": { "name": "Landscape", "allowedHosts": ["raw.githubusercontent.com"] }, "models": [ { "id": "billing", "source": "https://raw.githubusercontent.com/acme/billing/v1.4.0/architecture.jsonc" } ] }bausteinsicht workspace fetch landscape.jsoncis the only command that uses the network. It downloads the file into.bausteinsicht-cache/(git-ignored by its own.gitignore) and records its SHA-256 inbausteinsicht.lock. Commit the lock file.validate,listandmergeread the cache and verify the hash; nothing is fetched implicitly, and a missing cache or lock entry tells you to runworkspace fetch. If the content at the URL changes, the hash no longer matches and the command fails until you accept the change withworkspace fetch --update. A URL that names a branch (main) is accepted but warned about: the hash is the real pin, a tag or commit makes the pin visible.
The tool refuses private, loopback and link-local addresses, redirects and credentials in the URL. A token for a private host is read only from the environment variable BAUSTEINSICHT_FETCH_TOKEN_<HOST>, never from a file. See the CLI Specification ("workspace") for all rules.
Template Customization
Templates control the visual style of elements in draw.io.
Template File Structure
The template (template.drawio) is a draw.io file with sample elements tagged via bausteinsicht_template:
-
Element templates:
bausteinsicht_template="actor","system","container","component" -
Boundary templates:
bausteinsicht_template="system_boundary","container_boundary" -
Connector template:
bausteinsicht_template="relationship"
Customizing Styles
-
Open
template.drawioin draw.io -
Modify colors, fonts, shapes, sizes of the template elements
-
Save the file
-
Run
bausteinsicht sync— new elements use the updated styles
Existing elements keep their current style. Only newly created elements pick up template changes.
Template Properties Used
From each template element, Bausteinsicht extracts:
-
style — the full mxCell style string (must include
container=1;) -
width and height — default dimensions from mxGeometry
-
sub-cell styles — font size, color, weight, and vertical position for title, technology, and description text cells (from child
<mxCell>elements with-title,-tech,-descID suffixes)
Validation
Check your model for errors before syncing:
bausteinsicht validate
Output: Model is valid. or a list of errors.
For machine-readable output:
bausteinsicht validate --format json
{
"valid": true,
"errors": []
}
LLM Integration
Bausteinsicht is designed for AI-assisted architecture work.
All commands support --format json for machine-readable output.
AI Agent Workflow
An LLM can drive architecture changes entirely through CLI commands:
# Add elements
bausteinsicht add element --id cache --kind container \
--title "Cache" --technology "Redis" --parent webshop --format json
# Add relationships
bausteinsicht add relationship --from webshop.api --to webshop.cache \
--label "caches" --kind uses --format json
# Sync and verify
bausteinsicht sync --format json
bausteinsicht validate --format json
JSON Schema Support
The model file references a JSON Schema for IDE autocompletion and validation:
{
"$schema": "https://raw.githubusercontent.com/docToolchain/Bausteinsicht/main/schemas/bausteinsicht.schema.json",
...
}
This enables autocompletion in VS Code, IntelliJ, and other editors without plugins.
Troubleshooting
See Troubleshooting: the problems a newcomer meets first (command not found, no model file, syntax error, draw.io shows nothing, the red dashed border), then sync conflicts, files, export and performance. How sync works explains what sync does for a change on each side.
Headless export (Linux, containers, CI, WSL2) is described in Troubleshooting.
Exporting Diagrams
Export views as PNG or SVG images for embedding in documentation:
bausteinsicht export --image-format png
bausteinsicht export --image-format svg --view context
bausteinsicht export --image-format png --scale 2.0 --output ./images/
Export as text-based diagrams:
bausteinsicht export-diagram --diagram-format plantuml
bausteinsicht export-diagram --diagram-format mermaid
Export element tables:
bausteinsicht export-table --table-format adoc --output elements.adoc
bausteinsicht export-table --table-format markdown
Sequence Diagrams (Dynamic Views)
Dynamic views describe the runtime behaviour of your system as ordered message sequences.
Define them in the dynamicViews array of your model file and export them as PlantUML or Mermaid source:
"dynamicViews": [
{
"key": "checkout-flow",
"title": "Checkout Flow",
"steps": [
{ "index": 1, "from": "customer", "to": "webshop.api", "label": "POST /orders", "type": "sync" },
{ "index": 2, "from": "webshop.api", "to": "webshop.db", "label": "persist order", "type": "sync" },
{ "index": 3, "from": "webshop.api", "to": "customer", "label": "201 Created", "type": "return" }
]
}
]
# Export all dynamic views as PlantUML to stdout
bausteinsicht export-sequence
# Write PlantUML files to a directory
bausteinsicht export-sequence --output docs/sequences
# Export one view as Mermaid
bausteinsicht export-sequence --view checkout-flow --diagram-format mermaid
# Machine-readable JSON output (for LLM/CI use)
bausteinsicht export-sequence --format json
Step types control the arrow style in the diagram:
| Type | Meaning |
|---|---|
|
Synchronous call — solid arrow |
|
Response — dashed arrow |
|
Fire-and-forget — async arrow |
|
Note
|
Image export requires the draw.io Desktop CLI.
In containers, the drawio-export wrapper handles headless rendering via xvfb.
See Troubleshooting for common export issues.
|
Command Reference
See the CLI Specification for full command details.
| Command | Description |
|---|---|
|
Initialize a new project with sample model and template |
|
Run one bidirectional sync cycle |
|
Validate model without syncing |
|
Continuously sync on file changes |
|
Add element to model |
|
Add relationship to model |
|
Combine the models of several teams into one landscape ( |
|
Export views as PNG/SVG images |
|
Export views as PlantUML or Mermaid C4 diagrams |
|
Export element list as AsciiDoc or Markdown table |
|
Export dynamic views as PlantUML or Mermaid sequence diagrams |
|
Display version number |
Global Flags
| Flag | Description |
|---|---|
|
Output format (default: text) |
|
Path to model file (default: auto-detect) |
|
Path to template file |
|
Enable debug output |
Further Reading
-
Online Tutorial — hands-on walkthrough (paul-fleischmann.com)
-
Data Models — JSONC structure, draw.io XML format, Go structs
-
Sync Specification — three-way sync algorithm details
-
Getting Started Tutorial — step-by-step walkthrough
Feedback
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.