Quickstart
Install archgram, write a spec, draw it and put the diagram in your README.
Draw your first diagram by hand. You install archgram, write a short spec, draw it and put it in your README. You need Node 22 or later.
If you would rather have your coding agent write the spec from your code, read Quickstart with your agent instead.
1. Install archgram#
In your project's folder, add archgram as a development dependency.
npm install --save-dev archgrampnpm add -D archgramyarn add -D archgramarchgram is one native binary for macOS, Linux and Windows. Your package manager installs the one for your machine, and nothing runs or downloads at install time.
Every command in these docs is shown for npm, pnpm and Yarn; pick yours over any block. In a sentence, a command is written as archgram check, and you run it the same way.
2. Write a spec#
A spec is a small file that says what your system is made of. Save this one as docs/diagrams/linkshort.archgram.yaml.
archgram: 1
title: linkshort
description: A visit goes through the API to Postgres.
nodes:
- { id: browser, kind: browser, label: Visitor }
- { id: api, kind: service, label: API, tech: fastapi }
- { id: db, kind: database, label: links, tech: postgresql }
edges:
- { from: browser, to: api }
- { from: api, to: db }
flows:
- { name: a visit, steps: [browser, api, db] }Each part of it says one thing.
| Key | What it says |
|---|---|
archgram | The version of the spec format. It is always 1 for now. |
title | The diagram's name. It becomes the SVG's title. |
description | The whole diagram in one or two sentences. Screen readers read it. |
nodes | The parts of the system. Each has an id, a kind that picks its icon, and a label. tech adds a logo, such as postgresql. |
edges | What calls or reads what, from one node to another. |
flows | The path a request takes, step by step. archgram animates it. |
3. Draw it#
npm exec -- archgram build docs/diagrams/linkshort.archgram.yamlpnpm exec archgram build docs/diagrams/linkshort.archgram.yamlyarn archgram build docs/diagrams/linkshort.archgram.yamlarchgram writes docs/diagrams/linkshort.svg beside the spec and says the size it drew and the direction it chose. This is the file you get.
If the spec has a mistake, archgram draws nothing and says where it is, at its line and column. A misspelt id or logo comes with the nearest one that exists.
docs/diagrams/linkshort.archgram.yaml:10:22: no node has the id `dbx`; did you mean `db`?4. Put it in your README#
The SVG is an ordinary image. Link it like one.
The flow plays inside the image, on GitHub, on npm and on any docs page, with no script. The file follows the reader's light or dark mode by itself.
GitHub lets each reader choose a theme that can differ from their system's. To follow GitHub's choice instead, draw one file for each theme and let the page pick.
npm exec -- archgram build docs/diagrams/linkshort.archgram.yaml --split-themespnpm exec archgram build docs/diagrams/linkshort.archgram.yaml --split-themesyarn archgram build docs/diagrams/linkshort.archgram.yaml --split-themesThat writes linkshort.light.svg and linkshort.dark.svg. Show them with a <picture>.
<picture>
<source media="(prefers-color-scheme: dark)" srcset="docs/diagrams/linkshort.dark.svg">
<img src="docs/diagrams/linkshort.light.svg" alt="A visit goes through the API to Postgres.">
</picture>5. Check it as the system changes#
Keep the spec in git beside the code. When the system changes, change the spec in the same pull request and draw it again. To check a spec without drawing it, run check.
npm exec -- archgram check docs/diagrams/linkshort.archgram.yamlpnpm exec archgram check docs/diagrams/linkshort.archgram.yamlyarn archgram check docs/diagrams/linkshort.archgram.yamlIt lists every problem at its line and column. When a part names the file behind it, check also tells you when that file or line is gone.
Next#
- Read every field a spec can hold in the spec format, or print its short part with
archgram spec --brief. - See every command and option in the CLI reference.
- Let your agent write the next spec. Quickstart with your agent.