Skip to content

Diagrist

Diagrams as code, checked like code.

Diagrist turns small text files (.dgr) into diagrams. The language is strict on purpose: every statement, argument and attribute is listed in a table, a check names what it found and what is allowed, and the same file always gives the same SVG, byte for byte. So a diagram can be reviewed, diffed and fixed like code, by people who keep diagrams next to their code in git and by coding agents.

Sign in Sequence diagram (UML) · Sign in Valid or invalid credentials alt [valid] [invalid] open() login(name, password) token error page User :App :AuthService
Sign in. Sequence diagram (UML) with 3 participants and 5 messages. Participants from left to right: User (actor), :App, :AuthService. 1. User calls :App: open(). 2. :App calls :AuthService: login(name, password). Alternative [valid]: 3. :AuthService replies to :App: token. Otherwise [invalid]: 4. :AuthService replies to :App: error. 5. :App replies to User: page.

Open in the editor ↗

Strict on purpose

A mistake is reported with its position, a stable code and what would be correct. Rules check the meaning too, such as a call that never gets a reply.

Same file, same picture

The output is deterministic down to the byte, so a picture only changes in a pull request when its source does.

Made for agents

The grammar of every kind and every finding come as JSON, and an agent skill tells an agent how to look things up, write, check and fix.

Stays on your machine

The command line runs locally. The live editor compiles in your browser and keeps the source in the address, so no diagram reaches a server.

The UML kinds are laid out by Diagrist itself. C4 diagrams place their elements in a named grid that the file declares, so the author decides what stands next to what; a flow numbers the steps of a path, and an adr explains a mark in a bar below the picture.

Bike rental Context diagram (C4 L1) · Bike rental System context, draft for discussion Riderrents by app, pays per minute Service crewmoves and repairs bikes Bike rentalapp, rides, billing Stationslocks and chargers Payment providercard and direct debit Map servicelocations and routes unlocks a bikeApp(1) opens the lock · MQTT(2) charges the rideHTTPS(3) reports battery levels · MQTT(4) plans jobs · App(5) shows free bikes · HTTPS E1 Decisions (marks in the picture) E1 Who controls the locks? The rental itself Lock logic and firmware stay in one hand. synchronous call asynchronous domain event (1)Flow ride (1) to (3) (4)Flow upkeep (4) to (5) core decision E1decision, see the bar
Bike rental. Context diagram (C4 L1) with 6 elements in 0 groups. Without group: Rider, Service crew, Bike rental, Stations, Payment provider, Map service. Flow ride: (1) Rider → Bike rental: unlocks a bike, App [synchronous] (2) Bike rental → Stations: opens the lock, MQTT [synchronous] (3) Bike rental → Payment provider: charges the ride, HTTPS [synchronous] Flow upkeep: (4) Stations → Bike rental: reports battery levels, MQTT [asynchronous] (5) Bike rental → Service crew: plans jobs, App [synchronous] Further edge: Bike rental → Map service: shows free bikes, HTTPS. E1 Who controls the locks? Chosen: The rental itself. Lock logic and firmware stay in one hand.

Open in the editor ↗

A mistake looks like this:

order.dgr:4:29 L105 error: `participant` has no attribute `stereotyp`. Allowed: `stereotype=`, `tone=`.
participant pay ":Payments" stereotyp="external"
^^^^^^^^^^^^^^^^^^^^