A terminal-native diagram renderer and agent-native visual workspace for architecture workflows.
Diaview parses Mermaid flowcharts into an internal graph IR, lays them out with a pure-Rust topological engine, and renders 24-bit ANSI diagrams directly in your terminal, scrollback, or persistent interactive TUI.
Rendered from fixtures/temporal_payment_feedback_regression.mmd showing orthogonal routing, stencil icons, and perimeter return loops.
- Terminal-first, not a degraded web view: Built directly on Ratatui and Crossterm with truecolor 24-bit ANSI fills, borderless cards, and subtle character shadows. No Kitty graphics protocol hacks or raster browser embeds required.
- Agent-native feedback loop: Designed as a visual REPL for human and AI co-design. Point at nodes, dispatch instructions via Herdr, and watch the diagram update live in an adjacent pane.
- Pure Rust layout engine: Owns the entire pipeline from Mermaid parsing to coordinate ranking and orthogonal route planning. Zero external layout dependencies (no Graphviz, dagre, or node-canvas).
- Scrollback-friendly: Fullscreen interactive mode for deep inspection, plus
--inlineoutput that prints directly into terminal scrollback, tmux panes, and AI agent tool responses.
Build and run Diaview from source using Cargo:
Launch the persistent TUI viewer:
cargo run -- fixtures/temporal_payment_feedback_regression.mmdPrint ANSI-rendered diagrams directly into your terminal scrollback without entering alternate screen or raw mode:
cargo run -- --inline fixtures/temporal_payment_feedback_regression.mmdStream Mermaid directly through Diaview in shell pipelines:
cat fixtures/simple.mmd | cargo run -- --inlineDiaview provides keyboard-driven navigation and an integrated agent feedback loop.
| Key | Action |
|---|---|
Tab |
Select next node following visual diagram flow |
Shift+Tab / BackTab |
Select previous node |
q / Esc |
Quit Diaview |
The bottom status bar shows the currently selected node identifier, label, and available key hints. Selected cards are highlighted with a prominent blue fill. Routing dummy nodes are skipped automatically during navigation.
Diaview integrates natively with Herdr to enable an interactive co-design loop:
diaview --herdr diagram.mmd- Targeted prompts: Select any node and press
iorEnterto open the action bar. Type a natural language instruction (e.g., "Insert a Redis cache before this service"). - Agent dispatch: Pressing
Enterdispatches a context-rich instruction viaherdr agent prompt(including the selected node ID and label, diagram path, and user request). - Live file watching: Diaview enters a waiting state and monitors the Mermaid file. When the AI agent writes an updated diagram, Diaview automatically re-parses, re-lays out, and re-renders the diagram on the fly while preserving node selection.
- Resilient error handling: If the agent emits invalid intermediate Mermaid, Diaview preserves the last valid diagram on screen and reports the error in the status bar until corrected.
Diaview supports a focused, robust subset of Mermaid flowcharts optimized for system architecture:
- Directions:
flowchart TD,flowchart LR,graph TD,graph TB(normalized to top-down). - Node shapes:
- Rectangles:
A[API Gateway] - Rounded rectangles:
B(Service) - Decision diamonds:
C{WAF Allows?} - Circular nodes:
D((Client)) - Database cylinders:
E[(Postgres DB)]
- Rectangles:
- Edges & connectors:
- Solid arrows:
--> - Unlabeled solid links:
--- - Dashed arrows:
-.-> - Dashed links:
-.- - Thick arrows:
==> - Edge labels:
-->|text|and-- text -->
- Solid arrows:
- Subgraphs:
subgraph Title ... endrendered as background cluster boundaries. - Comments & formatting: Single-line comments starting with
%%and semicolon-separated statements.
For deeper technical documentation, see:
- docs/parser.md — Mermaid grammar, normalization, and parsing rules.
- docs/layout.md — Layering, barycenter crossing reduction, port assignment, and lane reservations.
- docs/rendering.md — Character grid rasterization, Ratatui canvas widgets, and ANSI truecolor styling.
- docs/interaction.md — AppState, event loop, visual-flow selection, Herdr sidecar, and status bar.
- docs/architecture.md — End-to-end component dataflow and module boundaries.
- docs/roadmap.md — Long-term milestones, sequence diagrams, and expanded Visual REPL capabilities.
Mermaid Source
│
▼
Parser (src/parser/mermaid.rs)
│
▼
Graph IR (src/model.rs)
│
▼
Layout Engine (src/layout/simple.rs)
├── Topological layering & barycenter ordering
├── Port assignment (top/bottom/side)
├── Orthogonal lane reservation & trunk bundling
└── Group cluster bounding
│
▼
Ratatui Canvas Renderer (src/renderer/canvas.rs)
├── Fullscreen TUI (event loop, Tab/Shift+Tab selection, status bar)
│ ├── Standalone browsing (q/Esc to quit)
│ └── Herdr sidecar (action bar, herdr agent prompt dispatch, file-poll reload)
└── Inline ANSI output (--inline; consumed by Pi extension for chat rendering)
Diaview requires Nerd Fonts v3 glyph support to render engineering stencil icons (database, bucket, queue, router, worker, shield, pulse, etc.).
Ensure your terminal emulator uses a patched Nerd Font (such as JetBrainsMono Nerd Font), or install Symbols Nerd Font Mono as a fallback font.
On macOS using Homebrew:
brew install --cask font-symbols-only-nerd-font# Validate formatting, types, and non-interactive tests
cargo fmt --check
cargo check
cargo test
# Inspect inline rendering on test fixtures
cargo run -- --inline fixtures/temporal_payment_feedback_regression.mmdRefer to docs/development.md and docs/testing.md for local workflows and non-interactive testing practices.
Diaview is dual-licensed under either:
- MIT License (LICENSE-MIT)
- Apache License, Version 2.0 (LICENSE-APACHE)
at your option.
