Building Block View
Level 1: Overall System
Motivation
At the centre sits a small core engine — model (the JSONC world), drawio (the XML world), and sync as the mediator between them, so changes to one format never leak into the other package. Around this core, a set of feature packages add analysis, evolution, interop, and styling, and a thin CLI layer (cmd/bausteinsicht) wires commands to them. A second binary (cmd/bausteinsicht-lsp) reuses the same library code to serve editors over the Language Server Protocol.
In total the system is two binaries over ~23 production packages (plus three test-only helper packages). The complete map is in the Package Map below; the core engine and the CLI layer are decomposed further in the Level 2 sections.
Building Blocks (core)
| Element | Kind | Technology | Description |
|---|---|---|---|
Changelog |
container |
Go |
Architecture changelog generation between two git refs |
CLI |
container |
Go / Cobra |
Command-line interface providing validate, sync, export, and watch commands |
Constraints |
container |
Go |
Validation constraints for model linting and consistency checking |
Diagram |
container |
Go |
Text-based diagram export to Mermaid C4 and PlantUML formats with markdown wrapping |
Diff |
container |
Go |
As-is vs. to-be architecture comparison |
draw.io |
container |
Go / etree |
draw.io XML document handling — elements, connectors, templates, and labels |
Export |
container |
Go |
Export diagrams to PNG, SVG, and other visual formats via draw.io CLI |
Exporter |
container |
Go |
Architecture export to Structurizr DSL and other formats |
Graph |
container |
Go |
Relationship graph analysis — cycle detection and dependency depth |
Health |
container |
Go |
Architecture health scoring — completeness, conformance, and complexity |
Importer |
container |
Go |
Import architecture from Structurizr DSL, LikeC4, and XMI/Enterprise Architect formats |
Layout |
container |
Go |
Auto-layout algorithms for positioning elements in draw.io diagrams |
Language Server |
container |
Go |
Language Server Protocol implementation for VS Code and other editors |
Model |
container |
Go |
JSONC architecture model management — loading, validation, and mutation |
Overlay |
container |
Go |
Metric heatmap overlay application and removal on draw.io diagrams |
Schema |
container |
Go |
JSON Schema generation from Go model types for IDE autocompletion |
Search |
container |
Go |
Element and relationship search with filtering and pattern matching |
Snapshot |
container |
Go |
Versioned architecture snapshot storage and restore |
Stale |
container |
Go |
Detects unused or forgotten architecture elements via git history and ADR/status metadata |
Sync Engine |
container |
Go |
Bidirectional synchronization engine between JSONC model and draw.io diagrams |
Table |
container |
Go |
Export architecture to CSV and Markdown table formats |
Template |
container |
Go |
draw.io template generation from element specification (shapes, layout) |
Watcher |
container |
Go / fsnotify |
File system monitoring for automatic sync on model or diagram changes |
Workspace |
container |
Go |
Multi-model workspace configuration loading and merging |
Developer |
actor |
Developer using the Bausteinsicht CLI to manage architecture models |
|
draw.io App |
external_system |
draw.io desktop or web application for visual diagram editing |
|
IDE |
external_system |
IDE with JSON Schema support for JSONC editing with autocompletion |
Important Interfaces
| Interface | Description |
|---|---|
|
Parses a JSONC file into the Go model struct. Validates against schema constraints. |
|
Writes the model back to JSONC, preserving comments where possible. |
|
Parses a draw.io XML file into a manipulable document structure. |
|
Writes the document back to uncompressed draw.io XML. |
|
Reads a template file and extracts styles keyed by |
|
Executes one full bidirectional sync cycle — a pure function with no I/O. |
|
Reads the |
|
Writes the updated sync state after successful sync. |
Package Map (all building blocks)
Every production package, grouped by role. Each row is a Level-1 building block: its responsibility and its source location. The core engine (model, drawio, sync) and the CLI layer (cli) are decomposed further in the Level 2 sections below.
| Package | Responsibility | Source |
|---|---|---|
|
DSL types, JSONC loader (comment-preserving patch + full save), validation, ID/wildcard resolution |
|
|
Read/write draw.io XML: document, element, connector, template, HTML label |
|
|
Bidirectional sync: diff, forward/reverse apply, conflict resolution, state, layout, badges, metadata |
|
|
fsnotify file watcher driving |
|
| Package | Responsibility | Source |
|---|---|---|
|
Evaluate architectural rules from the model ( |
|
|
Relationship-graph analysis: cycles, dependency depth, centrality ( |
|
|
Architecture health score across weighted categories ( |
|
|
Detect unused/forgotten elements, using git history ( |
|
|
Full-text search over elements, relationships, views ( |
|
|
Group, merge, and validate multiple models together as one workspace ( |
|
| Package | Responsibility | Source |
|---|---|---|
|
Versioned model captures, semantically diffable ( |
|
|
As-is vs. to-be model comparison ( |
|
|
Architecture changelog between two git points ( |
|
| Package | Responsibility | Source |
|---|---|---|
|
Hierarchical auto-layout engine ( |
|
|
Generate a draw.io template from the specification ( |
|
|
Apply/remove metric heatmap overlays on diagrams ( |
|
| Package | Responsibility | Source |
|---|---|---|
|
Import models from Structurizr DSL, LikeC4, and XMI/Enterprise Architect ( |
|
|
Export the model as Structurizr DSL |
|
|
Render views as text diagrams: C4-PlantUML, Mermaid, DOT, D2, HTML, sequence ( |
|
|
Render element attributes as AsciiDoc/Markdown tables ( |
|
|
Export diagram pages to PNG/SVG via headless draw.io ( |
|
|
Generate the JSON Schema from the Go model types ( |
|
| Package | Responsibility | Source |
|---|---|---|
|
Language Server Protocol server: diagnostics, code lenses; backs the |
|
|
Note
|
internal/chaos (fault-injection helper), internal/benchmarks, and internal/e2eplan (the e2e-test-plan report generator’s plan-ID registry, see #519) are test-only utilities, not production building blocks.
|
Container View by Domain
The full Container View above packs all ~24 containers and their relationships onto one page — accurate, but dense enough to be hard to read at the level of individual boxes and connector labels (#604). Two containers sit at the centre of nearly every relationship: cli (the entry point every command wires through) and model (the data structure nearly every package reads or writes) — a hub-and-spoke shape no simple grouping fully untangles. The four views below group the remaining containers by functional domain, each alongside cli and model for context, trading one complete picture for four legible ones.
Level 2: Sync Core Containers
The bidirectional sync loop: CLI, model, drawio, sync engine, watcher, and template resolution.
Building Blocks
| Element | Kind | Technology | Description |
|---|---|---|---|
CLI |
container |
Go / Cobra |
Command-line interface providing validate, sync, export, and watch commands |
draw.io |
container |
Go / etree |
draw.io XML document handling — elements, connectors, templates, and labels |
Model |
container |
Go |
JSONC architecture model management — loading, validation, and mutation |
Sync Engine |
container |
Go |
Bidirectional synchronization engine between JSONC model and draw.io diagrams |
Template |
container |
Go |
draw.io template generation from element specification (shapes, layout) |
Watcher |
container |
Go / fsnotify |
File system monitoring for automatic sync on model or diagram changes |
Level 2: Export & Import Containers
Containers reading and writing external formats: images, DSLs, text diagrams, tables, and the language server.
Building Blocks
| Element | Kind | Technology | Description |
|---|---|---|---|
CLI |
container |
Go / Cobra |
Command-line interface providing validate, sync, export, and watch commands |
Diagram |
container |
Go |
Text-based diagram export to Mermaid C4 and PlantUML formats with markdown wrapping |
Export |
container |
Go |
Export diagrams to PNG, SVG, and other visual formats via draw.io CLI |
Exporter |
container |
Go |
Architecture export to Structurizr DSL and other formats |
Importer |
container |
Go |
Import architecture from Structurizr DSL, LikeC4, and XMI/Enterprise Architect formats |
Language Server |
container |
Go |
Language Server Protocol implementation for VS Code and other editors |
Model |
container |
Go |
JSONC architecture model management — loading, validation, and mutation |
Table |
container |
Go |
Export architecture to CSV and Markdown table formats |
Level 2: Analysis & Governance Containers
Read-only architecture-quality containers: dependency graph analysis, health scoring, stale-element detection, constraint linting, search, and metric overlays.
Building Blocks
| Element | Kind | Technology | Description |
|---|---|---|---|
CLI |
container |
Go / Cobra |
Command-line interface providing validate, sync, export, and watch commands |
Constraints |
container |
Go |
Validation constraints for model linting and consistency checking |
Graph |
container |
Go |
Relationship graph analysis — cycle detection and dependency depth |
Health |
container |
Go |
Architecture health scoring — completeness, conformance, and complexity |
Model |
container |
Go |
JSONC architecture model management — loading, validation, and mutation |
Overlay |
container |
Go |
Metric heatmap overlay application and removal on draw.io diagrams |
Search |
container |
Go |
Element and relationship search with filtering and pattern matching |
Stale |
container |
Go |
Detects unused or forgotten architecture elements via git history and ADR/status metadata |
Level 2: Evolution & Tooling Containers
Versioning and tooling containers: changelog, as-is/to-be diff, snapshots, multi-model workspaces, JSON Schema generation, and auto-layout.
Building Blocks
| Element | Kind | Technology | Description |
|---|---|---|---|
Changelog |
container |
Go |
Architecture changelog generation between two git refs |
CLI |
container |
Go / Cobra |
Command-line interface providing validate, sync, export, and watch commands |
Diff |
container |
Go |
As-is vs. to-be architecture comparison |
Layout |
container |
Go |
Auto-layout algorithms for positioning elements in draw.io diagrams |
Model |
container |
Go |
JSONC architecture model management — loading, validation, and mutation |
Schema |
container |
Go |
JSON Schema generation from Go model types for IDE autocompletion |
Snapshot |
container |
Go |
Versioned architecture snapshot storage and restore |
Workspace |
container |
Go |
Multi-model workspace configuration loading and merging |
Level 2: Sync Engine
The sync engine is the most complex package. It decomposes into five sub-components.
Building Blocks
| Element | Kind | Technology | Description |
|---|---|---|---|
CLI |
container |
Go / Cobra |
Command-line interface providing validate, sync, export, and watch commands |
draw.io |
container |
Go / etree |
draw.io XML document handling — elements, connectors, templates, and labels |
Model |
container |
Go |
JSONC architecture model management — loading, validation, and mutation |
Conflict |
component |
Go |
Conflict detection and resolution when both model and diagram changed |
Diff |
component |
Go |
Three-way change detection comparing model, diagram, and last-sync state |
Engine |
component |
Go |
Main sync orchestrator coordinating diff, forward, reverse, and conflict resolution |
Forward Sync |
component |
Go |
Applies model changes to draw.io diagrams (model → drawio) |
Reverse Sync |
component |
Go |
Applies draw.io changes back to the JSONC model (drawio → model) |
State |
component |
Go |
Sync state persistence using SHA256 hashes for change detection |
Watcher |
container |
Go / fsnotify |
File system monitoring for automatic sync on model or diagram changes |
Level 2: DrawIO Package
The draw.io package handles all mxGraph XML concerns.
Building Blocks
| Element | Kind | Technology | Description |
|---|---|---|---|
Connector |
component |
Go |
Connector/relationship CRUD for edges between elements |
Document |
component |
Go |
XML parsing, page management, and file I/O for .drawio files |
Element |
component |
Go |
Element CRUD operations on mxGraphModel objects and mxCells |
Label |
component |
Go |
HTML label generation and parsing for element display text |
Template |
component |
Go |
Template loading and style lookup from .drawio template files |
Export |
container |
Go |
Export diagrams to PNG, SVG, and other visual formats via draw.io CLI |
Sync Engine |
container |
Go |
Bidirectional synchronization engine between JSONC model and draw.io diagrams |
draw.io App |
external_system |
draw.io desktop or web application for visual diagram editing |
Level 2: Model Package
Building Blocks
| Element | Kind | Technology | Description |
|---|---|---|---|
CLI |
container |
Go / Cobra |
Command-line interface providing validate, sync, export, and watch commands |
Loader |
component |
Go |
JSONC read/write with comment stripping and trailing comma handling |
Patch |
component |
Go |
Comment-preserving JSONC mutations for reverse sync |
Resolve |
component |
Go |
Dot-notation element resolution and wildcard pattern matching |
Types |
component |
Go |
Core struct definitions for elements, relationships, views, and specification |
Validate |
component |
Go |
Model validation rules for elements, relationships, and views |
Sync Engine |
container |
Go |
Bidirectional synchronization engine between JSONC model and draw.io diagrams |
IDE |
external_system |
IDE with JSON Schema support for JSONC editing with autocompletion |
Level 2: CLI Package
The CLI is the thinnest layer (no business logic — see Conventions below), but at 41 files across ~15 subcommands it’s grouped into 7 components by concern rather than one component per file, for the same reason `model’s 7 files map to 5 components above: file-level granularity would be noise at this diagram’s zoom level.
Building Blocks
| Element | Kind | Technology | Description |
|---|---|---|---|
Add |
component |
Go |
Add element/relationship/view/specification/pattern subcommands |
Analysis |
component |
Go |
find, show, status, stale, health, graph, and lint subcommands |
Core |
component |
Go |
Root command wiring, init, sync, validate, watch, and template resolution |
Evolution |
component |
Go |
snapshot (save/list/diff/restore/delete), diff, and changelog subcommands |
Export Commands |
component |
Go |
export, export-diagram, export-table, and export-sequence subcommands |
Interactive |
component |
Go |
repl, overlay, and adr subcommands |
Tooling |
component |
Go |
import, generate-template, layout, schema, and workspace subcommands |
Model |
container |
Go |
JSONC architecture model management — loading, validation, and mutation |
Sync Engine |
container |
Go |
Bidirectional synchronization engine between JSONC model and draw.io diagrams |
Watcher |
container |
Go / fsnotify |
File system monitoring for automatic sync on model or diagram changes |
Level 2: Diagram Package Components
Text-based diagram export components (Mermaid C4, PlantUML) and markdown wrapping.
Building Blocks
| Element | Kind | Technology | Description |
|---|---|---|---|
CLI |
container |
Go / Cobra |
Command-line interface providing validate, sync, export, and watch commands |
Markdown |
component |
Go |
Markdown document wrapper for multiple diagram pages |
Mermaid C4 |
component |
Go |
Mermaid C4 diagram generation with C4 level detection |
Model |
container |
Go |
JSONC architecture model management — loading, validation, and mutation |
Level 2: Importer Package Components
Import components for Structurizr DSL and LikeC4 format conversion to Bausteinsicht model.
Building Blocks
| Element | Kind | Technology | Description |
|---|---|---|---|
CLI |
container |
Go / Cobra |
Command-line interface providing validate, sync, export, and watch commands |
LikeC4 |
component |
Go |
LikeC4 DSL parsing and model conversion |
Structurizr |
component |
Go |
Structurizr DSL parsing and model conversion |
XMI |
component |
Go |
XMI/Enterprise Architect parsing and model conversion. Buffers the whole file in memory and converts Windows-1252 to UTF-8 before parsing (peak RSS ~2x file size); a 200MB read cap is enforced. |
Model |
container |
Go |
JSONC architecture model management — loading, validation, and mutation |
Level 2: Exporter Package Components
Export components for converting Bausteinsicht model to external formats (Structurizr DSL).
Building Blocks
| Element | Kind | Technology | Description |
|---|---|---|---|
CLI |
container |
Go / Cobra |
Command-line interface providing validate, sync, export, and watch commands |
Structurizr |
component |
Go |
Structurizr DSL export with smart variable naming |
Model |
container |
Go |
JSONC architecture model management — loading, validation, and mutation |
Level 2: Search Package Components
Element and relationship search with pattern matching and filtering.
Building Blocks
| Element | Kind | Technology | Description |
|---|---|---|---|
CLI |
container |
Go / Cobra |
Command-line interface providing validate, sync, export, and watch commands |
Model |
container |
Go |
JSONC architecture model management — loading, validation, and mutation |
Search |
container |
Go |
Element and relationship search with filtering and pattern matching |
Go Package Layout
The directory structure maps directly to the building blocks above (packages, not every file):
bausteinsicht/ ├── cmd/ │ ├── bausteinsicht/ // main CLI — one file per command (init, sync, add, repl, export*, …) │ └── bausteinsicht-lsp/ // Language Server Protocol binary ├── internal/ │ ├── model/ drawio/ sync/ watcher/ // core engine │ ├── constraints/ graph/ health/ stale/ search/ // analysis │ ├── snapshot/ diff/ changelog/ // evolution │ ├── layout/ template/ overlay/ // layout & styling │ ├── importer/ exporter/ diagram/ table/ export/ schema/ // interop & export │ ├── lsp/ // IDE integration │ └── chaos/ benchmarks/ e2eplan/ // test-only helpers ├── go.mod └── go.sum
Conventions
-
cmd/bausteinsicht/contains only CLI wiring — no business logic; all logic lives ininternal/packages (so the LSP binary can reuse it). -
internal/ensures packages cannot be imported by external code. -
Each package has a clear single responsibility (see the Package Map).
-
Cross-package dependencies flow inward toward the core:
cmd → feature packages → sync → model + drawio. -
The
modelanddrawiopackages never depend on each other —syncis the only mediator. -
chaosandbenchmarksare imported only from_test.gofiles, so production code never depends on them.e2eplanis imported by the standalonescripts/e2e-test-report-gentool (not a_test.gofile, but also not shipped in thebausteinsicht/bausteinsicht-lspbinaries).
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.