Diagram Generator
Diagrams as compiled artifacts
Project brief
ShippedProblem
Architecture diagrams drift when they are redrawn by hand instead of compiled from structured relationships.
Outcome
A pipeline that compiles a JSON relationship dictionary deterministically into Mermaid and SVG, when the architecture changes, the diagram is regenerated, not redrawn.
Evidence
- The pipeline parses the rendered SVG back into geometry (node boxes, edge paths) and computes layout metrics like overlaps, density, and edge lengths, turning “does this diagram look good?” into regression-checkable numbers.
- A test-analyze-fix loop experiments in sandboxed runs and promotes a candidate only when its metrics pass.
- Dual channels and rule layers (July 2025) is the earlier context architecture behind keeping scaffolding out of the main thread.
Key decisions
- Source zone: The ARD JSON file is the only source of truth. Diagrams are never hand-edited.
- Build zone: Mermaid, SVG, and HTML exports come from one deterministic build, so diffs stay clean.
- Measure zone: Rendered SVG is parsed back into geometry, turning diagram quality into regression-checkable numbers.
- Optimization zone: A tester, analyzer, and fixer iterate in sandboxes. A candidate promotes only when its metrics pass.
Source to artifact
The first figure follows one architecture description from ARD JSON to a measured, exported diagram.
I built a pipeline that compiles a JSON relationship dictionary into Mermaid and SVG so diagrams regenerate when the architecture changes instead of being redrawn by hand.
The pipeline parses the rendered SVG back into geometry and computes layout metrics like overlaps, density, and edge lengths, turning layout quality into regression-checkable numbers.
A test-analyze-fix loop experiments in sandboxed runs and promotes a candidate only when its metrics pass.
Tri-agent optimization loop
The second shows the tri-agent loop that improves layout quality until it passes.
Deterministic slugs, ordering, and output paths mean generated diagrams diff cleanly and get reviewed like source.
Reviewed like source
A picture worth a thousand tokens is why diagrams became a default. The compiled artifacts feed Clear Diagrams and Terragram.
Tooling & discipline
Portfolio graph
Maps how the work here connects. Open the Portfolio graph →
- Professional
- Personal
- Skill
- Writing