Diagrams for explaining software, written as code.
Documentation · Live playground · Examples · Changelog
Write a .layup file to describe your system, then render a self-contained
SVG, an interactive HTML page, or a JSON scene. Layup measures text with real
font metrics, arranges nodes, routes connections, and reports layout problems
with source locations. Use automatic placement or author the layout yourself.
The Rust engine also runs in JavaScript through WebAssembly.
Edit this diagram live · View its source
| Explain | Layup supports |
|---|---|
| Software structure | Architecture cards, containers, typed edges, shared models and named views |
| Control flow | Decision trees, process nodes, labeled branches and merges |
| Runtime behavior | State machines, composite states, cycles and sequence diagrams |
| Presentations | Slide sizing, progressive reveal, pan/zoom and interactive selection |
| International text | Four graph directions, LTR/RTL text, Unicode and system/user CJK fonts |
| Your workflow | CLI, Rust and JavaScript APIs, Markdown/VitePress, linting and formatting |
Layup 0.4 uses the named-diagram grammar shown below. Source files written for 0.3 need migration; see the language guide.
Try the playground to edit examples and download diagrams without installing anything. See the changelog for release history.
Install the CLI and render your first diagram
Install Rust stable and the CLI:
cargo install layup-cli --version 0.4.0 --locked
# Or install a supported prebuilt binary:
cargo binstall layup-cli --version 0.4.0The installed command is named layup. See the
release binaries and checksums
for Linux, macOS and Windows.
Save this as hello.layup:
diagram main "A request" type=graph layout=auto flow-direction=right {
node client "Client" style=process palette=blue
node api "API" style=process palette=green
node store "Storage" style=process palette=purple
::client -> ::api "Request"
::api -> ::store "Query"
}
layup render hello.layup --theme auto # hello.svg
layup render hello.layup --html --theme auto # hello.html, with pan/zoom
layup check hello.layup --strict # fail on layout warnings
layup lint hello.layup # source and authoring diagnostics
layup fmt hello.layup --check # check source formatting--theme auto follows the viewer's color scheme. Use --theme light or
--theme dark for a fixed palette. GitHub previews above use separate light
and dark SVGs so they follow the reader's theme too.
Continue with the DSL walkthrough and output formats.
Use the Rust/JavaScript APIs or run the docs locally
Install the JavaScript/WASM package, including its compiled engine:
pnpm add @hxyulin/layup@0.4.0
# Or: npm install @hxyulin/layup@0.4.0The API guide covers Rust, Node.js and browser WASM. The Markdown guide covers build-time diagrams and interactive VitePress integration.
For the local playground, use Rust stable, Node 22+, and the pnpm version pinned in package.json:
git clone https://github.com/hxyulin/layup.git
cd layup
rustup target add wasm32-unknown-unknown
pnpm install --frozen-lockfile
pnpm docs:dev # http://localhost:5173/layup/See CONTRIBUTING.md for repository setup and checks, and docs development for production previews and GitHub Pages deployment.
Bug reports, examples, documentation and implementation changes are welcome.
- CONTRIBUTING.md covers setup, validation, visual review and pull requests.
- For layout issues, include the
.layupsource, expected result and a screenshot. - The architecture guide introduces the engine.
- AGENTS.md records repository conventions for coding assistants.
Layup is available under either the MIT license or the Apache License 2.0, at your option.
- Bundled fonts use SIL OFL 1.1; see the font notes.
- CJK fonts come from the system or from the user.