@diagram tool renders architecture, dependency, flow and ER diagrams to PNG, SVG or JPG from Graphviz DOT — with crisp, exactly-correct text, because the labels come from the layout engine, not from pixels a vision model guesses.
Graphviz is embedded: go-graphviz ships the upstream engine compiled to WebAssembly, run on the pure-Go wazero runtime. So it works with no cgo, no install and no network call — the same self-contained DNA as the embedded TTS/STT and the pure-Go voice notes. When a system Graphviz (dot) is on PATH, the backend uses it by default (backend=auto): rendering the same DOT through fontconfig + the OS fonts + cairo yields crisper, better-laid-out output. The embedded engine stays the fallback, so the tool never requires an install. See Rendering backend.
Usage
@diagram automatically when you ask for an architecture/dependency diagram as an image — it writes the DOT (models are good at DOT) and renders it here.
There are two subcommands: render (DOT → image) and gomod (real import graph of a Go module → image).
render subcommand
Renders DOT — inline (dot) or from a .dot file (file) — to an image.
Arguments
gomod subcommand
Builds the real import graph of a Go module (via go list -json ./...) and renders it, clustered by top-level directory — a 1:1, code-faithful dependency graph with no manual package enumeration.
Arguments
Output
Forrender and gomod (without dotOnly), the tool writes the file and returns a summary with path, format, size and — for raster — the dimensions:
dotOnly: true, gomod returns the DOT source itself (text), ready to edit or version.
Rendering backend
@diagram renders the same DOT through one of two engines. The generated DOT is identical — only who rasterizes it changes:
The embedded engine rasterizes with
gg/freetype (no cairo/pango), so its PNG/JPG comes out slightly softer than a native dot render. To minimize that, the embedded path uses bundled Go fonts with full hinting and picks the right family by name (proportional vs monospace, regular vs bold) — crisp, consistent text on every machine. A system dot uses fontconfig + the OS fonts + cairo, so it stays a touch more polished. Under auto, if a system dot render fails there is a transparent fallback to the embedded engine.
Configuration
Three ways, from broadest to most specific:- Environment variable
CHATCLI_DIAGRAM_BACKEND=auto|system|embedded(process-wide) - Argument
backendper call (overrides the env):{"dot":"...","backend":"system"} /config diagramshows the configured backend, the effective one (after resolvingauto) and whether adotis installed, with its version:
Notes
- Not read-only and not concurrency-safe: the tool writes a file (and
gomodshells out togo list), so it goes through the standard security confirmation and never joins a parallel read-only batch. - Truly embedded: Graphviz runs as WebAssembly via wazero — nothing to install, works offline on first use, on any OS/architecture. With a system
dotinstalled, theautobackend uses it automatically for crisper output (see Rendering backend). - Supported engines:
dot(hierarchical, default),neato/fdp/sfdp(force-directed),circo(circular),twopi(radial),osage/patchwork(clusters/treemap).