This is the full developer documentation for Diagrist # 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. * Picture 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. * Source sign-in.dgr ```dgr # A user signs in: the app asks the auth service, which answers with a token or an error. diagram sequence "Sign in" subtitle="Valid or invalid credentials" actor user "User" participant app ":App" participant auth ":AuthService" msg user -> app "open()" msg app -> auth "login(name, password)" alt "valid" msg auth --> app "token" else "invalid" msg auth --> app "error" msg app --> user "page" ``` [Open in the editor ↗](https://live.diagrist.com/#v1:bZBBasQwDEX3PoVQNzMw6QECHcgZhnavJiIRk8iu5EyuX2xPoZTupC99-X2_wAC7s4HLrA6iPeSFgVIC8ru3Zs8LONtDRr7Asci4AKkfbA6H5AUIcryzQjQgBTaL9homodloA-evnXVkwJvMCqIIvn9mySu_4QetMhWf6KOWo_HEmoVWx0Bjjtbw8N3ZMCSyLKMk0lwZsR9S-iMXWuyHPS-3xoxh87md6a7NFhPr6dwGRSh69a1xFj0pbXyBRO5HtOmMgdYMWAkxAFRXWe9-7tX8ZcSrM-AzTRH-264_9Ovx7voMmWhmDN8) 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. ## UML, C4 and code [Section titled “UML, C4 and code”](#uml-c4-and-code) 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. * Picture 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. * Source bike-rental.dgr ```dgr # Bike rental, C4 level 1: the system as a black box with the people who use it and the systems around it. diagram context "Bike rental" subtitle="System context, draft for discussion" grid cols people,core,partners grid rows top,main,bottom person rider "Rider" tech="rents by app, pays per minute" at people/main person service "Service crew" tech="moves and repairs bikes" at people/bottom system rental "Bike rental" tech="app, rides, billing" at core/main emph mark=E1 system stations "Stations" tech="locks and chargers" at partners/top system payments "Payment provider" tech="card and direct debit" at partners/main system maps "Map service" tech="locations and routes" at partners/bottom flow ride accent rider -> rental "unlocks a bike" via=App rental -> stations "opens the lock" via=MQTT rental -> payments "charges the ride" via=HTTPS flow upkeep primary stations ~> rental "reports battery levels" via=MQTT rental -> service "plans jobs" via=App edge rental -> maps "shows free bikes" via=HTTPS adr E1 "Who controls the locks?" = "The rental itself" => "Lock logic and firmware stay in one hand." ``` [Open in the editor ↗](https://live.diagrist.com/#v1:bZNBb9swDIXv_hUP2tVtUWCnAemwDgV2WIFuCbAzLTOxZlsSSDlpLvvtg2W7cYr6JMDk4-NH8hMeXcsQ9om6Et8_o-Mjd7j_gtQw9KyJe5CCUHVkW1ThFSeXmvw7cogd49QEDMpwCeTrVaKCJAy-hku3Re3oINTDBp_4NcGsKhvoUCWXOt6Y7VRzDitRC-0T9kFQO7WDqgveFAdxNWzodDZR2iBcRpLkWXT6LeGkSCGWPTlfViGl0BdFZNHgIa5mAQDze3wZrL7EttmY0ZqiOoNiLBHpPNYS9M4PiQ1Aaa59N-ovuspydJYBs51fVvhkVrp9OLJmUsKRnCgq17K-ObjozpbnKUyoRsdX5FbK2ejYmJaoXNc5f7jqixJGTNkvuI8NepJ283S_lNBEyQWvMNv5Zd5B6YJtJ_O2ITmw6FWFbH4ewl0KcRGOdO4zTvMyvRAlHCfwk7AlqbNu7YRtQs2VS-Zj4cx7Vu4pag4wzxQX-uad5bmrzDwMia9Mr5WXJdl34ZRJgqxlnwosC3PzsBrE4GceeYQGR0ebbzGO0VPMzcOKaYjsNZ_HmDVFP__a7a7CL6QmwFPCWHxK-LHbvWxng0NsmSOiuJ7kXOBS69_FpRGOQcZNppRYztOF60flc3fLApvYkVf8DZVeGiu4PvDKbaZvtBkvbS_MyyqvnFIteLqH-dOEfNQyHu0CQb8abGB2zZuoS8rd3mDzAPMz2BZdODibR7d30p9IeGzzDOcRPKMhX9-a4j8) A mistake looks like this: ```text order.dgr:4:29 L105 error: `participant` has no attribute `stereotyp`. Allowed: `stereotype=`, `tone=`. participant pay ":Payments" stereotyp="external" ^^^^^^^^^^^^^^^^^^^^ ``` [Gallery](/gallery/)Every example of the repository, ready to change in the live editor. [Getting started](/docs/getting-started/)Build Diagrist, write a first file, check and build it. [The language](/docs/language/)How a file is written, every kind, every diagnostic code. [Live editor and embedding](/docs/editor/)Write in the browser, embed a diagram in Confluence. [For agents](/docs/agents/)Grammar and findings as JSON, the agent skill, llms.txt. [Live editor](https://live.diagrist.com/)live.diagrist.com: write and share a diagram in the browser. # For agents > How a coding agent works with Diagrist - the grammar and findings as JSON, the agent skill, llms.txt and every page as Markdown. Diagrist is written for coding agents as much as for people ([ADR 0005](https://github.com/diagrist/diagrist/blob/main/docs/adr/0005-agent-first-language.md)). Every statement, argument, attribute and flag has a description and an example, and the pages, the JSON and the skill are generated from the same tables that check the diagrams, so they cannot drift from what Diagrist accepts. ## The loop [Section titled “The loop”](#the-loop) An agent works the way a person does, only faster: look the grammar up, write the file, check it until nothing is reported, format it and build it. ```sh dgr grammar sequence --json # every statement of the kind as data dgr check order.dgr --json # every finding as data dgr fmt order.dgr dgr build order.dgr --png # look at the picture ``` `dgr grammar --json` prints each statement with its arguments, clauses, attributes, flags, doc and examples. The same data is on this site as `/grammar/.json`, such as [/grammar/sequence.json](/grammar/sequence.json), and it validates against the [JSON Schema](https://github.com/diagrist/diagrist/blob/main/schemas/grammar.schema.json). `dgr check --json` reports each finding with its code, position and the values its message is built from, so a tool does not have to parse text: ```json { "diagrist-cli": 1, "command": "check", "ok": false, "file": "order.dgr", "diagnostics": [ { "file": "order.dgr", "code": "L105", "severity": "error", "span": { "line": 4, "column": 29, "length": 20 }, "values": { "statement": "participant", "key": "stereotyp", "allowed": "`stereotype=`, `tone=`" }, "message": "`participant` has no attribute `stereotyp`. Allowed: `stereotype=`, `tone=`." } ] } ``` ## The agent skill [Section titled “The agent skill”](#the-agent-skill) The skill tells an agent how to work with Diagrist and holds a short reference of every kind. It is at [/skill.md](/skill.md); put it where your agent looks for skills, for Claude Code for example: ```sh mkdir -p .claude/skills/diagrist curl -o .claude/skills/diagrist/SKILL.md https://diagrist.com/skill.md ``` ## The docs as text [Section titled “The docs as text”](#the-docs-as-text) [/llms.txt](/llms.txt) lists the pages of this site for language models, [/llms-full.txt](/llms-full.txt) holds all of them in one file and [/llms-small.txt](/llms-small.txt) a shorter version. Every page is also available as Markdown at its address plus `.md`, such as [/docs/getting-started.md](/docs/getting-started.md). # Command line > The Diagrist command line: format, check and build .dgr files, and look up the grammar of a kind. The Diagrist command line: format, check and build .dgr files, and look up the grammar of a kind. Installed as `dgr` and `diagrist`. Usage: `dgr [arguments] [options]`; the command comes first. | Command | What it does | | ------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- | | [`fmt`](#dgr-fmt) | Formats .dgr files in place. | | [`check`](#dgr-check) | Checks a diagram against the grammar and the rules of its kind and prints every finding, those about one picture of a file with variants marked with the variant. | | [`build`](#dgr-build) | Renders a diagram as SVG, and with `--png` also as PNG: the base picture as `.svg` and each variant as `..svg`. | | [`grammar`](#dgr-grammar) | Shows what a diagram kind allows. | | [`help`](#dgr-help) | Explains the commands. | ## Options for every command [Section titled “Options for every command”](#options-for-every-command) | Option | Meaning | | ------------------- | --------------------------------------------------------------------------------------------------------------- | | `--json` | Print one JSON document on stdout instead of text, for agents and tools. Its form is stable, see “JSON output”. | | `--locale ` | Language of messages and diagnostics. Default: `en`. | | `-h, --help` | Show the help of the command instead of running it. | Without a command: | Option | Meaning | | ----------- | ----------------------------- | | `--version` | Print the version of the CLI. | ## Exit codes [Section titled “Exit codes”](#exit-codes) | Code | Meaning | | ---- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | 0 | Done: no finding with severity error. Warnings alone do not fail. | | 1 | A finding with severity error, or `fmt --check` found a file that is not formatted. | | 2 | The call cannot be carried out: unknown command or option, missing or extra argument, a value out of range, unreadable or unwritable file, a PNG that cannot be rendered. Also an unexpected error inside dgr, which is a bug and printed in one line on stderr. | ## dgr fmt [Section titled “dgr fmt”](#dgr-fmt) ```sh dgr fmt [options] ``` Formats .dgr files in place. Two spaces per indent level and at most one blank line; token order, aligned columns and comments stay as written. A file with read errors is left unchanged, because formatting it could drop lines. | Argument | Meaning | | ------------ | ------------------------- | | `` | The .dgr files to format. | | Option | Meaning | | --------- | ------------------------------------------------------------------------------------ | | `--check` | Change nothing; exit with 1 if a file is not formatted. For CI and pre-commit hooks. | Examples: ```sh # Format one file in place. dgr fmt diagrams/order.dgr # Fail when a file is not formatted, without changing it. dgr fmt --check diagrams/*.dgr ``` With `--json`, besides the fields of every document: | Field | Meaning | | ------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `files` | One entry per file, `{ file, status }`. `status` is `formatted` (rewritten), `unchanged` (already formatted), `unformatted` (only with `--check`: formatting would change it) or `invalid` (has read errors, left unchanged). | | `diagnostics` | Read errors and warnings of all files, see “Diagnostics”. | ## dgr check [Section titled “dgr check”](#dgr-check) ```sh dgr check [options] ``` Checks a diagram against the grammar and the rules of its kind and prints every finding, those about one picture of a file with variants marked with the variant. Writes nothing. | Argument | Meaning | | -------- | ----------------------- | | `` | The .dgr file to check. | Examples: ```sh # Print the findings; exit with 1 on an error. dgr check diagrams/order.dgr # The same as one JSON document, for agents. dgr check diagrams/order.dgr --json ``` With `--json`, besides the fields of every document: | Field | Meaning | | ------------- | -------------------------------- | | `file` | The checked file. | | `diagnostics` | All findings, see “Diagnostics”. | ## dgr build [Section titled “dgr build”](#dgr-build) ```sh dgr build [options] ``` Renders a diagram as SVG, and with `--png` also as PNG: the base picture as `.svg` and each variant as `..svg`. Nothing is written when the diagram has an error; warnings are printed and do not stop the build. With `--watch` it builds again after every change of the source or of a file it reads, through `use` or a value naming a file. | Argument | Meaning | | -------- | ------------------------ | | `` | The .dgr file to render. | | Option | Meaning | | ------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `-o, --out ` | Where to write the SVG of a diagram with one picture, or of the one `--variant` picks. Default: next to the source, with `.svg` instead of `.dgr`. The PNG goes beside the SVG. | | `--variant ` | Build only the picture of this variant, as `..svg` or where `-o` says. | | `--png` | Also write a PNG with the name of the SVG and `.png`. Rendered without a browser and with the bundled fonts, so the same diagram gives the same bytes on every machine. | | `--scale ` | Pixels of the PNG per SVG unit, from 0.25 to 8; 2 doubles width and height. Default: 2. Needs `--png`. | | `--watch` | Build, then build again each time the source or a file it reads changes, until Ctrl+C. Each build prints what it wrote and its findings, with `--json` one document per build. Errors in the diagram and a source that is gone for a moment do not end the watch; only a call refused at the first build does. Ends with the exit code of the last build. | Examples: ```sh # Write diagrams/order.svg, and one SVG per variant beside it. dgr build diagrams/order.dgr # Write the SVG somewhere else. dgr build diagrams/order.dgr -o site/order.svg # Also write diagrams/order.png, twice the size of the SVG. dgr build diagrams/order.dgr --png # Write the PNG at three times the size of the SVG, e.g. for print. dgr build diagrams/order.dgr --png --scale 3 # Write only diagrams/order.next.svg. dgr build diagrams/order.dgr --variant next # Write SVG and PNG again on every save. dgr build diagrams/order.dgr --png --watch ``` With `--json`, besides the fields of every document: | Field | Meaning | | ------------- | ------------------------------------------------------------------------------------------------------------------------------ | | `file` | The rendered source. | | `output` | Path of the first written SVG, the base unless `--variant` picks another; `null` when nothing was written. | | `png` | Path of the PNG beside `output`, `null` without `--png` or when nothing was written. | | `pictures` | Every picture asked for: `{ variant, output, png }`, `variant` `null` for the base, the paths `null` when nothing was written. | | `diagnostics` | All findings, see “Diagnostics”. | ## dgr grammar [Section titled “dgr grammar”](#dgr-grammar) ```sh dgr grammar [kind] [options] ``` Shows what a diagram kind allows. It lists the header, statements, arguments, attributes, flags and line forms, each with its doc and examples. Without a kind it lists the kinds. Derived from the same tables that check the diagrams. | Argument | Meaning | | -------- | ---------------------------------- | | `[kind]` | A diagram kind such as `sequence`. | Examples: ```sh # List the diagram kinds. dgr grammar # The grammar of sequence diagrams as data, for agents. dgr grammar sequence --json ``` With `--json`, besides the fields of every document: | Field | Meaning | | --------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `kinds` | Without a kind: `[{ kind, doc }]` for every kind. | | `grammar` | With a kind: its grammar as data, `{ kind, doc, header, statements }`; each statement lists `keyword`, `doc`, `examples`, `arguments`, `clauses`, `attributes`, `flags`, `children` and its line form `lines`. Each table is described once; elsewhere a child is `{ keyword, ref }`, where `ref` is a JSON Pointer into `grammar` such as `/statements/9`. It validates against the JSON Schema in `schemas/grammar.schema.json`. | ## dgr help [Section titled “dgr help”](#dgr-help) ```sh dgr help [command] [options] ``` Explains the commands. Without a command it lists them all, with the options every command takes and the exit codes. | Argument | Meaning | | ----------- | -------------------------------------- | | `[command]` | The command to explain, such as `fmt`. | Examples: ```sh # List the commands. dgr help # Arguments, options and examples of `fmt`; the same as `dgr fmt --help`. dgr help fmt # All command tables as data, for agents. dgr help --json ``` With `--json`, besides the fields of every document: | Field | Meaning | | ------------- | -------------------------------------------------------------------------------------------------------------------------------- | | `commands` | The tables of the explained commands: `{ name, doc, usage, arguments, options, examples, json }`, all of them without a command. | | `options` | Options every command takes, in the same form as the options of a command. | | `rootOptions` | Options of `dgr` without a command. | | `exitCodes` | `[{ code, doc }]`. | ## JSON output [Section titled “JSON output”](#json-output) With `--json` every call prints exactly one JSON document on stdout, also when it is refused. Fields in every document: | Field | Meaning | | -------------- | ------------------------------------------------------------------------------------------------------------- | | `diagrist-cli` | Version of this JSON form, currently `1`. It is raised only when a field changes meaning or goes away. | | `command` | The command that ran, `null` for `dgr --version` and when no command was recognized. | | `ok` | `true` exactly when the exit code is 0. | | `error` | Only when the call was refused (exit code 2): `{ code, message }`, with a code `C…` that is stable for tools. | | `version` | Only for `dgr --version`: the version of the CLI. | The fields of each command are listed in its section. ### Diagnostics [Section titled “Diagnostics”](#diagnostics) | Field | Meaning | | ---------- | ----------------------------------------------------------------------------------------------- | | `file` | Path of the file the finding is in: the source as given on the command line, or a file it uses. | | `picture` | Only for a finding about one picture of a file with variants: the id of the variant. | | `code` | Stable code such as `L001`; the prefix names the package or plugin that reports it. | | `severity` | `error` (exit code 1) or `warning`. | | `span` | `{ line, column, length }`: 1-based line and column, length in characters. | | `values` | The values the message is built from, by name. Use these instead of parsing the message. | | `message` | The text in the requested locale. | # Live editor and embedding > Write a diagram in the browser at live.diagrist.com, share it as a link and embed it in Confluence or any page with an iframe. The [live editor](https://live.diagrist.com/) shows the code on the left and the picture on the right, drawn again as you type. Findings appear below the code and as marks in it, with the same codes and texts as `dgr check`. Every kind of the docs can be drawn. ## Nothing reaches a server [Section titled “Nothing reaches a server”](#nothing-reaches-a-server) The editor compiles in your browser, in a Web Worker, and draws the PNG there too, with resvg compiled to WebAssembly. The source is kept in the address, behind the `#`: compressed with deflate and written as base64url, like `https://live.diagrist.com/#v1:…`. Browsers never send the part after the `#` to a server, not even as the referrer, so the diagram stays on your machine. Nothing is stored, and there are no accounts and no analytics. The address is the document. Bookmark it, put it in a ticket or send it to a colleague, and the diagram opens as you left it. The PNG and SVG the editor downloads are the same bytes the command line writes. ## Share and download [Section titled “Share and download”](#share-and-download) The bar above the editor has these buttons (the editor speaks German for now): | Button | What it does | | ------------- | --------------------------------------------------------------------------- | | Link kopieren | Copies the address with the source, to share the diagram. | | Einbetten | Opens the address and the HTML for an iframe, see below. | | SVG, PNG | Download the picture. | | .dgr | Downloads the source, to keep it next to your code and build it with `dgr`. | ## Embed a diagram [Section titled “Embed a diagram”](#embed-a-diagram) Every diagram has a second address, `https://live.diagrist.com/embed#v1:…`, that shows only the picture, scaled to the frame, with a link back to the editor. **Einbetten** gives you that address and an HTML snippet: ```html ``` In Confluence, type `/iframe`, paste the address and set a height. Any other page that allows iframes takes the HTML as it is. Only the embed page may be framed by other sites; the editor itself may not. The embedded picture is drawn in the reader’s browser from the address, so it changes only when you replace the address. To change a diagram, open it with the link below the picture, edit it, and embed the new address. # Getting started > Build Diagrist from source, write a first .dgr file, check it, build the picture and keep it checked in CI. Diagrist is not on npm yet, so for now it is built from source. You need Node 22.11 or later and pnpm 11; Corepack picks the pnpm version from `package.json`. ```sh git clone https://github.com/diagrist/diagrist.git cd diagrist pnpm install pnpm build alias dgr="node $PWD/packages/cli/dist/main.js" ``` To try the language without installing anything, use the [live editor](https://live.diagrist.com/): it compiles in the browser and shows the picture as you type. ## A first diagram [Section titled “A first diagram”](#a-first-diagram) A `.dgr` file starts with `diagram`, the kind and a title. Each following line is one statement that starts with its keyword; statements inside a block, like the operands of `alt`, are indented below it. Save this as `order.dgr`: Place an order. Sequence diagram (UML) with 3 participants and 5 messages. Participants from left to right: Customer (actor), :Shop, :Payments. 1. Customer calls :Shop: order(items). 2. :Shop calls :Payments: authorize(amount). Alternative \[approved]: 3. :Payments replies to :Shop: ok. Otherwise \[declined]: 4. :Payments replies to :Shop: declined. 5. :Shop replies to Customer: confirmation. ```dgr diagram sequence "Place an order" actor customer "Customer" participant shop ":Shop" participant pay ":Payments" msg customer -> shop "order(items)" msg shop -> pay "authorize(amount)" alt "approved" msg pay --> shop "ok" else "declined" msg pay --> shop "declined" msg shop --> customer "confirmation" ``` [Open in the editor ↗](https://live.diagrist.com/#v1:bY9LCsMwDET3PoXQKlnkAl1k0wsEegLhqIlpbLmyUkhPX_KBtNCdmHkzg_pAg1KEws-Zk2fAbiLPQAlEe1Z05E0U_FxMIivg9bjQZVILPmRKBmWUDHi5jZJ_jUwL4KWjJXKygi6W4Sxr2iO4bVXBOJZ6Zza9afc8zTaKhjdXFGVOVqOjyQApZ5UX9-gA1tAKN2fpY9V5KgzYs59C2sl_7Omf40379baXdA8ayYIk_AA) Which statements a kind has, and what each takes, is on the page of the kind, such as [sequence](/docs/language/sequence/), and in the terminal: ```sh dgr grammar sequence ``` ## Check it [Section titled “Check it”](#check-it) `dgr check` reads the file against the grammar of its kind and runs the rules of the kind. Every finding names its position, a stable code and what would be correct: ```text order.dgr:4:29 L105 error: `participant` has no attribute `stereotyp`. Allowed: `stereotype=`, `tone=`. participant pay ":Payments" stereotyp="external" ^^^^^^^^^^^^^^^^^^^^ ``` Errors stop the build. Warnings point at something that is drawn but probably not meant, such as a call that never gets a reply, and the picture is still drawn. ## Build the picture [Section titled “Build the picture”](#build-the-picture) ```sh dgr build order.dgr # writes order.svg dgr build order.dgr --png # also order.png dgr build order.dgr --watch # builds again on every save ``` The PNG is drawn by resvg compiled to WebAssembly with the bundled fonts, so it needs no browser and gives the same bytes on every machine. ## Format it [Section titled “Format it”](#format-it) `dgr fmt` formats files in place: two spaces per indent level, at most one blank line, everything else as you wrote it. `--check` changes nothing and fails when a file is not formatted. ```sh dgr fmt diagrams/*.dgr ``` ## In CI [Section titled “In CI”](#in-ci) `dgr check` exits with 1 when the file has an error, and `dgr fmt --check` when a file is not formatted. Run both in the pipeline that also runs your tests, and a broken diagram cannot be merged. `check` takes one file at a time: ```sh dgr fmt --check diagrams/*.dgr for file in diagrams/*.dgr; do dgr check "$file" || exit 1; done ``` The [command line reference](/docs/cli/) lists every command, option and exit code, and the form of the JSON output. # The Diagrist language > A .dgr file holds one diagram. Its first line names the kind and the title, diagram sequence "Checkout", followed by the attributes of the header. Every other line is a statement: a keyword, then its arguments in the order the table gives, then flags, clauses and key=value attributes in any order. A `.dgr` file holds one diagram. Its first line names the kind and the title, `diagram sequence "Checkout"`, followed by the attributes of the header. Every other line is a statement: a keyword, then its arguments in the order the table gives, then flags, clauses and `key=value` attributes in any order. Texts stand in double quotes and may contain `\"`. Ids are single words of letters, digits, `_` and `-` that start with a letter; a statement declares an id, and other statements refer to it by that word. An attribute value is a single word or a text in quotes, as in `stereotype="web app"`. Indentation nests: a line belongs to the nearest line above it with less indent, so the statements of a block such as a fragment are indented below it. `dgr fmt` writes two spaces per level and keeps at most one blank line. `#` starts a comment that runs to the end of the line. ## Kinds [Section titled “Kinds”](#kinds) Each kind has its own page with every statement, its parts, examples and the codes of its rules. | Kind | Plugin | What it draws | | ---------------------------------------- | -------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | [`sequence`](/docs/language/sequence/) | `uml` | A UML sequence diagram (UML 2.5.1, chapter 17): lifelines from left to right in source order, messages and fragments from top to bottom. | | [`usecase`](/docs/language/usecase/) | `uml` | A UML use case diagram (UML 2.5.1, chapter 18): actors outside, use cases inside their subject, relations as straight lines. | | [`activity`](/docs/language/activity/) | `uml` | A UML activity diagram (UML 2.5.1, chapters 15 and 16): nodes and edges in layers from top to bottom, one vertical swimlane per `partition`. | | [`class`](/docs/language/class/) | `uml` | A UML class diagram (UML 2.5.1, chapters 9 to 12): classes, interfaces and enumerations with their members, packages, and the relations between them. | | [`state`](/docs/language/state/) | `uml` | A UML state machine diagram (UML 2.5.1, chapter 14): states and pseudostates joined by transitions, composite states with substates or orthogonal regions, entry and exit points on their border. | | [`context`](/docs/language/context/) | `architecture` | A C4 system context diagram (level 1): the system as one box, the people who use it and the systems around it, placed in a named grid. | | [`container`](/docs/language/container/) | `architecture` | A C4 container diagram (level 2): the applications and data stores of a system, grouped by responsibility, placed in a named grid. | | [`component`](/docs/language/component/) | `architecture` | A C4 component diagram (level 3): the components inside a container and what they depend on, placed in a named grid. | | [`code`](/docs/language/code/) | `code` | A code diagram: excerpts of real source files as highlighted cards, one below the other, with marked lines, numbered notes below each card and arrows from a call to what it calls. | ## Statements of every kind [Section titled “Statements of every kind”](#statements-of-every-kind) Every kind also has `use`, `variant`, `set` and `drop`. A file holds one base picture and any number of variants: a `variant` block repeats only the lines that differ, so as-is and to-be, phases or option A and B stay one source. A statement of the kind inside a variant adds a line, `set` changes the clauses, attributes and flags of a declared line, `drop` removes one. `from` builds a variant on one declared above it, and `diff` draws it as a comparison with what it builds on, if the kind can (C4 can). Where a line goes: `set` keeps the line in its place, and a line declared again after its `drop` takes the dropped line’s place. A new line goes before the next line of its keyword that the variant declares again, otherwise after the last line of its keyword, so lines keep the order they are written in. The grid and `at` are inherited, so an element keeps its cell in every picture. `use "file.dgr"` puts the lines and variants of another file of the same kind before the file’s own, so a decision paper can build on a shared base. Paths are relative to the file, stay inside the folder `dgr` runs in and name no hidden file. `dgr build` writes the base as `.svg` and each variant as `..svg`; `--variant` builds one. ### `use` [Section titled “use”](#use) ```text use ``` Puts the statements and variants of another `.dgr` file of the same kind before this file’s own, as if they were written here, so a variant may build on them. The other file’s header is not taken. `use` lines stand directly after the header. Written at the top level. | Part | Kind | Value | Meaning | | -------- | -------- | ---------------------------------------------- | ------------------------------------------------------------------------------------------------------------------- | | `` | argument | a text in double quotes like `"Order service"` | Path of the file relative to this one. It stays inside the folder `dgr` runs in and names no hidden file or folder. | Example: ```dgr use "radverleih.dgr" ``` ### `variant` [Section titled “variant”](#variant) ```text variant [from <ref>] [subtitle=<text>] [diff] ``` One more picture from the same base, written as the lines that differ: a statement of the kind adds a line, `set` changes one and `drop` removes one. A new line goes before the next line of its keyword the variant declares again, else after the last line of its keyword, so lines keep the order they are written in. `dgr build` writes it as `<file>.<id>.svg`. Written at the top level. Indented below it: `set`, `drop`. | Part | Kind | Value | Meaning | | ------------ | --------- | ------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------- | | `<id>` | argument | an identifier like `api` (letters, digits, `_` and `-`, starting with a letter) | Id of the variant, part of the file name of its picture. | | `<title>` | argument | a text in double quotes like `"Order service"` | Title of its picture, in place of the title of the header. | | `from <ref>` | clause | the id of a `variant` declared in this diagram | A variant declared above to build on; without it the variant builds on the base. | | `subtitle=` | attribute | a text in double quotes like `"Order service"` | Subtitle of its picture, in place of the one of the header. | | `diff` | flag | | Draws the picture as a comparison with what it builds on: added, removed and changed lines marked, with a legend. Kinds that cannot draw it report K103. | Examples: ```dgr variant target "Target 2027" subtitle="For review" diff variant a "Option A: stream through the backend" from target ``` ### `set` [Section titled “set”](#set) ```text set <id> ``` Changes the line that declares `id`, where it stands. What follows the id is checked against that line’s own table: a clause or attribute written again replaces its value, a flag written turns it on. Arguments such as the label cannot be set: drop the line and declare it again. Written only inside `variant`. | Part | Kind | Value | Meaning | | ------ | -------- | -------------------------------------------------------------------- | ----------------------------- | | `<id>` | argument | the id a line at the top level of the picture declares, such as `db` | The id of the line to change. | Examples: ```dgr set db tech="PostgreSQL 17" set portal status=deprecated ``` ### `drop` [Section titled “drop”](#drop) ```text drop <keyword> [arguments] ``` Removes one line of the picture: its keyword and as many of its first arguments as make it unique, matched from the left. It must match exactly one line, and no line left may refer to an id it removes. A line declared again after its `drop` takes its place. Lines inside a block are not dropped singly: drop the block and declare it again. Written only inside `variant`. | Part | Kind | Value | Meaning | | ------------- | ----------------- | ---------------------------------------------------------------------------------------- | ---------------------------------------------------------- | | `<keyword>` | argument | a single word without quotes | The keyword of the line, such as `node`. | | `[arguments]` | optional argument | the first words, texts and operators of the line as written, such as `backend -> portal` | Its first arguments as written, as many as make it unique. | Examples: ```dgr drop node portal drop edge backend -> portal drop grid rows ``` ## The grammar as data [Section titled “The grammar as data”](#the-grammar-as-data) `dgr grammar <kind> --json` prints the grammar of a kind as data, derived from the same tables as these pages. It validates against the JSON Schema [`schemas/grammar.schema.json`](https://github.com/diagrist/diagrist/blob/main/schemas/grammar.schema.json). Editors and the language server ask `complete` from `@diagrist/lang` what may be written at a position; it reads the same tables. ## Diagnostic codes [Section titled “Diagnostic codes”](#diagnostic-codes) Every finding has a stable code whose letter names who reports it: `L` the language, `K` and `G` the kernel, and one letter per plugin, such as `U` for `uml`. The codes of a kind are on its page. The messages below show each value as `{name}`; with `--json` the same values come as `values`, so tools need not parse the text. The language reports these while it reads a file against the tables of its kind: | Code | Message | | ------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `L001` | Text is missing its closing quote. | | `L002` | A line starts with a keyword, not with {found}. | | `L003` | Indent with spaces, not tabs. | | `L004` | Attribute {key} is set twice; the last value wins. | | `L005` | The character {found} cannot stand in a diagram: the picture is SVG, and XML has no way to write it. Delete it; tabs, line breaks and every printable character are allowed. | | `L006` | Statements nest at most {limit} levels deep, and this one would be deeper; it and the lines indented below it are not read. Move it up a level or split the diagram. | | `L100` | A diagram starts with `diagram {kind} "Title"`. Registered kinds: {allowed}. Example: `{example}` | | `L101` | Unknown keyword `{found}` here; did you mean `{suggestion}`? Allowed: {allowed}. | | `L102` | `{statement}` needs {name}: {expected}. Example: `{example}` | | `L103` | `{found}` is not valid for {name}; expected {expected}. | | `L104` | `{found}` is not expected in `{statement}`. Allowed after the arguments: {allowed}. Example: `{example}` | | `L105` | `{statement}` has no attribute `{key}`. Allowed: {allowed}. | | `L106` | `{statement}` takes no indented lines without a keyword. Allowed child keywords: {allowed}. | | `L107` | `{found}` is not declared; {name} must be {expected}. Declared: {known}. | | `L108` | The id `{found}` is already declared in line {first}. Ids are unique within a diagram. | | `L109` | `use` stands directly after the header, before `{found}` in line {line}. Example: `use "base.dgr"` | | `L110` | `{file}` is a `{found}` diagram; `use` in a `{kind}` diagram needs a `{kind}` diagram. | | `L111` | `{file}` uses itself through {chain}. Remove one `use`. | | `L112` | `drop {found}` matches no line of the picture `{variant}` builds on. Lines with keyword `{keyword}`: {known}. Example: `{example}` | | `L113` | `drop {found}` matches the lines {lines}. Add arguments until exactly one matches, for example `{example}`. | | `L114` | `{id}` is dropped in variant `{variant}`, but {name} of this line still refers to it. Drop this line too, or keep `{id}`. | | `L115` | `set {id}` changes nothing. Write at least one attribute, clause or flag of `{keyword}`: {allowed}. Example: `set {id} {example}` | | `L116` | `variant {found}` builds on `{from}`, which is declared later in line {line}. Declare `{from}` first. | | `L117` | `{found}` is already declared in line {first}. In a variant, change it with `set {found} ...` or remove it with `drop {keyword} {found}`. | | `L118` | `{file}` was not handed over, so it cannot be read. Hosts read every file a diagram needs before they compile it; `dgr` does so and reports C018 when it cannot. | | `L119` | `{found}` is no allowed path: {case}. A path is relative to the diagram, stays inside the folder `dgr` runs in and names no hidden file or folder. Example: `"../shared/base.dgr"` | | `L120` | `{file}` would be the {depth}th file in a chain of `use`, and a chain holds at most {max}. Use the file that holds the lines directly, such as `use "../shared/base.dgr"`. | The kernel reports these about kinds, icons and the placement of what the layout drew: | Code | Message | | ------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `G400` | `{first}` overlaps `{second}`. Shorten a text, or change what the layout places here. | | `G401` | `{key}` reaches outside the picture. | | `G402` | `{key}` does not fit into `{within}`. Shorten the text or give `{within}` more room. | | `G403` | `{key}` reaches into the frame `{frame}` without belonging to it, so the picture says it is part of it. Make `{key}` a member of `{frame}`, or split the frame. | | `K100` | No plugin draws the diagram kind `{found}`. Registered kinds: {allowed}. A diagram starts with `diagram <kind> "Title"`. | | `K101` | The kind `{kind}` is registered twice, by {plugins}; the first one is used. | | `K102` | The picture uses the icon `{icon}`, which the style table does not have. Icons: {known}. | | `K103` | The kind `{kind}` draws no diff pictures; remove `diff` from `variant {variant}`. Kinds with diff pictures: {allowed}. | | `K104` | A text of the picture reads `{text}`, but its runs read `{runs}`. This is a bug of the plugin, not a mistake in the diagram: the runs of a text join to its text. | | `K110` | The plugin `{plugin}` failed while drawing the kind `{kind}`: {error}. This is a bug, not a mistake in the diagram; please report it with the diagram at <https://github.com/diagrist/diagrist/issues>. | # activity > A UML activity diagram (UML 2.5.1, chapters 15 and 16): nodes and edges in layers from top to bottom, one vertical swimlane per partition. Diagrist lays it out by itself: layers by the longest path, alternatives symmetric below their decision, parallel branches side by side below their fork, a hand-over into another lane level and horizontal when its line is free, loops back up on the right. A UML activity diagram (UML 2.5.1, chapters 15 and 16): nodes and edges in layers from top to bottom, one vertical swimlane per `partition`. Diagrist lays it out by itself: layers by the longest path, alternatives symmetric below their decision, parallel branches side by side below their fork, a hand-over into another lane level and horizontal when its line is free, loops back up on the right. This page lists everything an `activity` diagram may contain. The same grammar is available as data with `dgr grammar activity --json`, and [the overview](/docs/language/) explains how lines, texts and attributes are written and lists the codes every kind shares. ## The first line [Section titled “The first line”](#the-first-line) ```text diagram activity "Title" [subtitle=<text>] [look=<plain|cards>] [locale=<en|de>] ``` Every activity diagram starts with this line. | Part | Kind | Value | Meaning | | ----------- | --------- | ---------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `subtitle=` | attribute | a text in double quotes like `"Order service"` | Second line below the title. | | `look=` | attribute | one of `plain`, `cards` | `plain` (default) draws the UML notation, `cards` the same layout with actions, objects and signals as cards and toned lane heads; start, ends, diamonds, bars and hourglass stay UML symbols. | | `locale=` | attribute | one of `en`, `de` | Language of the texts Diagrist adds to the picture and of the description: `en` (default) or `de`. | Example: ```dgr diagram activity "Title" ``` ## Statements [Section titled “Statements”](#statements) Each statement is one line that starts with its keyword. Statements inside blocks are indented below them. Like every kind, `activity` also has `use`, `variant`, `set` and `drop`, described in [the overview](/docs/language/#statements-of-every-kind). | Statement | Where | What it does | | --------------------------------- | --------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | [`partition`](#partition) | top level | A partition, drawn as a vertical swimlane with its name in a head. | | [`interruptible`](#interruptible) | top level | An interruptible activity region: a dashed, rounded frame around the nodes with `interruptible=id`. | | [`expansion`](#expansion) | top level | An expansion region: a dashed, rounded frame around the nodes with `expansion=id`, run once per element of a collection, with its mode as `«iterative»`, `«parallel»` or `«stream»` at the top left. | | [`initial`](#initial) | top level | An initial node: a filled circle where the flow starts. | | [`final`](#final) | top level | An activity final node: a circle with a filled core. | | [`flowfinal`](#flowfinal) | top level | A flow final node: a circle with a cross. | | [`action`](#action) | top level | An action: a rounded box with its text; texts wider than 208 pixels wrap into two lines. | | [`decision`](#decision) | top level | A decision node: a diamond with one incoming edge and alternatives going out, each with a guard on its `go`. | | [`merge`](#merge) | top level | A merge node: a diamond that brings alternative branches together without waiting for each other, with exactly one outgoing edge. | | [`fork`](#fork) | top level | A fork node: a bar across the flow that starts all its outgoing branches at the same time. | | [`join`](#join) | top level | A join node: a bar across the flow that waits for all incoming branches and then continues on its one outgoing edge. | | [`object`](#object) | top level | An object node: a rectangle with the object type, its state below in brackets. | | [`datastore`](#datastore) | top level | A data store: an object node with `«datastore»` above its name, whose data outlive the activity. | | [`buffer`](#buffer) | top level | A central buffer: an object node with `«centralBuffer»` above its name that collects objects from several flows. | | [`send`](#send) | top level | A send signal action: a pentagon pointing right with the signal. | | [`accept`](#accept) | top level | An accept event action: a box with a notch on the left that waits for a signal. | | [`wait`](#wait) | top level | An accept time event action: an hourglass with the time beside it; the flow waits there until the time has come. | | [`go`](#go) | top level | An activity edge from `from` to `to`. | | [`handler`](#handler) | top level | An exception handler: when the protected action throws an exception of the type, the handler action takes over, and the flow goes on at the output of the protected action. | | [`adr`](#adr) | top level | An architecture decision in the bar below the picture: question, the chosen option after `=`, and the consequence after `=>`. | ### `partition` [Section titled “partition”](#partition) ```text partition <id> <label> [tone=<choice>] ``` A partition, drawn as a vertical swimlane with its name in a head. Lanes stand from left to right in source order; nodes join one with `in`. Without any partition the activity has one invisible lane. UML 2.5.1: 15.6.3.1 Activity partition (swimlane). Written at the top level. | Part | Kind | Value | Meaning | | --------- | --------- | ------------------------------------------------------------------------------------------------------ | ---------------------------------------------------------- | | `<id>` | argument | an identifier like `api` (letters, digits, `_` and `-`, starting with a letter) | Id that `in` uses for this lane. | | `<label>` | argument | a text in double quotes like `"Order service"` | Who is responsible, such as a role or a system. | | `tone=` | attribute | one of `blue`, `indigo`, `purple`, `maroon`, `green`, `teal`, `slate`, `red`, `orange`, `peach`, `sky` | Colour of the lane head in `look=cards`; without it slate. | Examples: ```dgr partition customer "Customer" partition billing "Billing" tone=purple ``` ### `interruptible` [Section titled “interruptible”](#interruptible) ```text interruptible <id> [label] ``` An interruptible activity region: a dashed, rounded frame around the nodes with `interruptible=id`. An interrupting edge `~>` leaving it stops everything inside. The name stands small at the top left of the frame where there is room, otherwise one line lower, at the bottom, wrapped, or only in the description. UML 2.5.1: 15.6.3.2 Interruptible activity region. Written at the top level. | Part | Kind | Value | Meaning | | --------- | ----------------- | ------------------------------------------------------------------------------- | ------------------------------------------------------- | | `<id>` | argument | an identifier like `api` (letters, digits, `_` and `-`, starting with a letter) | Id that `interruptible=` on nodes uses for this region. | | `[label]` | optional argument | a text in double quotes like `"Order service"` | Name of the region. | Example: ```dgr interruptible cancel "Cancellation by the customer" ``` ### `expansion` [Section titled “expansion”](#expansion) ```text expansion <id> [label] [mode=<iterative|parallel|stream>] [input=<text>] [output=<text>] ``` An expansion region: a dashed, rounded frame around the nodes with `expansion=id`, run once per element of a collection, with its mode as `«iterative»`, `«parallel»` or `«stream»` at the top left. Its id in `go` stands for its expansion nodes, rows of four small boxes on the frame: `go a => region` from outside ends at the input on the top edge, `go region => x` inside starts there; `go y => region` from inside ends at the output on the bottom edge, `go region => b` outside starts there. The output is drawn only when an edge uses it. UML 2.5.1: 16.12.3 Expansion region, 16.12.3 Expansion node on the border of its region. Written at the top level. | Part | Kind | Value | Meaning | | --------- | ----------------- | ------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `<id>` | argument | an identifier like `api` (letters, digits, `_` and `-`, starting with a letter) | Id that `expansion=` on nodes and the ends of `go` use for this region. | | `[label]` | optional argument | a text in double quotes like `"Order service"` | Name of the region, beside its mode. | | `mode=` | attribute | one of `iterative`, `parallel`, `stream` | How the elements run: `iterative` (default) one after the other, `parallel` at the same time, `stream` as a stream. UML 2.5.1: `iterative` 16.12.3 Expansion mode iterative; `parallel` 16.12.3 Expansion mode parallel; `stream` 16.12.3 Expansion mode stream. | | `input=` | attribute | a text in double quotes like `"Order service"` | Named inputs separated by commas, side by side on the top edge; `pin=` on `go` picks one. Without it the region has one unnamed input. UML 2.5.1: 16.12.3 Expansion node on the border of its region. | | `output=` | attribute | a text in double quotes like `"Order service"` | Named outputs separated by commas, side by side on the bottom edge; `pin=` on `go` picks one. Without it the region has at most one unnamed output. UML 2.5.1: 16.12.3 Expansion node on the border of its region. | Examples: ```dgr expansion each "Check every item" mode=parallel expansion prices "Price per item" input="Items, Price list" output="Prices, Errors" ``` ### `initial` [Section titled “initial”](#initial) ```text initial <id> [in <ref>] [interruptible=<ref>] [expansion=<ref>] ``` An initial node: a filled circle where the flow starts. It has no text and no incoming edge. UML 2.5.1: 15.3.3.1 Initial node. Written at the top level. | Part | Kind | Value | Meaning | | ---------------- | --------- | ------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `<id>` | argument | an identifier like `api` (letters, digits, `_` and `-`, starting with a letter) | Id that `go`, `handler` and `in` use for this node. | | `in <ref>` | clause | the id of a `partition` declared in this diagram | The partition (swimlane) the node stands in. Without it, Diagrist puts the node into the lane of its first predecessor that has one, else of its first successor, else into the first lane. UML 2.5.1: 15.6.3.1 Activity partition (swimlane). | | `interruptible=` | attribute | the id of an `interruptible` declared in this diagram | The interruptible region the node belongs to; its dashed frame is drawn around all members. UML 2.5.1: 15.6.3.2 Interruptible activity region. | | `expansion=` | attribute | the id of an `expansion` declared in this diagram | The expansion region the node belongs to, run once per element. UML 2.5.1: 16.12.3 Expansion region. | Example: ```dgr initial start in customer ``` ### `final` [Section titled “final”](#final) ```text final <id> [in <ref>] [interruptible=<ref>] [expansion=<ref>] ``` An activity final node: a circle with a filled core. The first token to reach it ends the whole activity, every parallel branch included. It has no text and no outgoing edge. UML 2.5.1: 15.3.3.2 Activity final node, ending every flow. Written at the top level. | Part | Kind | Value | Meaning | | ---------------- | --------- | ------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `<id>` | argument | an identifier like `api` (letters, digits, `_` and `-`, starting with a letter) | Id that `go`, `handler` and `in` use for this node. | | `in <ref>` | clause | the id of a `partition` declared in this diagram | The partition (swimlane) the node stands in. Without it, Diagrist puts the node into the lane of its first predecessor that has one, else of its first successor, else into the first lane. UML 2.5.1: 15.6.3.1 Activity partition (swimlane). | | `interruptible=` | attribute | the id of an `interruptible` declared in this diagram | The interruptible region the node belongs to; its dashed frame is drawn around all members. UML 2.5.1: 15.6.3.2 Interruptible activity region. | | `expansion=` | attribute | the id of an `expansion` declared in this diagram | The expansion region the node belongs to, run once per element. UML 2.5.1: 16.12.3 Expansion region. | Example: ```dgr final done in customer ``` ### `flowfinal` [Section titled “flowfinal”](#flowfinal) ```text flowfinal <id> [in <ref>] [interruptible=<ref>] [expansion=<ref>] ``` A flow final node: a circle with a cross. It ends only the branch that reaches it, the rest of the activity goes on. It has no text and no outgoing edge. UML 2.5.1: 15.3.3.2 Flow final node, ending one flow. Written at the top level. | Part | Kind | Value | Meaning | | ---------------- | --------- | ------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `<id>` | argument | an identifier like `api` (letters, digits, `_` and `-`, starting with a letter) | Id that `go`, `handler` and `in` use for this node. | | `in <ref>` | clause | the id of a `partition` declared in this diagram | The partition (swimlane) the node stands in. Without it, Diagrist puts the node into the lane of its first predecessor that has one, else of its first successor, else into the first lane. UML 2.5.1: 15.6.3.1 Activity partition (swimlane). | | `interruptible=` | attribute | the id of an `interruptible` declared in this diagram | The interruptible region the node belongs to; its dashed frame is drawn around all members. UML 2.5.1: 15.6.3.2 Interruptible activity region. | | `expansion=` | attribute | the id of an `expansion` declared in this diagram | The expansion region the node belongs to, run once per element. UML 2.5.1: 16.12.3 Expansion region. | Example: ```dgr flowfinal mailed ``` ### `action` [Section titled “action”](#action) ```text action <id> <label> [in <ref>] [interruptible=<ref>] [expansion=<ref>] [tone=<choice>] [mark=<ref>] [input=<text>] [output=<text>] [call] ``` An action: a rounded box with its text; texts wider than 208 pixels wrap into two lines. `input=` and `output=` put pins on its edges, `call` marks a call behavior action with a rake at the bottom right. An action with several incoming or outgoing edges waits for all of them or starts all of them; a `merge` or `decision` usually says what is meant. UML 2.5.1: 16.2.3.1 Action. Written at the top level. | Part | Kind | Value | Meaning | | ---------------- | --------- | ------------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `<id>` | argument | an identifier like `api` (letters, digits, `_` and `-`, starting with a letter) | Id that `go`, `handler` and `in` use for this node. | | `<label>` | argument | a text in double quotes like `"Order service"` | What is done, as a verb phrase. | | `in <ref>` | clause | the id of a `partition` declared in this diagram | The partition (swimlane) the node stands in. Without it, Diagrist puts the node into the lane of its first predecessor that has one, else of its first successor, else into the first lane. UML 2.5.1: 15.6.3.1 Activity partition (swimlane). | | `interruptible=` | attribute | the id of an `interruptible` declared in this diagram | The interruptible region the node belongs to; its dashed frame is drawn around all members. UML 2.5.1: 15.6.3.2 Interruptible activity region. | | `expansion=` | attribute | the id of an `expansion` declared in this diagram | The expansion region the node belongs to, run once per element. UML 2.5.1: 16.12.3 Expansion region. | | `tone=` | attribute | one of `blue`, `indigo`, `purple`, `maroon`, `green`, `teal`, `slate`, `red`, `orange`, `peach`, `sky` | Colour of the card outline in `look=cards`; without it the card is white with a grey outline. The plain look ignores it. | | `mark=` | attribute | the id of an `adr` declared in this diagram | Id of a decision of the decision bar, such as `E1`; the mark is drawn at the top right of the node. | | `input=` | attribute | a text in double quotes like `"Order service"` | Input pins by object type, separated by commas like `"Order, Amount"`; small squares on the top edge, the type beside each. UML 2.5.1: 16.2.3.3 Input and output pin of an action. | | `output=` | attribute | a text in double quotes like `"Order service"` | Output pins by object type, separated by commas like `"Order, Amount"`; small squares on the bottom edge, the type beside each. UML 2.5.1: 16.2.3.3 Input and output pin of an action. | | `call` | flag | | Calls an activity of its own (call behavior action): a rake at the bottom right of the box. UML 2.5.1: 16.3.4.1 Call behavior action with the rake symbol. | Examples: ```dgr action order "Place order" in customer action invoice "Create invoice" in billing output="Invoice" call ``` ### `decision` [Section titled “decision”](#decision) ```text decision <id> [question] [in <ref>] [interruptible=<ref>] [expansion=<ref>] ``` A decision node: a diamond with one incoming edge and alternatives going out, each with a guard on its `go`. The optional question stands at the top beside the diamond. The outermost alternatives leave at the left and right corner, the others at the bottom. The decision bar below the picture is `adr`, not `decision`. UML 2.5.1: 15.3.3.6 Decision node. Written at the top level. | Part | Kind | Value | Meaning | | ---------------- | ----------------- | ------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `<id>` | argument | an identifier like `api` (letters, digits, `_` and `-`, starting with a letter) | Id that `go`, `handler` and `in` use for this node. | | `[question]` | optional argument | a text in double quotes like `"Order service"` | Question the guards answer, shown beside the diamond. | | `in <ref>` | clause | the id of a `partition` declared in this diagram | The partition (swimlane) the node stands in. Without it, Diagrist puts the node into the lane of its first predecessor that has one, else of its first successor, else into the first lane. UML 2.5.1: 15.6.3.1 Activity partition (swimlane). | | `interruptible=` | attribute | the id of an `interruptible` declared in this diagram | The interruptible region the node belongs to; its dashed frame is drawn around all members. UML 2.5.1: 15.6.3.2 Interruptible activity region. | | `expansion=` | attribute | the id of an `expansion` declared in this diagram | The expansion region the node belongs to, run once per element. UML 2.5.1: 16.12.3 Expansion region. | Examples: ```dgr decision stock "Enough stock?" in warehouse decision paid ``` ### `merge` [Section titled “merge”](#merge) ```text merge <id> [label] [in <ref>] [interruptible=<ref>] [expansion=<ref>] ``` A merge node: a diamond that brings alternative branches together without waiting for each other, with exactly one outgoing edge. Branches leave a decision; parallel branches of a `fork` meet in a `join` instead. UML 2.5.1: 15.3.3.5 Merge node. Written at the top level. | Part | Kind | Value | Meaning | | ---------------- | ----------------- | ------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `<id>` | argument | an identifier like `api` (letters, digits, `_` and `-`, starting with a letter) | Id that `go`, `handler` and `in` use for this node. | | `[label]` | optional argument | a text in double quotes like `"Order service"` | Text beside the diamond. | | `in <ref>` | clause | the id of a `partition` declared in this diagram | The partition (swimlane) the node stands in. Without it, Diagrist puts the node into the lane of its first predecessor that has one, else of its first successor, else into the first lane. UML 2.5.1: 15.6.3.1 Activity partition (swimlane). | | `interruptible=` | attribute | the id of an `interruptible` declared in this diagram | The interruptible region the node belongs to; its dashed frame is drawn around all members. UML 2.5.1: 15.6.3.2 Interruptible activity region. | | `expansion=` | attribute | the id of an `expansion` declared in this diagram | The expansion region the node belongs to, run once per element. UML 2.5.1: 16.12.3 Expansion region. | Example: ```dgr merge together in support ``` ### `fork` [Section titled “fork”](#fork) ```text fork <id> [in <ref>] [interruptible=<ref>] [expansion=<ref>] ``` A fork node: a bar across the flow that starts all its outgoing branches at the same time. It has exactly one incoming edge; the bar is as wide as the branches below it. UML 2.5.1: 15.3.3.3 Fork node. Written at the top level. | Part | Kind | Value | Meaning | | ---------------- | --------- | ------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `<id>` | argument | an identifier like `api` (letters, digits, `_` and `-`, starting with a letter) | Id that `go`, `handler` and `in` use for this node. | | `in <ref>` | clause | the id of a `partition` declared in this diagram | The partition (swimlane) the node stands in. Without it, Diagrist puts the node into the lane of its first predecessor that has one, else of its first successor, else into the first lane. UML 2.5.1: 15.6.3.1 Activity partition (swimlane). | | `interruptible=` | attribute | the id of an `interruptible` declared in this diagram | The interruptible region the node belongs to; its dashed frame is drawn around all members. UML 2.5.1: 15.6.3.2 Interruptible activity region. | | `expansion=` | attribute | the id of an `expansion` declared in this diagram | The expansion region the node belongs to, run once per element. UML 2.5.1: 16.12.3 Expansion region. | Example: ```dgr fork split in warehouse ``` ### `join` [Section titled “join”](#join) ```text join <id> [in <ref>] [interruptible=<ref>] [expansion=<ref>] ``` A join node: a bar across the flow that waits for all incoming branches and then continues on its one outgoing edge. Alternatives of a decision meet in a `merge`; a join would wait forever for the branch not taken. UML 2.5.1: 15.3.3.4 Join node. Written at the top level. | Part | Kind | Value | Meaning | | ---------------- | --------- | ------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `<id>` | argument | an identifier like `api` (letters, digits, `_` and `-`, starting with a letter) | Id that `go`, `handler` and `in` use for this node. | | `in <ref>` | clause | the id of a `partition` declared in this diagram | The partition (swimlane) the node stands in. Without it, Diagrist puts the node into the lane of its first predecessor that has one, else of its first successor, else into the first lane. UML 2.5.1: 15.6.3.1 Activity partition (swimlane). | | `interruptible=` | attribute | the id of an `interruptible` declared in this diagram | The interruptible region the node belongs to; its dashed frame is drawn around all members. UML 2.5.1: 15.6.3.2 Interruptible activity region. | | `expansion=` | attribute | the id of an `expansion` declared in this diagram | The expansion region the node belongs to, run once per element. UML 2.5.1: 16.12.3 Expansion region. | Example: ```dgr join done in service ``` ### `object` [Section titled “object”](#object) ```text object <id> <label> [in <ref>] [interruptible=<ref>] [expansion=<ref>] [tone=<choice>] [mark=<ref>] [state=<text>] ``` An object node: a rectangle with the object type, its state below in brackets. Only object flows `=>` touch it. UML 2.5.1: 15.4.3.1 Object node. Written at the top level. | Part | Kind | Value | Meaning | | ---------------- | --------- | ------------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `<id>` | argument | an identifier like `api` (letters, digits, `_` and `-`, starting with a letter) | Id that `go`, `handler` and `in` use for this node. | | `<label>` | argument | a text in double quotes like `"Order service"` | Type of the object. | | `in <ref>` | clause | the id of a `partition` declared in this diagram | The partition (swimlane) the node stands in. Without it, Diagrist puts the node into the lane of its first predecessor that has one, else of its first successor, else into the first lane. UML 2.5.1: 15.6.3.1 Activity partition (swimlane). | | `interruptible=` | attribute | the id of an `interruptible` declared in this diagram | The interruptible region the node belongs to; its dashed frame is drawn around all members. UML 2.5.1: 15.6.3.2 Interruptible activity region. | | `expansion=` | attribute | the id of an `expansion` declared in this diagram | The expansion region the node belongs to, run once per element. UML 2.5.1: 16.12.3 Expansion region. | | `tone=` | attribute | one of `blue`, `indigo`, `purple`, `maroon`, `green`, `teal`, `slate`, `red`, `orange`, `peach`, `sky` | Colour of the card outline in `look=cards`; without it the card is white with a grey outline. The plain look ignores it. | | `mark=` | attribute | the id of an `adr` declared in this diagram | Id of a decision of the decision bar, such as `E1`; the mark is drawn at the top right of the node. | | `state=` | attribute | a text in double quotes like `"Order service"` | State of the object, drawn as `[state]` below the type. UML 2.5.1: 15.4.4.1 States of an object node in brackets below its name. | Example: ```dgr object invoice "Invoice" state="open" in billing ``` ### `datastore` [Section titled “datastore”](#datastore) ```text datastore <id> <label> [in <ref>] [interruptible=<ref>] [expansion=<ref>] [tone=<choice>] [mark=<ref>] ``` A data store: an object node with `«datastore»` above its name, whose data outlive the activity. A data store without incoming edge counts as a start. UML 2.5.1: 15.4.3.4 Data store node. Written at the top level. | Part | Kind | Value | Meaning | | ---------------- | --------- | ------------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `<id>` | argument | an identifier like `api` (letters, digits, `_` and `-`, starting with a letter) | Id that `go`, `handler` and `in` use for this node. | | `<label>` | argument | a text in double quotes like `"Order service"` | Name of the store. | | `in <ref>` | clause | the id of a `partition` declared in this diagram | The partition (swimlane) the node stands in. Without it, Diagrist puts the node into the lane of its first predecessor that has one, else of its first successor, else into the first lane. UML 2.5.1: 15.6.3.1 Activity partition (swimlane). | | `interruptible=` | attribute | the id of an `interruptible` declared in this diagram | The interruptible region the node belongs to; its dashed frame is drawn around all members. UML 2.5.1: 15.6.3.2 Interruptible activity region. | | `expansion=` | attribute | the id of an `expansion` declared in this diagram | The expansion region the node belongs to, run once per element. UML 2.5.1: 16.12.3 Expansion region. | | `tone=` | attribute | one of `blue`, `indigo`, `purple`, `maroon`, `green`, `teal`, `slate`, `red`, `orange`, `peach`, `sky` | Colour of the card outline in `look=cards`; without it the card is white with a grey outline. The plain look ignores it. | | `mark=` | attribute | the id of an `adr` declared in this diagram | Id of a decision of the decision bar, such as `E1`; the mark is drawn at the top right of the node. | Example: ```dgr datastore accounts "Customer accounts" in payment ``` ### `buffer` [Section titled “buffer”](#buffer) ```text buffer <id> <label> [in <ref>] [interruptible=<ref>] [expansion=<ref>] [tone=<choice>] [mark=<ref>] ``` A central buffer: an object node with `«centralBuffer»` above its name that collects objects from several flows. UML 2.5.1: 15.4.3.3 Central buffer node. Written at the top level. | Part | Kind | Value | Meaning | | ---------------- | --------- | ------------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `<id>` | argument | an identifier like `api` (letters, digits, `_` and `-`, starting with a letter) | Id that `go`, `handler` and `in` use for this node. | | `<label>` | argument | a text in double quotes like `"Order service"` | Name of what is buffered. | | `in <ref>` | clause | the id of a `partition` declared in this diagram | The partition (swimlane) the node stands in. Without it, Diagrist puts the node into the lane of its first predecessor that has one, else of its first successor, else into the first lane. UML 2.5.1: 15.6.3.1 Activity partition (swimlane). | | `interruptible=` | attribute | the id of an `interruptible` declared in this diagram | The interruptible region the node belongs to; its dashed frame is drawn around all members. UML 2.5.1: 15.6.3.2 Interruptible activity region. | | `expansion=` | attribute | the id of an `expansion` declared in this diagram | The expansion region the node belongs to, run once per element. UML 2.5.1: 16.12.3 Expansion region. | | `tone=` | attribute | one of `blue`, `indigo`, `purple`, `maroon`, `green`, `teal`, `slate`, `red`, `orange`, `peach`, `sky` | Colour of the card outline in `look=cards`; without it the card is white with a grey outline. The plain look ignores it. | | `mark=` | attribute | the id of an `adr` declared in this diagram | Id of a decision of the decision bar, such as `E1`; the mark is drawn at the top right of the node. | Example: ```dgr buffer receipts "Receipts" in accounting ``` ### `send` [Section titled “send”](#send) ```text send <id> <label> [in <ref>] [interruptible=<ref>] [expansion=<ref>] [tone=<choice>] [mark=<ref>] [input=<text>] ``` A send signal action: a pentagon pointing right with the signal. It may take input pins, never output pins. UML 2.5.1: 16.3.3.2 Send signal action. Written at the top level. | Part | Kind | Value | Meaning | | ---------------- | --------- | ------------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `<id>` | argument | an identifier like `api` (letters, digits, `_` and `-`, starting with a letter) | Id that `go`, `handler` and `in` use for this node. | | `<label>` | argument | a text in double quotes like `"Order service"` | The signal that is sent. | | `in <ref>` | clause | the id of a `partition` declared in this diagram | The partition (swimlane) the node stands in. Without it, Diagrist puts the node into the lane of its first predecessor that has one, else of its first successor, else into the first lane. UML 2.5.1: 15.6.3.1 Activity partition (swimlane). | | `interruptible=` | attribute | the id of an `interruptible` declared in this diagram | The interruptible region the node belongs to; its dashed frame is drawn around all members. UML 2.5.1: 15.6.3.2 Interruptible activity region. | | `expansion=` | attribute | the id of an `expansion` declared in this diagram | The expansion region the node belongs to, run once per element. UML 2.5.1: 16.12.3 Expansion region. | | `tone=` | attribute | one of `blue`, `indigo`, `purple`, `maroon`, `green`, `teal`, `slate`, `red`, `orange`, `peach`, `sky` | Colour of the card outline in `look=cards`; without it the card is white with a grey outline. The plain look ignores it. | | `mark=` | attribute | the id of an `adr` declared in this diagram | Id of a decision of the decision bar, such as `E1`; the mark is drawn at the top right of the node. | | `input=` | attribute | a text in double quotes like `"Order service"` | Input pins by object type, separated by commas like `"Order, Amount"`; small squares on the top edge, the type beside each. UML 2.5.1: 16.2.3.3 Input and output pin of an action. | Example: ```dgr send refusal "Refusal" in service ``` ### `accept` [Section titled “accept”](#accept) ```text accept <id> <label> [in <ref>] [interruptible=<ref>] [expansion=<ref>] [tone=<choice>] [mark=<ref>] [output=<text>] ``` An accept event action: a box with a notch on the left that waits for a signal. It may give output pins, never input pins. Without an incoming edge it starts a flow of its own, such as the trigger of an interruptible region. UML 2.5.1: 16.10.3.1 Accept event action. Written at the top level. | Part | Kind | Value | Meaning | | ---------------- | --------- | ------------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `<id>` | argument | an identifier like `api` (letters, digits, `_` and `-`, starting with a letter) | Id that `go`, `handler` and `in` use for this node. | | `<label>` | argument | a text in double quotes like `"Order service"` | The signal it waits for. | | `in <ref>` | clause | the id of a `partition` declared in this diagram | The partition (swimlane) the node stands in. Without it, Diagrist puts the node into the lane of its first predecessor that has one, else of its first successor, else into the first lane. UML 2.5.1: 15.6.3.1 Activity partition (swimlane). | | `interruptible=` | attribute | the id of an `interruptible` declared in this diagram | The interruptible region the node belongs to; its dashed frame is drawn around all members. UML 2.5.1: 15.6.3.2 Interruptible activity region. | | `expansion=` | attribute | the id of an `expansion` declared in this diagram | The expansion region the node belongs to, run once per element. UML 2.5.1: 16.12.3 Expansion region. | | `tone=` | attribute | one of `blue`, `indigo`, `purple`, `maroon`, `green`, `teal`, `slate`, `red`, `orange`, `peach`, `sky` | Colour of the card outline in `look=cards`; without it the card is white with a grey outline. The plain look ignores it. | | `mark=` | attribute | the id of an `adr` declared in this diagram | Id of a decision of the decision bar, such as `E1`; the mark is drawn at the top right of the node. | | `output=` | attribute | a text in double quotes like `"Order service"` | Output pins by object type, separated by commas like `"Order, Amount"`; small squares on the bottom edge, the type beside each. UML 2.5.1: 16.2.3.3 Input and output pin of an action. | Example: ```dgr accept cancel "Cancellation requested" in warehouse interruptible=cancel ``` ### `wait` [Section titled “wait”](#wait) ```text wait <id> <label> [in <ref>] [interruptible=<ref>] [expansion=<ref>] ``` An accept time event action: an hourglass with the time beside it; the flow waits there until the time has come. Without an incoming edge it starts a flow at that time. UML 2.5.1: 16.10.4 Accept time event action drawn as an hourglass. Written at the top level. | Part | Kind | Value | Meaning | | ---------------- | --------- | ------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `<id>` | argument | an identifier like `api` (letters, digits, `_` and `-`, starting with a letter) | Id that `go`, `handler` and `in` use for this node. | | `<label>` | argument | a text in double quotes like `"Order service"` | The time or period, such as `"14 days"` or `"every Monday"`. | | `in <ref>` | clause | the id of a `partition` declared in this diagram | The partition (swimlane) the node stands in. Without it, Diagrist puts the node into the lane of its first predecessor that has one, else of its first successor, else into the first lane. UML 2.5.1: 15.6.3.1 Activity partition (swimlane). | | `interruptible=` | attribute | the id of an `interruptible` declared in this diagram | The interruptible region the node belongs to; its dashed frame is drawn around all members. UML 2.5.1: 15.6.3.2 Interruptible activity region. | | `expansion=` | attribute | the id of an `expansion` declared in this diagram | The expansion region the node belongs to, run once per element. UML 2.5.1: 16.12.3 Expansion region. | Example: ```dgr wait period "14 days" in billing ``` ### `go` [Section titled “go”](#go) ```text go <from> <arrow> <to> [guard] [pin=<text>] [weight=<number>] [else] ``` An activity edge from `from` to `to`. `->` is a control flow, `=>` an object flow, `~>` an interrupting edge that leaves an interruptible region. The guard is written without brackets and drawn as `[guard]` at the start of the edge; the flag `else` is the predefined guard `[else]`. Edges run down through the layers; an edge back up runs around the nodes on the right. Written at the top level. | Part | Kind | Value | Meaning | | --------- | ----------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | `<from>` | argument | the id of an `initial`, `final`, `flowfinal`, `action`, `decision`, `merge`, `fork`, `join`, `object`, `datastore`, `buffer`, `send`, `accept`, `wait` or `expansion` declared in this diagram | Node or expansion region the edge starts at. | | `<arrow>` | argument | one of the arrows `->` control flow, `=>` object flow, with an object node or pin at one end at least, `~>` interrupting edge out of an interruptible region, drawn with a lightning bolt | What kind of edge it is. UML 2.5.1: `->` 15.2.3.3 Control flow; `=>` 15.2.3.4 Object flow; `~>` 15.6.3.2 Edge that interrupts its region. | | `<to>` | argument | the id of an `initial`, `final`, `flowfinal`, `action`, `decision`, `merge`, `fork`, `join`, `object`, `datastore`, `buffer`, `send`, `accept`, `wait` or `expansion` declared in this diagram | Node or expansion region the edge ends at. | | `[guard]` | optional argument | a text in double quotes like `"Order service"` | Guard on an edge out of a decision, without brackets. UML 2.5.1: 15.2.3.3 Guard on an activity edge. | | `pin=` | attribute | a text in double quotes like `"Order service"` | Pin the object flow starts or ends at, when an action or expansion region has several. Without it Diagrist takes the pin of the same name at the other end, else the next free one. UML 2.5.1: 16.2.3.3 Input and output pin of an action. | | `weight=` | attribute | a number like `12` or `2.5`, at least 1 | Tokens per traversal, drawn as `{weight=n}`. UML 2.5.1: 15.2.3.3 Weight of an activity edge. | | `else` | flag | | The predefined guard `[else]`: taken when no other guard of the decision holds. UML 2.5.1: 15.3.3.6 Predefined guard else. | The values of `arrow` and what they mean: | Value | Meaning | | ----- | ----------------------------------------------------------------------------- | | `->` | control flow | | `=>` | object flow, with an object node or pin at one end at least | | `~>` | interrupting edge out of an interruptible region, drawn with a lightning bolt | Examples: ```dgr go start -> order go stock -> split "yes" go paid -> remind else go capture => receipts weight=20 ``` ### `handler` [Section titled “handler”](#handler) ```text handler <protected> <arrow> <handler> <exception> ``` An exception handler: when the protected action throws an exception of the type, the handler action takes over, and the flow goes on at the output of the protected action. The handler has no edges of its own. Diagrist puts it beside the protected action and draws a bolt to its exception pin with the type beside it; one handler may protect several actions. UML 2.5.1: 15.5.3.1 Exception handler of an executable node. Written at the top level. | Part | Kind | Value | Meaning | | ------------- | -------- | ---------------------------------------------- | ------------------------------------------------ | | `<protected>` | argument | the id of an `action` declared in this diagram | The action whose exception is handled. | | `<arrow>` | argument | one of the arrows `->` | Points from the protected action to the handler. | | `<handler>` | argument | the id of an `action` declared in this diagram | The action that handles the exception. | | `<exception>` | argument | a text in double quotes like `"Order service"` | Type of the exception. | Example: ```dgr handler capture -> open "Direct debit refused" ``` ### `adr` [Section titled “adr”](#adr) ```text adr <id> <question> <equals> <choice> [then] [consequence] [open=<text>] ``` An architecture decision in the bar below the picture: question, the chosen option after `=`, and the consequence after `=>`. `mark=` with its id puts the mark into the picture. Written at the top level. | Part | Kind | Value | Meaning | | --------------- | ----------------- | ------------------------------------------------------------------------------- | ------------------------------------------------------------- | | `<id>` | argument | an identifier like `api` (letters, digits, `_` and `-`, starting with a letter) | Id of the decision, such as `E1`; `mark=E1` refers to it. | | `<question>` | argument | a text in double quotes like `"Order service"` | The question that was decided. | | `<equals>` | argument | one of the arrows `=` | Separates the question from the choice. | | `<choice>` | argument | a text in double quotes like `"Order service"` | The chosen option. | | `[then]` | optional argument | one of the arrows `=>` | Introduces the consequence. | | `[consequence]` | optional argument | a text in double quotes like `"Order service"` | What follows from the choice. | | `open=` | attribute | a text in double quotes like `"Order service"` | Who still decides an open question; the card is drawn dashed. | Example: ```dgr adr E1 "How do the services coordinate?" = "Events over Kafka" => "No central coordinator" ``` ## Diagnostic codes [Section titled “Diagnostic codes”](#diagnostic-codes) Besides the codes of the language and the kernel, listed in [the overview](/docs/language/#diagnostic-codes), the rules of `activity` report these. An error stops the build; a warning is printed and the picture is still drawn. | Code | Severity | What it checks | | ------ | -------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `U430` | error | An initial node has no incoming edge, an activity final and a flow final node have no outgoing one. UML 2.5.1: 15.3.3.1 Initial node, 15.3.3.2 Activity final node, ending every flow, 15.3.3.2 Flow final node, ending one flow. | | `U431` | error | A decision has one incoming edge; bringing flows together is the job of a merge in front of it. UML 2.5.1: 15.3.3.6 Decision node. | | `U432` | error | A merge and a join have exactly one outgoing edge, a fork exactly one incoming edge. UML 2.5.1: 15.3.3.5 Merge node, 15.3.3.4 Join node, 15.3.3.3 Fork node. | | `U433` | error | The guards of a decision exclude each other, so none appears twice, and `else` appears at most once and only on an edge out of a decision. UML 2.5.1: 15.2.3.3 Guard on an activity edge, 15.3.3.6 Predefined guard else. | | `U434` | error | A control flow touches no object node, and an object flow has an object node, a pin or a control node it passes at one end at least. UML 2.5.1: 15.2.3.3 Control flow, 15.2.3.4 Object flow. | | `U435` | error | A join waits for all its incoming edges. When they come from alternatives of one decision, only one of them runs and the activity hangs; a merge is meant. UML 2.5.1: 15.3.3.4 Join node. | | `U437` | error | An interrupting edge `~>` starts inside an interruptible region and ends outside it. UML 2.5.1: 15.6.3.2 Edge that interrupts its region. | | `U455` | error | Pins are named object nodes of an action: a name stands once per side, and `pin=` on an object flow names an output pin of its source or an input pin of its target, or a named expansion node. UML 2.5.1: 16.2.3.3 Input and output pin of an action. | | `U456` | error | An exception handler joins two different actions. The handler action has no edges of its own, no input pin besides the exception pin, and as many output pins as the protected action: after it the flow goes on at the output of the protected action. UML 2.5.1: 15.5.3.1 Exception handler of an executable node. | | `U457` | error | An expansion region gets the collection it runs over as an object flow `=>` from outside into each of its inputs. UML 2.5.1: 16.12.3 Expansion node on the border of its region. | | `U458` | error | Expansion nodes are object nodes: only object flows `=>` start or end at an expansion region. UML 2.5.1: 16.12.3 Expansion node on the border of its region. | | `U930` | warning | UML allows no initial node or several; exam practice expects exactly one. UML 2.5.1: 15.3.3.1 Initial node. | | `U931` | warning | UML asks for one outgoing edge at least; a decision with fewer than two decides nothing. UML 2.5.1: 15.3.3.6 Decision node. | | `U932` | warning | A merge or join with fewer than two incoming edges, and a fork with fewer than two outgoing ones, has no effect. UML 2.5.1: 15.3.3.5 Merge node, 15.3.3.4 Join node, 15.3.3.3 Fork node. | | `U933` | warning | Every alternative of a decision needs a guard; otherwise it is open when it applies. UML 2.5.1: 15.2.3.3 Guard on an activity edge. | | `U934` | warning | The guards of a decision should cover every case together. Without `else` that shows only for obvious pairs such as yes and no; otherwise the flow may stop. UML 2.5.1: 15.2.3.3 Guard on an activity edge, 15.3.3.6 Predefined guard else. | | `U935` | warning | Every node should be reachable from a start: an initial node, or an accept event, time event or data store without incoming edge, which start a flow from outside. A handler counts when the action it protects does. | | `U936` | warning | UML allows an activity without end; exam practice expects one. A node without outgoing edge that is no end lets its flow run out; after a handler the flow goes on at its protected action. UML 2.5.1: 15.3.3.2 Activity final node, ending every flow, 15.3.3.2 Flow final node, ending one flow. | | `U937` | warning | A merge does not synchronize: when its incoming edges come from parallel branches of a fork, everything after it runs several times. Valid UML, but usually a join is meant. UML 2.5.1: 15.3.3.5 Merge node. | | `U938` | warning | An activity final ends every flow. When two parallel branches end in an activity final each without a join, the faster one stops the other: the main branch ends with `final`, side branches with `flowfinal`. UML 2.5.1: 15.3.3.2 Activity final node, ending every flow. | | `U939` | warning | An action with several incoming edges waits for all of them (implicit join), with several outgoing ones it starts all of them (implicit fork). Usually a merge or a decision is meant. Object flows at pins do not count: each pin is an object node of its own. UML 2.5.1: 16.2.3.1 Action. | | `U955` | warning | An interruptible region without an interrupting edge `~>` interrupts nothing: usually the edge is missing, or the frame only groups. UML 2.5.1: 15.6.3.2 Interruptible activity region. | | `U956` | warning | An edge that crosses the frame of an expansion region without an expansion node is valid UML, but leaves open whether it acts once per element or once for the whole region. The way through the input or output is clearer. UML 2.5.1: 16.12.3 Expansion region. | | `U957` | warning | An expansion region without nodes, or without an edge from its input inside, processes nothing: usually `expansion=` on the nodes or `go region => first` is missing. UML 2.5.1: 16.12.3 Expansion region. | # class > A UML class diagram (UML 2.5.1, chapters 9 to 12): classes, interfaces and enumerations with their members, packages, and the relations between them. Diagrist lays it out by itself in layers: superclasses, interfaces, wholes and users above, associated classes side by side, each package as one block. A UML class diagram (UML 2.5.1, chapters 9 to 12): classes, interfaces and enumerations with their members, packages, and the relations between them. Diagrist lays it out by itself in layers: superclasses, interfaces, wholes and users above, associated classes side by side, each package as one block. This page lists everything a `class` diagram may contain. The same grammar is available as data with `dgr grammar class --json`, and [the overview](/docs/language/) explains how lines, texts and attributes are written and lists the codes every kind shares. ## The first line [Section titled “The first line”](#the-first-line) ```text diagram class "Title" [subtitle=<text>] [look=<plain|cards>] [locale=<en|de>] ``` Every class diagram starts with this line. | Part | Kind | Value | Meaning | | ----------- | --------- | ---------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------- | | `subtitle=` | attribute | a text in double quotes like `"Order service"` | Second line below the title. | | `look=` | attribute | one of `plain`, `cards` | `plain` (default) draws the UML notation, `cards` the same layout as cards with a toned name field and toned packages. | | `locale=` | attribute | one of `en`, `de` | Language of the texts Diagrist adds to the picture and of the description: `en` (default) or `de`. | Example: ```dgr diagram class "Title" ``` ## Statements [Section titled “Statements”](#statements) Each statement is one line that starts with its keyword. Statements inside blocks are indented below them. Like every kind, `class` also has `use`, `variant`, `set` and `drop`, described in [the overview](/docs/language/#statements-of-every-kind). | Statement | Where | What it does | | ------------------------- | --------- | ----------------------------------------------------------------------------------------------------------------------------- | | [`class`](#class) | top level | A class: a box with the name, below it the compartments of attributes and operations, shown even when empty. | | [`interface`](#interface) | top level | An interface: `«interface»` above the name, operations in italics; the attribute compartment only when it holds something. | | [`enum`](#enum) | top level | An enumeration: `«enumeration»` above the name, below it one value per line. | | [`package`](#package) | top level | A package: a frame with a tab holding the name, around the classifiers `in` it. | | [`assoc`](#assoc) | top level | An n-ary association: a diamond joined to three or more classes. | | [`rel`](#rel) | top level | A relation between classifiers, read from `from` to `to`; the arrow says which (see the arrows). | | [`note`](#note) | top level | A comment on a classifier: a dashed box above it with a tip down to it, below it when lines run above. | | [`adr`](#adr) | top level | An architecture decision in the bar below the picture: question, the chosen option after `=`, and the consequence after `=>`. | ### `class` [Section titled “class”](#class) ```text class <id> <label> [in <ref>] [stereotype=<text>] [template=<text>] [tone=<choice>] [mark=<ref>] [abstract] [emph] ``` A class: a box with the name, below it the compartments of attributes and operations, shown even when empty. Members follow indented, one per line. Diagrist places classifiers in layers: superclasses and interfaces above, the whole above its parts, the user above what it uses, associated classes side by side. UML 2.5.1: 11.4.4 Class with compartments for attributes and operations. Written at the top level. | Part | Kind | Value | Meaning | | ------------- | --------- | ------------------------------------------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `<id>` | argument | an identifier like `api` (letters, digits, `_` and `-`, starting with a letter) | Id that `rel`, `note` and `class=` use for this classifier. | | `<label>` | argument | a text in double quotes like `"Order service"` | Name shown in the box. | | `in <ref>` | clause | the id of a `package` declared in this diagram | The package the classifier belongs to. | | `stereotype=` | attribute | a text in double quotes like `"Order service"` | Stereotype above the name, written without guillemets: `entity` shows `«entity»`. | | `template=` | attribute | a text in double quotes like `"Order service"` | Template parameters such as `"T"` or `"K, V"`, drawn in a dashed box at the top right corner. UML 2.5.1: 7.3.4 Template parameters in a dashed box at the top right corner. | | `tone=` | attribute | one of `blue`, `indigo`, `purple`, `maroon`, `green`, `teal`, `slate`, `red`, `orange`, `peach`, `sky` | Colour of the name field in `look=cards`; without it slate. | | `mark=` | attribute | the id of an `adr` declared in this diagram | Id of a decision of the decision bar, such as `E1`; the mark is drawn beside it. | | `abstract` | flag | | An abstract classifier: the name in italics with `{abstract}` below it. UML 2.5.1: 9.2.4 Abstract classifier, its name in italics. | | `emph` | flag | | Highlights the box in the accent colour. | Example: ```dgr class order "Order" stereotype="entity" "- number : String {readOnly}" "+ total() : Money" ``` Indented lines that start without one of these keywords have this form: ```text <text> [static] [abstract] ``` A member of the classifier as a UML text in double quotes, one per line: an attribute `"- name : Type"` or an operation `"+ total(tax : Rate) : Money"`. Visibility (`+ - # ~`) and the operation (by its parenthesis) are read from the text, as are multiplicities and properties such as `[1..*]` and `{readOnly}`. In an `enum` each line is a value. Members never wrap; the box grows to the widest one. UML 2.5.1: 9.5.4 Attribute with visibility, type, multiplicity and properties, 9.6.4 Operation with visibility, parameters, return type and properties. | Part | Kind | Value | Meaning | | ---------- | -------- | ---------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------ | | `<text>` | argument | a text in double quotes like `"Order service"` | The member as UML writes it, such as `"- iban : String {readOnly}"`. | | `static` | flag | | A member of the class, not of its instances: drawn underlined. UML 2.5.1: 9.4.4 Static feature, underlined. | | `abstract` | flag | | An operation without implementation: drawn in italics. Only in abstract classes and interfaces. UML 2.5.1: 9.6.4 Abstract operation, in italics. | Examples: ```dgr "- name : String" "+ total() : Money" abstract ``` ### `interface` [Section titled “interface”](#interface) ```text interface <id> <label> [in <ref>] [stereotype=<text>] [template=<text>] [tone=<choice>] [mark=<ref>] [abstract] [emph] ``` An interface: `«interface»` above the name, operations in italics; the attribute compartment only when it holds something. Members follow indented, one per line. Diagrist places classifiers in layers: superclasses and interfaces above, the whole above its parts, the user above what it uses, associated classes side by side. UML 2.5.1: 10.4.4 Interface with the keyword «interface». Written at the top level. | Part | Kind | Value | Meaning | | ------------- | --------- | ------------------------------------------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `<id>` | argument | an identifier like `api` (letters, digits, `_` and `-`, starting with a letter) | Id that `rel`, `note` and `class=` use for this classifier. | | `<label>` | argument | a text in double quotes like `"Order service"` | Name shown in the box. | | `in <ref>` | clause | the id of a `package` declared in this diagram | The package the classifier belongs to. | | `stereotype=` | attribute | a text in double quotes like `"Order service"` | Stereotype above the name, written without guillemets: `entity` shows `«entity»`. | | `template=` | attribute | a text in double quotes like `"Order service"` | Template parameters such as `"T"` or `"K, V"`, drawn in a dashed box at the top right corner. UML 2.5.1: 7.3.4 Template parameters in a dashed box at the top right corner. | | `tone=` | attribute | one of `blue`, `indigo`, `purple`, `maroon`, `green`, `teal`, `slate`, `red`, `orange`, `peach`, `sky` | Colour of the name field in `look=cards`; without it slate. | | `mark=` | attribute | the id of an `adr` declared in this diagram | Id of a decision of the decision bar, such as `E1`; the mark is drawn beside it. | | `abstract` | flag | | An abstract classifier: the name in italics with `{abstract}` below it. UML 2.5.1: 9.2.4 Abstract classifier, its name in italics. | | `emph` | flag | | Highlights the box in the accent colour. | Example: ```dgr interface printable "Printable" "+ print() : String" ``` Indented lines that start without one of these keywords have this form: ```text <text> [static] [abstract] ``` A member of the classifier as a UML text in double quotes, one per line: an attribute `"- name : Type"` or an operation `"+ total(tax : Rate) : Money"`. Visibility (`+ - # ~`) and the operation (by its parenthesis) are read from the text, as are multiplicities and properties such as `[1..*]` and `{readOnly}`. In an `enum` each line is a value. Members never wrap; the box grows to the widest one. UML 2.5.1: 9.5.4 Attribute with visibility, type, multiplicity and properties, 9.6.4 Operation with visibility, parameters, return type and properties. | Part | Kind | Value | Meaning | | ---------- | -------- | ---------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------ | | `<text>` | argument | a text in double quotes like `"Order service"` | The member as UML writes it, such as `"- iban : String {readOnly}"`. | | `static` | flag | | A member of the class, not of its instances: drawn underlined. UML 2.5.1: 9.4.4 Static feature, underlined. | | `abstract` | flag | | An operation without implementation: drawn in italics. Only in abstract classes and interfaces. UML 2.5.1: 9.6.4 Abstract operation, in italics. | Examples: ```dgr "- name : String" "+ total() : Money" abstract ``` ### `enum` [Section titled “enum”](#enum) ```text enum <id> <label> [in <ref>] [stereotype=<text>] [template=<text>] [tone=<choice>] [mark=<ref>] [abstract] [emph] ``` An enumeration: `«enumeration»` above the name, below it one value per line. Members follow indented, one per line. Diagrist places classifiers in layers: superclasses and interfaces above, the whole above its parts, the user above what it uses, associated classes side by side. UML 2.5.1: 10.2.4 Enumeration with its literals. Written at the top level. | Part | Kind | Value | Meaning | | ------------- | --------- | ------------------------------------------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `<id>` | argument | an identifier like `api` (letters, digits, `_` and `-`, starting with a letter) | Id that `rel`, `note` and `class=` use for this classifier. | | `<label>` | argument | a text in double quotes like `"Order service"` | Name shown in the box. | | `in <ref>` | clause | the id of a `package` declared in this diagram | The package the classifier belongs to. | | `stereotype=` | attribute | a text in double quotes like `"Order service"` | Stereotype above the name, written without guillemets: `entity` shows `«entity»`. | | `template=` | attribute | a text in double quotes like `"Order service"` | Template parameters such as `"T"` or `"K, V"`, drawn in a dashed box at the top right corner. UML 2.5.1: 7.3.4 Template parameters in a dashed box at the top right corner. | | `tone=` | attribute | one of `blue`, `indigo`, `purple`, `maroon`, `green`, `teal`, `slate`, `red`, `orange`, `peach`, `sky` | Colour of the name field in `look=cards`; without it slate. | | `mark=` | attribute | the id of an `adr` declared in this diagram | Id of a decision of the decision bar, such as `E1`; the mark is drawn beside it. | | `abstract` | flag | | An abstract classifier: the name in italics with `{abstract}` below it. UML 2.5.1: 9.2.4 Abstract classifier, its name in italics. | | `emph` | flag | | Highlights the box in the accent colour. | Example: ```dgr enum status "Status" "OPEN" "PAID" ``` Indented lines that start without one of these keywords have this form: ```text <text> [static] [abstract] ``` A member of the classifier as a UML text in double quotes, one per line: an attribute `"- name : Type"` or an operation `"+ total(tax : Rate) : Money"`. Visibility (`+ - # ~`) and the operation (by its parenthesis) are read from the text, as are multiplicities and properties such as `[1..*]` and `{readOnly}`. In an `enum` each line is a value. Members never wrap; the box grows to the widest one. UML 2.5.1: 9.5.4 Attribute with visibility, type, multiplicity and properties, 9.6.4 Operation with visibility, parameters, return type and properties. | Part | Kind | Value | Meaning | | ---------- | -------- | ---------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------ | | `<text>` | argument | a text in double quotes like `"Order service"` | The member as UML writes it, such as `"- iban : String {readOnly}"`. | | `static` | flag | | A member of the class, not of its instances: drawn underlined. UML 2.5.1: 9.4.4 Static feature, underlined. | | `abstract` | flag | | An operation without implementation: drawn in italics. Only in abstract classes and interfaces. UML 2.5.1: 9.6.4 Abstract operation, in italics. | Examples: ```dgr "- name : String" "+ total() : Money" abstract ``` ### `package` [Section titled “package”](#package) ```text package <id> <label> [in <ref>] [tone=<choice>] ``` A package: a frame with a tab holding the name, around the classifiers `in` it. Packages nest with `in`. Between packages, and between a package and a classifier, only dependencies `-->` exist, optionally with `import` or `access`. A package without classifiers is not drawn. UML 2.5.1: 12.2.4 Package as a frame with its name in the tab. Written at the top level. | Part | Kind | Value | Meaning | | ---------- | --------- | ------------------------------------------------------------------------------------------------------ | ----------------------------------------------------- | | `<id>` | argument | an identifier like `api` (letters, digits, `_` and `-`, starting with a letter) | Id that `in`, `rel` and `note` use for this package. | | `<label>` | argument | a text in double quotes like `"Order service"` | Name shown in the tab. | | `in <ref>` | clause | the id of a `package` declared in this diagram | The package this one is nested in. | | `tone=` | attribute | one of `blue`, `indigo`, `purple`, `maroon`, `green`, `teal`, `slate`, `red`, `orange`, `peach`, `sky` | Colour of its area in `look=cards`; without it slate. | Examples: ```dgr package domain "domain" package persistence "persistence" in backend ``` ### `assoc` [Section titled “assoc”](#assoc) ```text assoc <id> [label] [in <ref>] [class=<ref>] [mark=<ref>] [emph] ``` An n-ary association: a diamond joined to three or more classes. Each end is a leg `rel <assoc> -- <class> card=... role=...`; multiplicity and role stand at the class end and say how many objects there belong to one fixed combination of the other ends. The name stands at the top right of the diamond. Diagrist places the diamond in the middle of its ends: the first two left and right, the third below, the fourth (or the association class) above. UML 2.5.1: 11.5.4 N-ary association as a diamond with a leg to each end. Written at the top level. | Part | Kind | Value | Meaning | | ---------- | ----------------- | ------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------- | | `<id>` | argument | an identifier like `api` (letters, digits, `_` and `-`, starting with a letter) | Id that the legs `rel <id> -- <class>` use. | | `[label]` | optional argument | a text in double quotes like `"Order service"` | Name of the association, shown at the top right of the diamond. | | `in <ref>` | clause | the id of a `package` declared in this diagram | The package the association belongs to. | | `class=` | attribute | the id of a `class` declared in this diagram | The association class: a class that is this association, joined dashed to the diamond. UML 2.5.1: 11.5.4 Association class joined by a dashed line. | | `mark=` | attribute | the id of an `adr` declared in this diagram | Id of a decision of the decision bar, such as `E1`; the mark is drawn beside it. | | `emph` | flag | | Highlights the diamond in the accent colour. | Example: ```dgr assoc lesson "Lesson" class=unit ``` ### `rel` [Section titled “rel”](#rel) ```text rel <from> <arrow> <to> [label] [source=<multiplicity>] [card=<multiplicity>] [role=<text>] [srole=<text>] [nonav=<from|to|both>] [class=<ref>] [import] [access] [emph] ``` A relation between classifiers, read from `from` to `to`; the arrow says which (see the arrows). `card=` and `role=` stand at `to`, `source=` and `srole=` at `from`. Generalizations and realizations with the same target share one triangle. A relation of a class with itself is a loop. A leg of an n-ary association runs from the `assoc` to a class. Written at the top level. | Part | Kind | Value | Meaning | | --------- | ----------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `<from>` | argument | the id of a `class`, `interface`, `enum`, `assoc` or `package` declared in this diagram | Classifier, n-ary association or package the relation starts at. | | `<arrow>` | argument | one of the arrows `--` association, navigability open at both ends, `->` directed association, navigable towards `to` (open head there), `<->` association navigable at both ends (open heads at both), `-->` dependency, dashed with an open head at `to`; between packages with `import` or `access`, `-\|>` generalization: `from` is a special kind of `to`, hollow triangle at `to`, `--\|>` realization: `from` implements the interface `to`, dashed with a hollow triangle, `o--` aggregation: `from` is the whole, hollow diamond at `from`, `*--` composition: `from` is the whole that owns its parts, filled diamond at `from` | What kind of relation it is. UML 2.5.1: `--` 11.5.4 Binary association as a line with its name; `->` 11.5.4 Binary association as a line with its name, 11.5.4 Navigable end with an open arrowhead; `<->` 11.5.4 Binary association as a line with its name, 11.5.4 Navigable end with an open arrowhead; `-->` 7.7.4 Dependency as a dashed arrow; `-\|>` 9.2.3.2 Generalization between classifiers; `--\|>` 10.4.4 Realization of an interface, dashed with a hollow triangle; `o--` 11.5.4 Shared aggregation with a hollow diamond at the whole; `*--` 11.5.4 Composition with a filled diamond at the whole. | | `<to>` | argument | the id of a `class`, `interface`, `enum`, `assoc` or `package` declared in this diagram | Classifier, n-ary association or package the relation points to. | | `[label]` | optional argument | a text in double quotes like `"Order service"` | Name of the relation, shown at the middle of the line. | | `source=` | attribute | a UML multiplicity like `1`, `0..1`, `1..*` or `*`, the lower bound not above the upper one | Multiplicity at `from`: how many `from` belong to one `to`. UML 2.5.1: 7.5.4 Multiplicity at an end or of a property. | | `card=` | attribute | a UML multiplicity like `1`, `0..1`, `1..*` or `*`, the lower bound not above the upper one | Multiplicity at `to`: how many `to` belong to one `from`. UML 2.5.1: 7.5.4 Multiplicity at an end or of a property. | | `role=` | attribute | a text in double quotes like `"Order service"` | Role name at `to`, written opposite the multiplicity. UML 2.5.1: 11.5.4 Role name at an end of an association. | | `srole=` | attribute | a text in double quotes like `"Order service"` | Role name at `from`. UML 2.5.1: 11.5.4 Role name at an end of an association. | | `nonav=` | attribute | one of `from`, `to`, `both` | Ends that are not navigable: a small x shortly before the end. Only on associations, never at an end with an arrowhead. UML 2.5.1: 11.5.4 Non-navigable end with a small x. | | `class=` | attribute | the id of a `class` declared in this diagram | The association class: a class that is this association too, joined dashed to the middle of the line and placed below it. UML 2.5.1: 11.5.4 Association class joined by a dashed line. | | `import` | flag | | A package import `«import»` on a dependency `-->`. UML 2.5.1: 7.4.4 Package import with the keyword «import» or «access». | | `access` | flag | | A private package import `«access»` on a dependency `-->`. UML 2.5.1: 7.4.4 Package import with the keyword «import» or «access». | | `emph` | flag | | Highlights the line in the accent colour. | The values of `arrow` and what they mean: | Value | Meaning | | ------- | ---------------------------------------------------------------------------------------- | | `--` | association, navigability open at both ends | | `->` | directed association, navigable towards `to` (open head there) | | `<->` | association navigable at both ends (open heads at both) | | `-->` | dependency, dashed with an open head at `to`; between packages with `import` or `access` | | `-\|>` | generalization: `from` is a special kind of `to`, hollow triangle at `to` | | `--\|>` | realization: `from` implements the interface `to`, dashed with a hollow triangle | | `o--` | aggregation: `from` is the whole, hollow diamond at `from` | | `*--` | composition: `from` is the whole that owns its parts, filled diamond at `from` | Examples: ```dgr rel customer -- order "places" source=1 card=0..* rel order *-- item source=1 card=1..* rel invoice -|> document rel repo --|> port rel student -- course "takes" source=* card=* class=enrolment rel web --> domain import ``` ### `note` [Section titled “note”](#note) ```text note <text> [on <ref>] ``` A comment on a classifier: a dashed box above it with a tip down to it, below it when lines run above. UML 2.5.1: 7.2.3.2 Comment (note). Written at the top level. | Part | Kind | Value | Meaning | | ---------- | -------- | ------------------------------------------------------------------- | --------------------------------------------- | | `<text>` | argument | a text in double quotes like `"Order service"` | What the note says, in one line. | | `on <ref>` | clause | the id of a `class`, `interface` or `enum` declared in this diagram | The classifier the note belongs to. Required. | Example: ```dgr note "Exactly one lecturer per lesson" on lecturer ``` ### `adr` [Section titled “adr”](#adr) ```text adr <id> <question> <equals> <choice> [then] [consequence] [open=<text>] ``` An architecture decision in the bar below the picture: question, the chosen option after `=`, and the consequence after `=>`. `mark=` with its id puts the mark into the picture. Written at the top level. | Part | Kind | Value | Meaning | | --------------- | ----------------- | ------------------------------------------------------------------------------- | ------------------------------------------------------------- | | `<id>` | argument | an identifier like `api` (letters, digits, `_` and `-`, starting with a letter) | Id of the decision, such as `E1`; `mark=E1` refers to it. | | `<question>` | argument | a text in double quotes like `"Order service"` | The question that was decided. | | `<equals>` | argument | one of the arrows `=` | Separates the question from the choice. | | `<choice>` | argument | a text in double quotes like `"Order service"` | The chosen option. | | `[then]` | optional argument | one of the arrows `=>` | Introduces the consequence. | | `[consequence]` | optional argument | a text in double quotes like `"Order service"` | What follows from the choice. | | `open=` | attribute | a text in double quotes like `"Order service"` | Who still decides an open question; the card is drawn dashed. | Example: ```dgr adr E1 "How do the services coordinate?" = "Events over Kafka" => "No central coordinator" ``` ## Diagnostic codes [Section titled “Diagnostic codes”](#diagnostic-codes) Besides the codes of the language and the kernel, listed in [the overview](/docs/language/#diagnostic-codes), the rules of `class` report these. An error stops the build; a warning is printed and the picture is still drawn. | Code | Severity | What it checks | | ------ | -------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `U410` | error | A realization `--\|>` runs from a class or enumeration to an interface: its target is an interface, its source is none. UML 2.5.1: 10.4.4 Realization of an interface, dashed with a hollow triangle. | | `U411` | error | A generalization `-\|>` joins classifiers of one kind (class with class, interface with interface) and runs in no cycle; the triangle points at the more general one. A class implements an interface with `--\|>`. UML 2.5.1: 9.2.3.2 Generalization between classifiers. | | `U412` | error | Only operations are abstract, and only in abstract classes and interfaces: an abstract operation of a concrete class has no implementation anywhere. UML 2.5.1: 9.6.4 Abstract operation, in italics. | | `U413` | error | A member is a UML text: `[visibility] name : Type` for an attribute, `[visibility] name(p : Type) : Type` for an operation; a value of an enumeration is a plain name without `static` or `abstract`. UML 2.5.1: 9.5.4 Attribute with visibility, type, multiplicity and properties, 9.6.4 Operation with visibility, parameters, return type and properties, 10.2.4 Enumeration with its literals. | | `U414` | error | Generalization, realization and dependency join types, not objects: their ends have no multiplicity and no role. UML 2.5.1: 7.7.4 Dependency as a dashed arrow, 9.2.3.2 Generalization between classifiers, 10.4.4 Realization of an interface, dashed with a hollow triangle. | | `U415` | error | A part belongs to at most one whole at a time: the multiplicity at the whole of a composition `*--` is `1` or `0..1`. UML 2.5.1: 11.5.4 Composition with a filled diamond at the whole. | | `U416` | error | A classifier names each attribute once and each operation once per list of parameter types; overloads with other parameter types are allowed. UML 2.5.1: 9.5.4 Attribute with visibility, type, multiplicity and properties, 9.6.4 Operation with visibility, parameters, return type and properties. | | `U417` | error | An association class is an association and a class at once: `class=` stands on an association between classifiers or on an `assoc`, names a `class` (the table allows no other) that is none of its own ends, and each association class belongs to exactly one association. UML 2.5.1: 11.5.4 Association class joined by a dashed line. | | `U418` | error | A package is no classifier: it is an end of dependencies `-->` only. `import` and `access` mark package imports, so they belong to dependencies `-->`. UML 2.5.1: 12.2.4 Package as a frame with its name in the tab, 7.4.4 Package import with the keyword «import» or «access». | | `U419` | error | A package already holds its members; a dependency between a package and its own content says nothing. UML 2.5.1: 12.2.4 Package as a frame with its name in the tab, 7.7.4 Dependency as a dashed arrow. | | `U470` | error | An end is navigable (open head), not navigable (x) or open. An x at an end with an arrowhead contradicts itself, and generalization, realization and dependency have no navigable ends. UML 2.5.1: 11.5.4 Navigable end with an open arrowhead, 11.5.4 Non-navigable end with a small x. | | `U471` | error | A note in a class diagram is a comment on one classifier: it names it with `on`. UML 2.5.1: 7.2.3.2 Comment (note). | | `U910` | warning | UML allows ends without multiplicity; exam practice, like the learning platform, asks for both ends of an association, aggregation or composition. A leg of an n-ary association needs it at the class end only. UML 2.5.1: 7.5.4 Multiplicity at an end or of a property. | | `U911` | warning | Two relations between the same classifiers can only be told apart by a name or a role. UML 2.5.1: 11.5.4 Binary association as a line with its name, 11.5.4 Role name at an end of an association. | | `U912` | warning | Packages should depend on each other without cycles (acyclic dependencies principle). Dependencies `-->` between packages and between classifiers of different packages count; UML allows cycles, so it is a warning, once per cycle. UML 2.5.1: 12.2.4 Package as a frame with its name in the tab. | | `U913` | warning | A package without classifiers, also in its nested packages, has no frame: it is not drawn, and relations to it are left out. UML 2.5.1: 12.2.4 Package as a frame with its name in the tab. | | `U916` | warning | `{readOnly}` makes an attribute unchangeable, `{query}` an operation free of side effects. Swapped, neither says anything; the text is drawn as written. UML 2.5.1: 9.5.4 Attribute with visibility, type, multiplicity and properties, 9.6.4 Operation with visibility, parameters, return type and properties. | | `U917` | warning | An n-ary association joins three or more ends. With two legs it is a binary association, drawn as a line without diamond. UML 2.5.1: 11.5.4 N-ary association as a diamond with a leg to each end. | | `U918` | warning | A leg of an n-ary association is a line from the diamond to a class: `--`, or `->` towards the class. Name and association class belong to the diamond, multiplicity and role to the class end; aggregation and composition exist only between two ends. UML 2.5.1: 11.5.4 N-ary association as a diamond with a leg to each end. | # code > A code diagram: excerpts of real source files as highlighted cards, one below the other, with marked lines, numbered notes below each card and arrows from a call to what it calls. The files are read when the picture is built, so a renamed method fails the build instead of leaving a stale picture. Java, Kotlin, SQL, YAML, JSON and XML are highlighted. A code diagram: excerpts of real source files as highlighted cards, one below the other, with marked lines, numbered notes below each card and arrows from a call to what it calls. The files are read when the picture is built, so a renamed method fails the build instead of leaving a stale picture. Java, Kotlin, SQL, YAML, JSON and XML are highlighted. This page lists everything a `code` diagram may contain. The same grammar is available as data with `dgr grammar code --json`, and [the overview](/docs/language/) explains how lines, texts and attributes are written and lists the codes every kind shares. ## The first line [Section titled “The first line”](#the-first-line) ```text diagram code "Title" [subtitle=<text>] [locale=<en|de>] ``` Every code diagram starts with this line. | Part | Kind | Value | Meaning | | ----------- | --------- | ---------------------------------------------- | -------------------------------------------------------------------------------------------------- | | `subtitle=` | attribute | a text in double quotes like `"Order service"` | Second line below the title. | | `locale=` | attribute | one of `en`, `de` | Language of the texts Diagrist adds to the picture and of the description: `en` (default) or `de`. | Example: ```dgr diagram code "Title" ``` ## Statements [Section titled “Statements”](#statements) Each statement is one line that starts with its keyword. Statements inside blocks are indented below them. Like every kind, `code` also has `use`, `variant`, `set` and `drop`, described in [the overview](/docs/language/#statements-of-every-kind). | Statement | Where | What it does | | ------------------- | --------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- | | [`source`](#source) | top level | A card of highlighted code read from a file when the picture is built, so it shows the code as it is now and the build fails when the code it points to is gone. | | [`mark`](#mark) | inside `source` | Marks lines of the card with a band and a number, counted across the picture; the note stands under that number below the card. | | [`link`](#link) | top level | An arrow from a line of one card to another card: this call leads there. | ### `source` [Section titled “source”](#source) ```text source <id> <title> [src=<file>] [symbol=<word>] [region=<word>] [lines=<lineRange>] [lang=<choice>] [outline] ``` A card of highlighted code read from a file when the picture is built, so it shows the code as it is now and the build fails when the code it points to is gone. `symbol` (a declaration by name) follows the code when lines move and is the first choice, `region` (between `#region` comments) the second, `lines` the last; without any of them the card shows the whole file. Cards stand one below the other in the order of the diagram; the lines keep the numbers of the source file. Written at the top level. Indented below it: `mark`. | Part | Kind | Value | Meaning | | --------- | --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `<id>` | argument | an identifier like `api` (letters, digits, `_` and `-`, starting with a letter) | Id of the card, which `link` names. | | `<title>` | argument | a text in double quotes like `"Order service"` | Caption in the head of the card, such as the class and the method. | | `src=` | attribute | a path in double quotes, relative to the diagram, like `"src/OrderService.java"`; it stays inside the folder `dgr` runs in and names no hidden file or folder | The source file, a path in double quotes relative to the diagram. Required. | | `symbol=` | attribute | a single word without quotes | Only the declaration of this method or type (Java, Kotlin): the annotations and the comment right above it, then everything to its closing brace. A call of the name does not count. | | `region=` | attribute | a single word without quotes | Only the lines between `#region <name>` and `#endregion` comments in the file, in the comment syntax of its language (`// #region publish`, `-- #region find`, `<!-- #region deps -->`), without the markers. | | `lines=` | attribute | a line like `31` or a range like `27-30`, counted from 1, the smaller number first | Only this range of lines, like `25-36`. Drifts when lines are added above it. | | `lang=` | attribute | one of `java`, `kotlin`, `sql`, `yaml`, `json`, `xml`, `text` | Language of the code. Default: from the extension of `src` (`.java`, `.kt`, `.kts`, `.sql`, `.yaml`, `.yml`, `.json`, `.xml`, `.xsd`), else `text`, which draws the code without colours. | | `outline` | flag | | Zooms out: declarations, fields, annotations and member signatures, each member body folded into `{ … }`; package, imports, comments and blank lines go. | Examples: ```dgr source submit "TransferService.submit" src="TransferService.java" symbol=submit source publish "Outbox.publish" src="Outbox.java" region=publish source table "outbox_entry" src="outbox.sql" lines=2-9 source api "TransferService" src="TransferService.java" outline ``` ### `mark` [Section titled “mark”](#mark) ```text mark <range> [note] ``` Marks lines of the card with a band and a number, counted across the picture; the note stands under that number below the card. The lines are numbered as in the file, so they must be lines the card shows. Written only inside `source`. | Part | Kind | Value | Meaning | | --------- | ----------------- | ---------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------- | | `<range>` | argument | a line like `31` or a range like `27-30`, counted from 1, the smaller number first | A line or a range of lines in the numbers of the file, like `31` or `27-30`. | | `[note]` | optional argument | a text in double quotes like `"Order service"` | What these lines do and why, listed below the card. Without it only the band and the number show. | Examples: ```dgr mark 27-30 "A second call with the same key returns the first transfer" mark 34 ``` ### `link` [Section titled “link”](#link) ```text link <from> <fromLine> <arrow> <to> [label] ``` An arrow from a line of one card to another card: this call leads there. It leaves the card at the right edge of the line and enters the other card at its head. Written at the top level. | Part | Kind | Value | Meaning | | ------------ | ----------------- | ---------------------------------------------- | -------------------------------------------------------------------------------- | | `<from>` | argument | the id of a `source` declared in this diagram | The card the arrow starts in. | | `<fromLine>` | argument | a number like `12` or `2.5`, at least 1 | The line the arrow starts at, in the numbers of the file; the card must show it. | | `<arrow>` | argument | one of the arrows `->` leads to | Always `->`. | | `<to>` | argument | the id of a `source` declared in this diagram | The card the arrow points to. | | `[label]` | optional argument | a text in double quotes like `"Order service"` | What happens on the way, such as the call, written beside the arrow. | The values of `arrow` and what they mean: | Value | Meaning | | ----- | -------- | | `->` | leads to | Example: ```dgr link submit 34 -> publish "outbox.publish(event)" ``` ## Diagnostic codes [Section titled “Diagnostic codes”](#diagnostic-codes) Besides the codes of the language and the kernel, listed in [the overview](/docs/language/#diagnostic-codes), the rules of `code` report these. An error stops the build; a warning is printed and the picture is still drawn. | Code | Severity | What it checks | | ------ | -------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `S100` | error | Every card names its file with `src=`; the picture shows that file as it is when it is built. | | `S101` | error | A card selects its lines in one way at most: `symbol=`, `region=` or `lines=`. | | `S102` | error | The declaration, region or lines a card selects exist in its file as it is now. The finding names what the file declares or marks instead, and the nearest name. | | `S103` | error | A mark names lines its card shows, counted as in the file. | | `S104` | error | A link starts at a line its card shows and leads to another card. | | `S600` | warning | A card shows at most 40 lines; more is read in the editor, not in a picture. | # component > A C4 component diagram (level 3): the components inside a container and what they depend on, placed in a named grid. A C4 component diagram (level 3): the components inside a container and what they depend on, placed in a named grid. This page lists everything a `component` diagram may contain. The same grammar is available as data with `dgr grammar component --json`, and [the overview](/docs/language/) explains how lines, texts and attributes are written and lists the codes every kind shares. ## The first line [Section titled “The first line”](#the-first-line) ```text diagram component "Title" [subtitle=<text>] [label=<text>] [look=<plain|cards|blocks|paper|columns>] [decisions=<right|below|auto>] [layout=<adaptive>] [locale=<en|de>] ``` Every component diagram starts with this line. | Part | Kind | Value | Meaning | | ------------ | --------- | ----------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `subtitle=` | attribute | a text in double quotes like `"Order service"` | Second line below the title. | | `label=` | attribute | a text in double quotes like `"Order service"` | Name before the title instead of the kind; an empty `label=""` leaves only the title. | | `look=` | attribute | one of `plain`, `cards`, `blocks`, `paper`, `columns` | `plain` (default) boxes with a legend, `cards` toned icon cards, `blocks` filled blocks as in pattern books, `paper` a quiet print look: Inter on paper, zones as areas, the core in yellow, decisions in the margin, `columns` a technical sheet: columns in bands under grey heads, names in the top edge of square boxes, the focus flow heavy. | | `decisions=` | attribute | one of `right`, `below`, `auto` | Where a look that writes decisions as notes sets them: `right` (default) in a column beside the picture, `below` side by side under it, `auto` below once the picture is wider than 1,100 pixels, as a printed page needs. | | `layout=` | attribute | one of `adaptive` | Columns grow to their content and edges find their own way around obstacles; without it the grid is fixed. | | `locale=` | attribute | one of `en`, `de` | Language of the texts Diagrist adds to the picture and of the description: `en` (default) or `de`. | Example: ```dgr diagram component "Title" ``` ## Statements [Section titled “Statements”](#statements) Each statement is one line that starts with its keyword. Statements inside blocks are indented below them. Like every kind, `component` also has `use`, `variant`, `set` and `drop`, described in [the overview](/docs/language/#statements-of-every-kind). | Statement | Where | What it does | | ------------------------- | --------- | ----------------------------------------------------------------------------------------------------------------------------- | | [`grid`](#grid) | top level | The named columns from left to right, or the rows from top to bottom. | | [`layer`](#layer) | top level | Names a row in a box right of the picture, joined by one bracket for all layers; needs `layout=adaptive`. | | [`group`](#group) | top level | A frame around elements by responsibility; it grows from its members. | | [`style`](#style) | top level | Named values for elements, and a tone for edges, so sizes and colours stand in one place. | | [`person`](#person) | top level | A person who uses the system, drawn as a stick figure with name and role below it. | | [`container`](#container) | top level | A container: an application or data store that runs on its own, such as a service or a database. | | [`component`](#component) | top level | A component inside a container, such as a module or an adapter. | | [`node`](#node) | top level | A neutral element for any level, such as a queue, a job or a layer of a pattern. | | [`edge`](#edge) | top level | An edge outside of flows, without number. | | [`flow`](#flow) | top level | A numbered path: its steps are indented below it. | | [`note`](#note) | top level | A dashed note above an element, with a tip pointing at it. | | [`adr`](#adr) | top level | An architecture decision in the bar below the picture: question, the chosen option after `=`, and the consequence after `=>`. | ### `grid` [Section titled “grid”](#grid) ```text grid <axis> <names> ``` The named columns from left to right, or the rows from top to bottom. Names with the same prefix before a dot stand close, such as `api.1,api.2`. Written at the top level. | Part | Kind | Value | Meaning | | --------- | -------- | ----------------------------------------------------------------- | ------------------------------------------------------- | | `<axis>` | argument | one of `cols`, `rows` | `cols` for the columns, `rows` for the rows. | | `<names>` | argument | names separated by commas without spaces, like `user,api.1,api.2` | The names in order, separated by commas without spaces. | Examples: ```dgr grid cols user,backend.1,backend.2,edge grid rows top,main,data ``` ### `layer` [Section titled “layer”](#layer) ```text layer <row> <label> ``` Names a row in a box right of the picture, joined by one bracket for all layers; needs `layout=adaptive`. Written at the top level. | Part | Kind | Value | Meaning | | --------- | -------- | ---------------------------------------------- | ------------------ | | `<row>` | argument | a column or row name like `api` or `backend.1` | The row it names. | | `<label>` | argument | a text in double quotes like `"Order service"` | Name of the layer. | Example: ```dgr layer business "Business logic" ``` ### `group` [Section titled “group”](#group) ```text group <id> <title> [in <ref>] [team=<text>] [heading=<top|side>] [tag=<text>] [cover=<grid-name>] [tone=<choice>] [own] [shared] [external] ``` A frame around elements by responsibility; it grows from its members. Exactly one of `own`, `shared`, `external`. `in` nests it into another group; an empty title draws only the frame. Written at the top level. | Part | Kind | Value | Meaning | | ---------- | --------- | ------------------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------- | | `<id>` | argument | an identifier like `api` (letters, digits, `_` and `-`, starting with a letter) | Id that `in` of elements and groups and the ends of edges use. | | `<title>` | argument | a text in double quotes like `"Order service"` | Title in the head of the frame. | | `in <ref>` | clause | the id of a `group` declared in this diagram | The group whose frame holds this one. | | `team=` | attribute | a text in double quotes like `"Order service"` | Who is responsible; second line of the head, else the role in words. | | `heading=` | attribute | one of `top`, `side` | `top` (default) or `side`: title left in the middle, as for layer bands. | | `tag=` | attribute | a text in double quotes like `"Order service"` | A tag right in the frame, such as `"CLOSED"` for a closed layer. | | `cover=` | attribute | a column or row name like `api` or `backend.1` | A column the frame also covers, at the height of its members; needs `layout=adaptive`. | | `tone=` | attribute | one of `blue`, `indigo`, `purple`, `maroon`, `green`, `teal`, `slate`, `red`, `orange`, `peach`, `sky` | Fills the frame lightly in this tone; in `look=blocks` the colour of its area. | | `own` | flag | | Our own system: a solid frame on a light area. | | `shared` | flag | | Shared infrastructure: its elements are drawn muted. | | `external` | flag | | Someone else’s system: a dashed frame. | Examples: ```dgr group backend "Backend" own team="Kotlin · Team Ausleihe" group api "API" own in backend ``` ### `style` [Section titled “style”](#style) ```text style <id> [icon=<choice>] [shape=<db|queue|store|job|app>] [width=<integer>] [height=<integer>] [tone=<choice>] [form=<card|circle|text>] ``` Named values for elements, and a tone for edges, so sizes and colours stand in one place. `style=name` applies them where the element or edge sets none. Written at the top level. | Part | Kind | Value | Meaning | | --------- | --------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------- | | `<id>` | argument | an identifier like `api` (letters, digits, `_` and `-`, starting with a letter) | Name that `style=` refers to. | | `icon=` | attribute | one of `apachekafka`, `archive`, `boxes`, `brick-wall`, `building-2`, `chart-line`, `cloud`, `container`, `copy`, `cpu`, `database`, `earth`, `file-cog`, `file-text`, `files`, `flame`, `folder`, `gauge`, `globe`, `hard-drive`, `hexagon`, `key-round`, `keycloak`, `kubernetes`, `layers`, `layout-dashboard`, `lock`, `map-pin`, `minio`, `monitor`, `network`, `package`, `postgresql`, `puzzle`, `receipt`, `route`, `router`, `server`, `server-cog`, `settings`, `shield`, `shield-check`, `smartphone`, `split`, `springboot`, `terminal`, `user-cog`, `user-round`, `users`, `vuedotjs`, `warehouse`, `waypoints`, `workflow` | Pictogram before the name: the technology or the role of the element. | | `shape=` | attribute | one of `db`, `queue`, `store`, `job`, `app` | Form of the box: `db` cylinder, `queue` tube, `store` folded sheet, `job`, `app`. | | `width=` | attribute | a whole number from 48 to 960 | Width of the box in pixels; needs `layout=adaptive`. | | `height=` | attribute | a whole number from 24 to 480 | Height of the box in pixels; needs `layout=adaptive`. | | `tone=` | attribute | one of `blue`, `indigo`, `purple`, `maroon`, `green`, `teal`, `slate`, `red`, `orange`, `peach`, `sky` | Colour of the icon circle in `look=cards` and of the block in `look=blocks`. | | `form=` | attribute | one of `card`, `circle`, `text` | `card` or `circle` in `look=cards`; `text` draws only the name in `look=blocks`. | Examples: ```dgr style component height=80 style store shape=db height=96 ``` ### `person` [Section titled “person”](#person) ```text person <id> <label> [at <place>] [in <ref>] [tech=<text>] [icon=<choice>] [shape=<db|queue|store|job|app>] [width=<integer>] [height=<integer>] [tone=<choice>] [form=<card|circle|text>] [status=<planned|deprecated>] [replicas=<integer>] [span=<span>] [slot=<slot>] [style=<ref>] [mark=<ref>] [emph] ``` A person who uses the system, drawn as a stick figure with name and role below it. `at` places it in the grid, `in` puts it into a group. `emph` marks a core decision with a thick border. Written at the top level. | Part | Kind | Value | Meaning | | ------------ | --------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------- | | `<id>` | argument | an identifier like `api` (letters, digits, `_` and `-`, starting with a letter) | Id that edges, flows, notes and `in` use for this element. | | `<label>` | argument | a text in double quotes like `"Order service"` | Name in the picture. | | `at <place>` | clause | a place `column/row` like `backend.1/main` | Place in the grid as `column/row`. Required. | | `in <ref>` | clause | the id of a `group` declared in this diagram | The group whose frame holds the element. | | `tech=` | attribute | a text in double quotes like `"Order service"` | Second line: technology or role, such as `"PostgreSQL"`. | | `icon=` | attribute | one of `apachekafka`, `archive`, `boxes`, `brick-wall`, `building-2`, `chart-line`, `cloud`, `container`, `copy`, `cpu`, `database`, `earth`, `file-cog`, `file-text`, `files`, `flame`, `folder`, `gauge`, `globe`, `hard-drive`, `hexagon`, `key-round`, `keycloak`, `kubernetes`, `layers`, `layout-dashboard`, `lock`, `map-pin`, `minio`, `monitor`, `network`, `package`, `postgresql`, `puzzle`, `receipt`, `route`, `router`, `server`, `server-cog`, `settings`, `shield`, `shield-check`, `smartphone`, `split`, `springboot`, `terminal`, `user-cog`, `user-round`, `users`, `vuedotjs`, `warehouse`, `waypoints`, `workflow` | Pictogram before the name: the technology or the role of the element. | | `shape=` | attribute | one of `db`, `queue`, `store`, `job`, `app` | Form of the box: `db` cylinder, `queue` tube, `store` folded sheet, `job`, `app`. | | `width=` | attribute | a whole number from 48 to 960 | Width of the box in pixels; needs `layout=adaptive`. | | `height=` | attribute | a whole number from 24 to 480 | Height of the box in pixels; needs `layout=adaptive`. | | `tone=` | attribute | one of `blue`, `indigo`, `purple`, `maroon`, `green`, `teal`, `slate`, `red`, `orange`, `peach`, `sky` | Colour of the icon circle in `look=cards` and of the block in `look=blocks`. | | `form=` | attribute | one of `card`, `circle`, `text` | `card` or `circle` in `look=cards`; `text` draws only the name in `look=blocks`. | | `status=` | attribute | one of `planned`, `deprecated` | `planned` draws the box dashed, `deprecated` grey; both name it beside `tech`. | | `replicas=` | attribute | a whole number from 2 to 99 | Number of instances from 2, shown as `x3` in the corner. | | `span=` | attribute | the last column like `mobile`, or `column/row` like `edge/data` | Last column, or `column/row`, of the area the element covers; needs `layout=adaptive`. | | `slot=` | attribute | `i/n` with 1 ≤ i ≤ n ≤ 64, like `2/3` | Takes place `i` of `n` equal places in its area, like `2/3`; needs `layout=adaptive`. | | `style=` | attribute | the id of a `style` declared in this diagram | A `style` whose values apply where the element sets none. | | `mark=` | attribute | the id of an `adr` declared in this diagram | Id of a decision of the bar below, such as `E1`; the mark stands at the corner. | | `emph` | flag | | Draws the border thick: the core decision of the picture. | Example: ```dgr person customer "Customer" tech="account holder" at user/main ``` ### `container` [Section titled “container”](#container) ```text container <id> <label> [at <place>] [in <ref>] [tech=<text>] [icon=<choice>] [shape=<db|queue|store|job|app>] [width=<integer>] [height=<integer>] [tone=<choice>] [form=<card|circle|text>] [status=<planned|deprecated>] [replicas=<integer>] [span=<span>] [slot=<slot>] [style=<ref>] [mark=<ref>] [emph] ``` A container: an application or data store that runs on its own, such as a service or a database. `at` places it in the grid, `in` puts it into a group. `emph` marks a core decision with a thick border. Written at the top level. | Part | Kind | Value | Meaning | | ------------ | --------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------- | | `<id>` | argument | an identifier like `api` (letters, digits, `_` and `-`, starting with a letter) | Id that edges, flows, notes and `in` use for this element. | | `<label>` | argument | a text in double quotes like `"Order service"` | Name in the picture. | | `at <place>` | clause | a place `column/row` like `backend.1/main` | Place in the grid as `column/row`. Required. | | `in <ref>` | clause | the id of a `group` declared in this diagram | The group whose frame holds the element. | | `tech=` | attribute | a text in double quotes like `"Order service"` | Second line: technology or role, such as `"PostgreSQL"`. | | `icon=` | attribute | one of `apachekafka`, `archive`, `boxes`, `brick-wall`, `building-2`, `chart-line`, `cloud`, `container`, `copy`, `cpu`, `database`, `earth`, `file-cog`, `file-text`, `files`, `flame`, `folder`, `gauge`, `globe`, `hard-drive`, `hexagon`, `key-round`, `keycloak`, `kubernetes`, `layers`, `layout-dashboard`, `lock`, `map-pin`, `minio`, `monitor`, `network`, `package`, `postgresql`, `puzzle`, `receipt`, `route`, `router`, `server`, `server-cog`, `settings`, `shield`, `shield-check`, `smartphone`, `split`, `springboot`, `terminal`, `user-cog`, `user-round`, `users`, `vuedotjs`, `warehouse`, `waypoints`, `workflow` | Pictogram before the name: the technology or the role of the element. | | `shape=` | attribute | one of `db`, `queue`, `store`, `job`, `app` | Form of the box: `db` cylinder, `queue` tube, `store` folded sheet, `job`, `app`. | | `width=` | attribute | a whole number from 48 to 960 | Width of the box in pixels; needs `layout=adaptive`. | | `height=` | attribute | a whole number from 24 to 480 | Height of the box in pixels; needs `layout=adaptive`. | | `tone=` | attribute | one of `blue`, `indigo`, `purple`, `maroon`, `green`, `teal`, `slate`, `red`, `orange`, `peach`, `sky` | Colour of the icon circle in `look=cards` and of the block in `look=blocks`. | | `form=` | attribute | one of `card`, `circle`, `text` | `card` or `circle` in `look=cards`; `text` draws only the name in `look=blocks`. | | `status=` | attribute | one of `planned`, `deprecated` | `planned` draws the box dashed, `deprecated` grey; both name it beside `tech`. | | `replicas=` | attribute | a whole number from 2 to 99 | Number of instances from 2, shown as `x3` in the corner. | | `span=` | attribute | the last column like `mobile`, or `column/row` like `edge/data` | Last column, or `column/row`, of the area the element covers; needs `layout=adaptive`. | | `slot=` | attribute | `i/n` with 1 ≤ i ≤ n ≤ 64, like `2/3` | Takes place `i` of `n` equal places in its area, like `2/3`; needs `layout=adaptive`. | | `style=` | attribute | the id of a `style` declared in this diagram | A `style` whose values apply where the element sets none. | | `mark=` | attribute | the id of an `adr` declared in this diagram | Id of a decision of the bar below, such as `E1`; the mark stands at the corner. | | `emph` | flag | | Draws the border thick: the core decision of the picture. | Example: ```dgr container db "Database" tech="PostgreSQL" icon=postgresql at infra/data in infra ``` ### `component` [Section titled “component”](#component) ```text component <id> <label> [at <place>] [in <ref>] [tech=<text>] [icon=<choice>] [shape=<db|queue|store|job|app>] [width=<integer>] [height=<integer>] [tone=<choice>] [form=<card|circle|text>] [status=<planned|deprecated>] [replicas=<integer>] [span=<span>] [slot=<slot>] [style=<ref>] [mark=<ref>] [emph] ``` A component inside a container, such as a module or an adapter. `at` places it in the grid, `in` puts it into a group. `emph` marks a core decision with a thick border. Written at the top level. | Part | Kind | Value | Meaning | | ------------ | --------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------- | | `<id>` | argument | an identifier like `api` (letters, digits, `_` and `-`, starting with a letter) | Id that edges, flows, notes and `in` use for this element. | | `<label>` | argument | a text in double quotes like `"Order service"` | Name in the picture. | | `at <place>` | clause | a place `column/row` like `backend.1/main` | Place in the grid as `column/row`. Required. | | `in <ref>` | clause | the id of a `group` declared in this diagram | The group whose frame holds the element. | | `tech=` | attribute | a text in double quotes like `"Order service"` | Second line: technology or role, such as `"PostgreSQL"`. | | `icon=` | attribute | one of `apachekafka`, `archive`, `boxes`, `brick-wall`, `building-2`, `chart-line`, `cloud`, `container`, `copy`, `cpu`, `database`, `earth`, `file-cog`, `file-text`, `files`, `flame`, `folder`, `gauge`, `globe`, `hard-drive`, `hexagon`, `key-round`, `keycloak`, `kubernetes`, `layers`, `layout-dashboard`, `lock`, `map-pin`, `minio`, `monitor`, `network`, `package`, `postgresql`, `puzzle`, `receipt`, `route`, `router`, `server`, `server-cog`, `settings`, `shield`, `shield-check`, `smartphone`, `split`, `springboot`, `terminal`, `user-cog`, `user-round`, `users`, `vuedotjs`, `warehouse`, `waypoints`, `workflow` | Pictogram before the name: the technology or the role of the element. | | `shape=` | attribute | one of `db`, `queue`, `store`, `job`, `app` | Form of the box: `db` cylinder, `queue` tube, `store` folded sheet, `job`, `app`. | | `width=` | attribute | a whole number from 48 to 960 | Width of the box in pixels; needs `layout=adaptive`. | | `height=` | attribute | a whole number from 24 to 480 | Height of the box in pixels; needs `layout=adaptive`. | | `tone=` | attribute | one of `blue`, `indigo`, `purple`, `maroon`, `green`, `teal`, `slate`, `red`, `orange`, `peach`, `sky` | Colour of the icon circle in `look=cards` and of the block in `look=blocks`. | | `form=` | attribute | one of `card`, `circle`, `text` | `card` or `circle` in `look=cards`; `text` draws only the name in `look=blocks`. | | `status=` | attribute | one of `planned`, `deprecated` | `planned` draws the box dashed, `deprecated` grey; both name it beside `tech`. | | `replicas=` | attribute | a whole number from 2 to 99 | Number of instances from 2, shown as `x3` in the corner. | | `span=` | attribute | the last column like `mobile`, or `column/row` like `edge/data` | Last column, or `column/row`, of the area the element covers; needs `layout=adaptive`. | | `slot=` | attribute | `i/n` with 1 ≤ i ≤ n ≤ 64, like `2/3` | Takes place `i` of `n` equal places in its area, like `2/3`; needs `layout=adaptive`. | | `style=` | attribute | the id of a `style` declared in this diagram | A `style` whose values apply where the element sets none. | | `mark=` | attribute | the id of an `adr` declared in this diagram | Id of a decision of the bar below, such as `E1`; the mark stands at the corner. | | `emph` | flag | | Draws the border thick: the core decision of the picture. | Example: ```dgr component api "REST API" tech="Spring Boot" icon=springboot at backend.2/main in backend ``` ### `node` [Section titled “node”](#node) ```text node <id> <label> [at <place>] [in <ref>] [tech=<text>] [icon=<choice>] [shape=<db|queue|store|job|app>] [width=<integer>] [height=<integer>] [tone=<choice>] [form=<card|circle|text>] [status=<planned|deprecated>] [replicas=<integer>] [span=<span>] [slot=<slot>] [style=<ref>] [mark=<ref>] [emph] ``` A neutral element for any level, such as a queue, a job or a layer of a pattern. `at` places it in the grid, `in` puts it into a group. `emph` marks a core decision with a thick border. Written at the top level. | Part | Kind | Value | Meaning | | ------------ | --------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------- | | `<id>` | argument | an identifier like `api` (letters, digits, `_` and `-`, starting with a letter) | Id that edges, flows, notes and `in` use for this element. | | `<label>` | argument | a text in double quotes like `"Order service"` | Name in the picture. | | `at <place>` | clause | a place `column/row` like `backend.1/main` | Place in the grid as `column/row`. Required. | | `in <ref>` | clause | the id of a `group` declared in this diagram | The group whose frame holds the element. | | `tech=` | attribute | a text in double quotes like `"Order service"` | Second line: technology or role, such as `"PostgreSQL"`. | | `icon=` | attribute | one of `apachekafka`, `archive`, `boxes`, `brick-wall`, `building-2`, `chart-line`, `cloud`, `container`, `copy`, `cpu`, `database`, `earth`, `file-cog`, `file-text`, `files`, `flame`, `folder`, `gauge`, `globe`, `hard-drive`, `hexagon`, `key-round`, `keycloak`, `kubernetes`, `layers`, `layout-dashboard`, `lock`, `map-pin`, `minio`, `monitor`, `network`, `package`, `postgresql`, `puzzle`, `receipt`, `route`, `router`, `server`, `server-cog`, `settings`, `shield`, `shield-check`, `smartphone`, `split`, `springboot`, `terminal`, `user-cog`, `user-round`, `users`, `vuedotjs`, `warehouse`, `waypoints`, `workflow` | Pictogram before the name: the technology or the role of the element. | | `shape=` | attribute | one of `db`, `queue`, `store`, `job`, `app` | Form of the box: `db` cylinder, `queue` tube, `store` folded sheet, `job`, `app`. | | `width=` | attribute | a whole number from 48 to 960 | Width of the box in pixels; needs `layout=adaptive`. | | `height=` | attribute | a whole number from 24 to 480 | Height of the box in pixels; needs `layout=adaptive`. | | `tone=` | attribute | one of `blue`, `indigo`, `purple`, `maroon`, `green`, `teal`, `slate`, `red`, `orange`, `peach`, `sky` | Colour of the icon circle in `look=cards` and of the block in `look=blocks`. | | `form=` | attribute | one of `card`, `circle`, `text` | `card` or `circle` in `look=cards`; `text` draws only the name in `look=blocks`. | | `status=` | attribute | one of `planned`, `deprecated` | `planned` draws the box dashed, `deprecated` grey; both name it beside `tech`. | | `replicas=` | attribute | a whole number from 2 to 99 | Number of instances from 2, shown as `x3` in the corner. | | `span=` | attribute | the last column like `mobile`, or `column/row` like `edge/data` | Last column, or `column/row`, of the area the element covers; needs `layout=adaptive`. | | `slot=` | attribute | `i/n` with 1 ≤ i ≤ n ≤ 64, like `2/3` | Takes place `i` of `n` equal places in its area, like `2/3`; needs `layout=adaptive`. | | `style=` | attribute | the id of a `style` declared in this diagram | A `style` whose values apply where the element sets none. | | `mark=` | attribute | the id of an `adr` declared in this diagram | Id of a decision of the bar below, such as `E1`; the mark stands at the corner. | | `emph` | flag | | Draws the border thick: the core decision of the picture. | Example: ```dgr node orders "Orders" tech="business logic" replicas=3 at web/business in cloud ``` ### `edge` [Section titled “edge”](#edge) ```text edge <from> <arrow> <to> [label] [via=<text>] [schedule=<text>] [volume=<text>] [sla=<text>] [mark=<ref>] [bundle=<word>] [lane=<grid-name>] [tone=<choice>] [style=<ref>] ``` An edge outside of flows, without number. Its ends may be groups too. Written at the top level. | Part | Kind | Value | Meaning | | ----------- | ----------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------ | | `<from>` | argument | the id of a `person`, `container`, `component`, `node` or `group` declared in this diagram | Where it starts: an element or a group. | | `<arrow>` | argument | one of the arrows `->` synchronous call (filled head), `~>` asynchronous message or event (dashed, open head), `-->` dependency (dashed, open head), `=>` data flow (thick line, filled head), `--` connection without direction (no head), `<->` call in both directions (a head at each end) | The kind of edge, which also decides how it is drawn. | | `<to>` | argument | the id of a `person`, `container`, `component`, `node` or `group` declared in this diagram | Where it ends: an element or a group. | | `[label]` | optional argument | a text in double quotes like `"Order service"` | What happens, such as `"reads documents"`; first line of the label. | | `via=` | attribute | a text in double quotes like `"Order service"` | Protocol or transport, such as `HTTPS`; second line of the label. | | `schedule=` | attribute | a text in double quotes like `"Order service"` | When it runs, such as `"nightly 02:00"`; joins the second line. | | `volume=` | attribute | a text in double quotes like `"Order service"` | How much, such as `"10k/day"`; joins the second line. | | `sla=` | attribute | a text in double quotes like `"Order service"` | What is promised, such as `"< 200 ms"`; joins the second line. | | `mark=` | attribute | the id of an `adr` declared in this diagram | Id of a decision of the bar below, such as `E1`; the mark stands near the end. | | `bundle=` | attribute | a single word without quotes | Edges with the same bundle and a shared end share one trunk; needs `layout=adaptive`. | | `lane=` | attribute | a column or row name like `api` or `backend.1` | Column a vertical edge runs in, reaching into frames at its ends; needs `layout=adaptive`. | | `tone=` | attribute | one of `blue`, `indigo`, `purple`, `maroon`, `green`, `teal`, `slate`, `red`, `orange`, `peach`, `sky` | Colour of line and heads, such as `red` for a highlighted way. | | `style=` | attribute | the id of a `style` declared in this diagram | A `style` whose `tone` applies when the edge sets none. | The values of `arrow` and what they mean: | Value | Meaning | | ----- | ------------------------------------------------- | | `->` | synchronous call (filled head) | | `~>` | asynchronous message or event (dashed, open head) | | `-->` | dependency (dashed, open head) | | `=>` | data flow (thick line, filled head) | | `--` | connection without direction (no head) | | `<->` | call in both directions (a head at each end) | Examples: ```dgr edge abgleich => db "check inventory" schedule="daily 03:00" edge web -> gateway via=HTTPS ``` ### `flow` [Section titled “flow”](#flow) ```text flow <id> [primary] [accent] ``` A numbered path: its steps are indented below it. Numbers run on across all flows in source order. Written at the top level. | Part | Kind | Value | Meaning | | --------- | -------- | ------------------------------------------------------------------------------- | --------------------------------------------------------------- | | `<id>` | argument | an identifier like `api` (letters, digits, `_` and `-`, starting with a letter) | Name of the flow, shown in the legend. | | `primary` | flag | | Draws the steps in the line colour (default). | | `accent` | flag | | Draws the steps, their labels and numbers in the accent colour. | Example: ```dgr flow import primary ``` Indented lines that start without one of these keywords have this form: ```text <from> <arrow> <to> [label] [via=<text>] [schedule=<text>] [volume=<text>] [sla=<text>] [mark=<ref>] [bundle=<word>] [lane=<grid-name>] [tone=<choice>] [style=<ref>] ``` A step of the flow: an edge without keyword, numbered after the steps before it, across all flows. | Part | Kind | Value | Meaning | | ----------- | ----------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------ | | `<from>` | argument | the id of a `person`, `container`, `component`, `node` or `group` declared in this diagram | Where it starts: an element or a group. | | `<arrow>` | argument | one of the arrows `->` synchronous call (filled head), `~>` asynchronous message or event (dashed, open head), `-->` dependency (dashed, open head), `=>` data flow (thick line, filled head), `--` connection without direction (no head), `<->` call in both directions (a head at each end) | The kind of edge, which also decides how it is drawn. | | `<to>` | argument | the id of a `person`, `container`, `component`, `node` or `group` declared in this diagram | Where it ends: an element or a group. | | `[label]` | optional argument | a text in double quotes like `"Order service"` | What happens, such as `"reads documents"`; first line of the label. | | `via=` | attribute | a text in double quotes like `"Order service"` | Protocol or transport, such as `HTTPS`; second line of the label. | | `schedule=` | attribute | a text in double quotes like `"Order service"` | When it runs, such as `"nightly 02:00"`; joins the second line. | | `volume=` | attribute | a text in double quotes like `"Order service"` | How much, such as `"10k/day"`; joins the second line. | | `sla=` | attribute | a text in double quotes like `"Order service"` | What is promised, such as `"< 200 ms"`; joins the second line. | | `mark=` | attribute | the id of an `adr` declared in this diagram | Id of a decision of the bar below, such as `E1`; the mark stands near the end. | | `bundle=` | attribute | a single word without quotes | Edges with the same bundle and a shared end share one trunk; needs `layout=adaptive`. | | `lane=` | attribute | a column or row name like `api` or `backend.1` | Column a vertical edge runs in, reaching into frames at its ends; needs `layout=adaptive`. | | `tone=` | attribute | one of `blue`, `indigo`, `purple`, `maroon`, `green`, `teal`, `slate`, `red`, `orange`, `peach`, `sky` | Colour of line and heads, such as `red` for a highlighted way. | | `style=` | attribute | the id of a `style` declared in this diagram | A `style` whose `tone` applies when the edge sets none. | The values of `arrow` and what they mean: | Value | Meaning | | ----- | ------------------------------------------------- | | `->` | synchronous call (filled head) | | `~>` | asynchronous message or event (dashed, open head) | | `-->` | dependency (dashed, open head) | | `=>` | data flow (thick line, filled head) | | `--` | connection without direction (no head) | | `<->` | call in both directions (a head at each end) | Examples: ```dgr kafka ~> importer "consume event" storage -> bucket "read object" via="S3 HEAD" ``` ### `note` [Section titled “note”](#note) ```text note <text> [on <ref>] ``` A dashed note above an element, with a tip pointing at it. It is no element and no edge. Written at the top level. | Part | Kind | Value | Meaning | | ---------- | -------- | --------------------------------------------------------------------------------- | ----------------------------------- | | `<text>` | argument | a text in double quotes like `"Order service"` | What the note says. | | `on <ref>` | clause | the id of a `person`, `container`, `component` or `node` declared in this diagram | The element it points at. Required. | Example: ```dgr note "replaced in Q3" on portal ``` ### `adr` [Section titled “adr”](#adr) ```text adr <id> <question> <equals> <choice> [then] [consequence] [open=<text>] ``` An architecture decision in the bar below the picture: question, the chosen option after `=`, and the consequence after `=>`. `mark=` with its id puts the mark into the picture. Written at the top level. | Part | Kind | Value | Meaning | | --------------- | ----------------- | ------------------------------------------------------------------------------- | ------------------------------------------------------------- | | `<id>` | argument | an identifier like `api` (letters, digits, `_` and `-`, starting with a letter) | Id of the decision, such as `E1`; `mark=E1` refers to it. | | `<question>` | argument | a text in double quotes like `"Order service"` | The question that was decided. | | `<equals>` | argument | one of the arrows `=` | Separates the question from the choice. | | `<choice>` | argument | a text in double quotes like `"Order service"` | The chosen option. | | `[then]` | optional argument | one of the arrows `=>` | Introduces the consequence. | | `[consequence]` | optional argument | a text in double quotes like `"Order service"` | What follows from the choice. | | `open=` | attribute | a text in double quotes like `"Order service"` | Who still decides an open question; the card is drawn dashed. | Example: ```dgr adr E1 "How do the services coordinate?" = "Events over Kafka" => "No central coordinator" ``` ## Diagnostic codes [Section titled “Diagnostic codes”](#diagnostic-codes) Besides the codes of the language and the kernel, listed in [the overview](/docs/language/#diagnostic-codes), the rules of `component` report these. An error stops the build; a warning is printed and the picture is still drawn. | Code | Severity | What it checks | | ------ | -------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `A001` | error | A note names the element it points at with `on`. | | `A007` | error | A group has exactly one role: `own`, `shared` or `external`. The role draws its frame and mutes shared elements. | | `A008` | error | Every element has a place in the grid with `at column/row`. | | `A103` | error | Column and row of `at` are names of the grid. | | `A105` | error | An edge connects two different elements or groups. | | `A106` | error | Every column and every row is named once. | | `A107` | error | An edge does not lead from an element to the group that holds it, or back. | | `A109` | error | Areas (`span`, `slot`, `width`, `height`), bundles and layers need `layout=adaptive`; areas reach right and down within the grid; `cover` names a column; groups nest without a cycle; a bundle shares an end and a kind; a row has one layer. | | `A710` | warning | An edge says what happens: a label or a protocol (`via=`). | | `A801` | warning | A decision of the bar has a mark in the picture, on an element or a step (`mark=`). | # container > A C4 container diagram (level 2): the applications and data stores of a system, grouped by responsibility, placed in a named grid. A C4 container diagram (level 2): the applications and data stores of a system, grouped by responsibility, placed in a named grid. This page lists everything a `container` diagram may contain. The same grammar is available as data with `dgr grammar container --json`, and [the overview](/docs/language/) explains how lines, texts and attributes are written and lists the codes every kind shares. ## The first line [Section titled “The first line”](#the-first-line) ```text diagram container "Title" [subtitle=<text>] [label=<text>] [look=<plain|cards|blocks|paper|columns>] [decisions=<right|below|auto>] [layout=<adaptive>] [locale=<en|de>] ``` Every container diagram starts with this line. | Part | Kind | Value | Meaning | | ------------ | --------- | ----------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `subtitle=` | attribute | a text in double quotes like `"Order service"` | Second line below the title. | | `label=` | attribute | a text in double quotes like `"Order service"` | Name before the title instead of the kind; an empty `label=""` leaves only the title. | | `look=` | attribute | one of `plain`, `cards`, `blocks`, `paper`, `columns` | `plain` (default) boxes with a legend, `cards` toned icon cards, `blocks` filled blocks as in pattern books, `paper` a quiet print look: Inter on paper, zones as areas, the core in yellow, decisions in the margin, `columns` a technical sheet: columns in bands under grey heads, names in the top edge of square boxes, the focus flow heavy. | | `decisions=` | attribute | one of `right`, `below`, `auto` | Where a look that writes decisions as notes sets them: `right` (default) in a column beside the picture, `below` side by side under it, `auto` below once the picture is wider than 1,100 pixels, as a printed page needs. | | `layout=` | attribute | one of `adaptive` | Columns grow to their content and edges find their own way around obstacles; without it the grid is fixed. | | `locale=` | attribute | one of `en`, `de` | Language of the texts Diagrist adds to the picture and of the description: `en` (default) or `de`. | Example: ```dgr diagram container "Title" ``` ## Statements [Section titled “Statements”](#statements) Each statement is one line that starts with its keyword. Statements inside blocks are indented below them. Like every kind, `container` also has `use`, `variant`, `set` and `drop`, described in [the overview](/docs/language/#statements-of-every-kind). | Statement | Where | What it does | | ------------------------- | --------- | ----------------------------------------------------------------------------------------------------------------------------- | | [`grid`](#grid) | top level | The named columns from left to right, or the rows from top to bottom. | | [`layer`](#layer) | top level | Names a row in a box right of the picture, joined by one bracket for all layers; needs `layout=adaptive`. | | [`group`](#group) | top level | A frame around elements by responsibility; it grows from its members. | | [`style`](#style) | top level | Named values for elements, and a tone for edges, so sizes and colours stand in one place. | | [`person`](#person) | top level | A person who uses the system, drawn as a stick figure with name and role below it. | | [`system`](#system) | top level | A software system, as a box with name and a second line. | | [`container`](#container) | top level | A container: an application or data store that runs on its own, such as a service or a database. | | [`node`](#node) | top level | A neutral element for any level, such as a queue, a job or a layer of a pattern. | | [`edge`](#edge) | top level | An edge outside of flows, without number. | | [`flow`](#flow) | top level | A numbered path: its steps are indented below it. | | [`note`](#note) | top level | A dashed note above an element, with a tip pointing at it. | | [`adr`](#adr) | top level | An architecture decision in the bar below the picture: question, the chosen option after `=`, and the consequence after `=>`. | ### `grid` [Section titled “grid”](#grid) ```text grid <axis> <names> ``` The named columns from left to right, or the rows from top to bottom. Names with the same prefix before a dot stand close, such as `api.1,api.2`. Written at the top level. | Part | Kind | Value | Meaning | | --------- | -------- | ----------------------------------------------------------------- | ------------------------------------------------------- | | `<axis>` | argument | one of `cols`, `rows` | `cols` for the columns, `rows` for the rows. | | `<names>` | argument | names separated by commas without spaces, like `user,api.1,api.2` | The names in order, separated by commas without spaces. | Examples: ```dgr grid cols user,backend.1,backend.2,edge grid rows top,main,data ``` ### `layer` [Section titled “layer”](#layer) ```text layer <row> <label> ``` Names a row in a box right of the picture, joined by one bracket for all layers; needs `layout=adaptive`. Written at the top level. | Part | Kind | Value | Meaning | | --------- | -------- | ---------------------------------------------- | ------------------ | | `<row>` | argument | a column or row name like `api` or `backend.1` | The row it names. | | `<label>` | argument | a text in double quotes like `"Order service"` | Name of the layer. | Example: ```dgr layer business "Business logic" ``` ### `group` [Section titled “group”](#group) ```text group <id> <title> [in <ref>] [team=<text>] [heading=<top|side>] [tag=<text>] [cover=<grid-name>] [tone=<choice>] [own] [shared] [external] ``` A frame around elements by responsibility; it grows from its members. Exactly one of `own`, `shared`, `external`. `in` nests it into another group; an empty title draws only the frame. Written at the top level. | Part | Kind | Value | Meaning | | ---------- | --------- | ------------------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------- | | `<id>` | argument | an identifier like `api` (letters, digits, `_` and `-`, starting with a letter) | Id that `in` of elements and groups and the ends of edges use. | | `<title>` | argument | a text in double quotes like `"Order service"` | Title in the head of the frame. | | `in <ref>` | clause | the id of a `group` declared in this diagram | The group whose frame holds this one. | | `team=` | attribute | a text in double quotes like `"Order service"` | Who is responsible; second line of the head, else the role in words. | | `heading=` | attribute | one of `top`, `side` | `top` (default) or `side`: title left in the middle, as for layer bands. | | `tag=` | attribute | a text in double quotes like `"Order service"` | A tag right in the frame, such as `"CLOSED"` for a closed layer. | | `cover=` | attribute | a column or row name like `api` or `backend.1` | A column the frame also covers, at the height of its members; needs `layout=adaptive`. | | `tone=` | attribute | one of `blue`, `indigo`, `purple`, `maroon`, `green`, `teal`, `slate`, `red`, `orange`, `peach`, `sky` | Fills the frame lightly in this tone; in `look=blocks` the colour of its area. | | `own` | flag | | Our own system: a solid frame on a light area. | | `shared` | flag | | Shared infrastructure: its elements are drawn muted. | | `external` | flag | | Someone else’s system: a dashed frame. | Examples: ```dgr group backend "Backend" own team="Kotlin · Team Ausleihe" group api "API" own in backend ``` ### `style` [Section titled “style”](#style) ```text style <id> [icon=<choice>] [shape=<db|queue|store|job|app>] [width=<integer>] [height=<integer>] [tone=<choice>] [form=<card|circle|text>] ``` Named values for elements, and a tone for edges, so sizes and colours stand in one place. `style=name` applies them where the element or edge sets none. Written at the top level. | Part | Kind | Value | Meaning | | --------- | --------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------- | | `<id>` | argument | an identifier like `api` (letters, digits, `_` and `-`, starting with a letter) | Name that `style=` refers to. | | `icon=` | attribute | one of `apachekafka`, `archive`, `boxes`, `brick-wall`, `building-2`, `chart-line`, `cloud`, `container`, `copy`, `cpu`, `database`, `earth`, `file-cog`, `file-text`, `files`, `flame`, `folder`, `gauge`, `globe`, `hard-drive`, `hexagon`, `key-round`, `keycloak`, `kubernetes`, `layers`, `layout-dashboard`, `lock`, `map-pin`, `minio`, `monitor`, `network`, `package`, `postgresql`, `puzzle`, `receipt`, `route`, `router`, `server`, `server-cog`, `settings`, `shield`, `shield-check`, `smartphone`, `split`, `springboot`, `terminal`, `user-cog`, `user-round`, `users`, `vuedotjs`, `warehouse`, `waypoints`, `workflow` | Pictogram before the name: the technology or the role of the element. | | `shape=` | attribute | one of `db`, `queue`, `store`, `job`, `app` | Form of the box: `db` cylinder, `queue` tube, `store` folded sheet, `job`, `app`. | | `width=` | attribute | a whole number from 48 to 960 | Width of the box in pixels; needs `layout=adaptive`. | | `height=` | attribute | a whole number from 24 to 480 | Height of the box in pixels; needs `layout=adaptive`. | | `tone=` | attribute | one of `blue`, `indigo`, `purple`, `maroon`, `green`, `teal`, `slate`, `red`, `orange`, `peach`, `sky` | Colour of the icon circle in `look=cards` and of the block in `look=blocks`. | | `form=` | attribute | one of `card`, `circle`, `text` | `card` or `circle` in `look=cards`; `text` draws only the name in `look=blocks`. | Examples: ```dgr style component height=80 style store shape=db height=96 ``` ### `person` [Section titled “person”](#person) ```text person <id> <label> [at <place>] [in <ref>] [tech=<text>] [icon=<choice>] [shape=<db|queue|store|job|app>] [width=<integer>] [height=<integer>] [tone=<choice>] [form=<card|circle|text>] [status=<planned|deprecated>] [replicas=<integer>] [span=<span>] [slot=<slot>] [style=<ref>] [mark=<ref>] [emph] ``` A person who uses the system, drawn as a stick figure with name and role below it. `at` places it in the grid, `in` puts it into a group. `emph` marks a core decision with a thick border. Written at the top level. | Part | Kind | Value | Meaning | | ------------ | --------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------- | | `<id>` | argument | an identifier like `api` (letters, digits, `_` and `-`, starting with a letter) | Id that edges, flows, notes and `in` use for this element. | | `<label>` | argument | a text in double quotes like `"Order service"` | Name in the picture. | | `at <place>` | clause | a place `column/row` like `backend.1/main` | Place in the grid as `column/row`. Required. | | `in <ref>` | clause | the id of a `group` declared in this diagram | The group whose frame holds the element. | | `tech=` | attribute | a text in double quotes like `"Order service"` | Second line: technology or role, such as `"PostgreSQL"`. | | `icon=` | attribute | one of `apachekafka`, `archive`, `boxes`, `brick-wall`, `building-2`, `chart-line`, `cloud`, `container`, `copy`, `cpu`, `database`, `earth`, `file-cog`, `file-text`, `files`, `flame`, `folder`, `gauge`, `globe`, `hard-drive`, `hexagon`, `key-round`, `keycloak`, `kubernetes`, `layers`, `layout-dashboard`, `lock`, `map-pin`, `minio`, `monitor`, `network`, `package`, `postgresql`, `puzzle`, `receipt`, `route`, `router`, `server`, `server-cog`, `settings`, `shield`, `shield-check`, `smartphone`, `split`, `springboot`, `terminal`, `user-cog`, `user-round`, `users`, `vuedotjs`, `warehouse`, `waypoints`, `workflow` | Pictogram before the name: the technology or the role of the element. | | `shape=` | attribute | one of `db`, `queue`, `store`, `job`, `app` | Form of the box: `db` cylinder, `queue` tube, `store` folded sheet, `job`, `app`. | | `width=` | attribute | a whole number from 48 to 960 | Width of the box in pixels; needs `layout=adaptive`. | | `height=` | attribute | a whole number from 24 to 480 | Height of the box in pixels; needs `layout=adaptive`. | | `tone=` | attribute | one of `blue`, `indigo`, `purple`, `maroon`, `green`, `teal`, `slate`, `red`, `orange`, `peach`, `sky` | Colour of the icon circle in `look=cards` and of the block in `look=blocks`. | | `form=` | attribute | one of `card`, `circle`, `text` | `card` or `circle` in `look=cards`; `text` draws only the name in `look=blocks`. | | `status=` | attribute | one of `planned`, `deprecated` | `planned` draws the box dashed, `deprecated` grey; both name it beside `tech`. | | `replicas=` | attribute | a whole number from 2 to 99 | Number of instances from 2, shown as `x3` in the corner. | | `span=` | attribute | the last column like `mobile`, or `column/row` like `edge/data` | Last column, or `column/row`, of the area the element covers; needs `layout=adaptive`. | | `slot=` | attribute | `i/n` with 1 ≤ i ≤ n ≤ 64, like `2/3` | Takes place `i` of `n` equal places in its area, like `2/3`; needs `layout=adaptive`. | | `style=` | attribute | the id of a `style` declared in this diagram | A `style` whose values apply where the element sets none. | | `mark=` | attribute | the id of an `adr` declared in this diagram | Id of a decision of the bar below, such as `E1`; the mark stands at the corner. | | `emph` | flag | | Draws the border thick: the core decision of the picture. | Example: ```dgr person customer "Customer" tech="account holder" at user/main ``` ### `system` [Section titled “system”](#system) ```text system <id> <label> [at <place>] [in <ref>] [tech=<text>] [icon=<choice>] [shape=<db|queue|store|job|app>] [width=<integer>] [height=<integer>] [tone=<choice>] [form=<card|circle|text>] [status=<planned|deprecated>] [replicas=<integer>] [span=<span>] [slot=<slot>] [style=<ref>] [mark=<ref>] [emph] ``` A software system, as a box with name and a second line. `at` places it in the grid, `in` puts it into a group. `emph` marks a core decision with a thick border. Written at the top level. | Part | Kind | Value | Meaning | | ------------ | --------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------- | | `<id>` | argument | an identifier like `api` (letters, digits, `_` and `-`, starting with a letter) | Id that edges, flows, notes and `in` use for this element. | | `<label>` | argument | a text in double quotes like `"Order service"` | Name in the picture. | | `at <place>` | clause | a place `column/row` like `backend.1/main` | Place in the grid as `column/row`. Required. | | `in <ref>` | clause | the id of a `group` declared in this diagram | The group whose frame holds the element. | | `tech=` | attribute | a text in double quotes like `"Order service"` | Second line: technology or role, such as `"PostgreSQL"`. | | `icon=` | attribute | one of `apachekafka`, `archive`, `boxes`, `brick-wall`, `building-2`, `chart-line`, `cloud`, `container`, `copy`, `cpu`, `database`, `earth`, `file-cog`, `file-text`, `files`, `flame`, `folder`, `gauge`, `globe`, `hard-drive`, `hexagon`, `key-round`, `keycloak`, `kubernetes`, `layers`, `layout-dashboard`, `lock`, `map-pin`, `minio`, `monitor`, `network`, `package`, `postgresql`, `puzzle`, `receipt`, `route`, `router`, `server`, `server-cog`, `settings`, `shield`, `shield-check`, `smartphone`, `split`, `springboot`, `terminal`, `user-cog`, `user-round`, `users`, `vuedotjs`, `warehouse`, `waypoints`, `workflow` | Pictogram before the name: the technology or the role of the element. | | `shape=` | attribute | one of `db`, `queue`, `store`, `job`, `app` | Form of the box: `db` cylinder, `queue` tube, `store` folded sheet, `job`, `app`. | | `width=` | attribute | a whole number from 48 to 960 | Width of the box in pixels; needs `layout=adaptive`. | | `height=` | attribute | a whole number from 24 to 480 | Height of the box in pixels; needs `layout=adaptive`. | | `tone=` | attribute | one of `blue`, `indigo`, `purple`, `maroon`, `green`, `teal`, `slate`, `red`, `orange`, `peach`, `sky` | Colour of the icon circle in `look=cards` and of the block in `look=blocks`. | | `form=` | attribute | one of `card`, `circle`, `text` | `card` or `circle` in `look=cards`; `text` draws only the name in `look=blocks`. | | `status=` | attribute | one of `planned`, `deprecated` | `planned` draws the box dashed, `deprecated` grey; both name it beside `tech`. | | `replicas=` | attribute | a whole number from 2 to 99 | Number of instances from 2, shown as `x3` in the corner. | | `span=` | attribute | the last column like `mobile`, or `column/row` like `edge/data` | Last column, or `column/row`, of the area the element covers; needs `layout=adaptive`. | | `slot=` | attribute | `i/n` with 1 ≤ i ≤ n ≤ 64, like `2/3` | Takes place `i` of `n` equal places in its area, like `2/3`; needs `layout=adaptive`. | | `style=` | attribute | the id of a `style` declared in this diagram | A `style` whose values apply where the element sets none. | | `mark=` | attribute | the id of an `adr` declared in this diagram | Id of a decision of the bar below, such as `E1`; the mark stands at the corner. | | `emph` | flag | | Draws the border thick: the core decision of the picture. | Example: ```dgr system shop "Web shop" tech="sells online" at core/main emph mark=E1 ``` ### `container` [Section titled “container”](#container) ```text container <id> <label> [at <place>] [in <ref>] [tech=<text>] [icon=<choice>] [shape=<db|queue|store|job|app>] [width=<integer>] [height=<integer>] [tone=<choice>] [form=<card|circle|text>] [status=<planned|deprecated>] [replicas=<integer>] [span=<span>] [slot=<slot>] [style=<ref>] [mark=<ref>] [emph] ``` A container: an application or data store that runs on its own, such as a service or a database. `at` places it in the grid, `in` puts it into a group. `emph` marks a core decision with a thick border. Written at the top level. | Part | Kind | Value | Meaning | | ------------ | --------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------- | | `<id>` | argument | an identifier like `api` (letters, digits, `_` and `-`, starting with a letter) | Id that edges, flows, notes and `in` use for this element. | | `<label>` | argument | a text in double quotes like `"Order service"` | Name in the picture. | | `at <place>` | clause | a place `column/row` like `backend.1/main` | Place in the grid as `column/row`. Required. | | `in <ref>` | clause | the id of a `group` declared in this diagram | The group whose frame holds the element. | | `tech=` | attribute | a text in double quotes like `"Order service"` | Second line: technology or role, such as `"PostgreSQL"`. | | `icon=` | attribute | one of `apachekafka`, `archive`, `boxes`, `brick-wall`, `building-2`, `chart-line`, `cloud`, `container`, `copy`, `cpu`, `database`, `earth`, `file-cog`, `file-text`, `files`, `flame`, `folder`, `gauge`, `globe`, `hard-drive`, `hexagon`, `key-round`, `keycloak`, `kubernetes`, `layers`, `layout-dashboard`, `lock`, `map-pin`, `minio`, `monitor`, `network`, `package`, `postgresql`, `puzzle`, `receipt`, `route`, `router`, `server`, `server-cog`, `settings`, `shield`, `shield-check`, `smartphone`, `split`, `springboot`, `terminal`, `user-cog`, `user-round`, `users`, `vuedotjs`, `warehouse`, `waypoints`, `workflow` | Pictogram before the name: the technology or the role of the element. | | `shape=` | attribute | one of `db`, `queue`, `store`, `job`, `app` | Form of the box: `db` cylinder, `queue` tube, `store` folded sheet, `job`, `app`. | | `width=` | attribute | a whole number from 48 to 960 | Width of the box in pixels; needs `layout=adaptive`. | | `height=` | attribute | a whole number from 24 to 480 | Height of the box in pixels; needs `layout=adaptive`. | | `tone=` | attribute | one of `blue`, `indigo`, `purple`, `maroon`, `green`, `teal`, `slate`, `red`, `orange`, `peach`, `sky` | Colour of the icon circle in `look=cards` and of the block in `look=blocks`. | | `form=` | attribute | one of `card`, `circle`, `text` | `card` or `circle` in `look=cards`; `text` draws only the name in `look=blocks`. | | `status=` | attribute | one of `planned`, `deprecated` | `planned` draws the box dashed, `deprecated` grey; both name it beside `tech`. | | `replicas=` | attribute | a whole number from 2 to 99 | Number of instances from 2, shown as `x3` in the corner. | | `span=` | attribute | the last column like `mobile`, or `column/row` like `edge/data` | Last column, or `column/row`, of the area the element covers; needs `layout=adaptive`. | | `slot=` | attribute | `i/n` with 1 ≤ i ≤ n ≤ 64, like `2/3` | Takes place `i` of `n` equal places in its area, like `2/3`; needs `layout=adaptive`. | | `style=` | attribute | the id of a `style` declared in this diagram | A `style` whose values apply where the element sets none. | | `mark=` | attribute | the id of an `adr` declared in this diagram | Id of a decision of the bar below, such as `E1`; the mark stands at the corner. | | `emph` | flag | | Draws the border thick: the core decision of the picture. | Example: ```dgr container db "Database" tech="PostgreSQL" icon=postgresql at infra/data in infra ``` ### `node` [Section titled “node”](#node) ```text node <id> <label> [at <place>] [in <ref>] [tech=<text>] [icon=<choice>] [shape=<db|queue|store|job|app>] [width=<integer>] [height=<integer>] [tone=<choice>] [form=<card|circle|text>] [status=<planned|deprecated>] [replicas=<integer>] [span=<span>] [slot=<slot>] [style=<ref>] [mark=<ref>] [emph] ``` A neutral element for any level, such as a queue, a job or a layer of a pattern. `at` places it in the grid, `in` puts it into a group. `emph` marks a core decision with a thick border. Written at the top level. | Part | Kind | Value | Meaning | | ------------ | --------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------- | | `<id>` | argument | an identifier like `api` (letters, digits, `_` and `-`, starting with a letter) | Id that edges, flows, notes and `in` use for this element. | | `<label>` | argument | a text in double quotes like `"Order service"` | Name in the picture. | | `at <place>` | clause | a place `column/row` like `backend.1/main` | Place in the grid as `column/row`. Required. | | `in <ref>` | clause | the id of a `group` declared in this diagram | The group whose frame holds the element. | | `tech=` | attribute | a text in double quotes like `"Order service"` | Second line: technology or role, such as `"PostgreSQL"`. | | `icon=` | attribute | one of `apachekafka`, `archive`, `boxes`, `brick-wall`, `building-2`, `chart-line`, `cloud`, `container`, `copy`, `cpu`, `database`, `earth`, `file-cog`, `file-text`, `files`, `flame`, `folder`, `gauge`, `globe`, `hard-drive`, `hexagon`, `key-round`, `keycloak`, `kubernetes`, `layers`, `layout-dashboard`, `lock`, `map-pin`, `minio`, `monitor`, `network`, `package`, `postgresql`, `puzzle`, `receipt`, `route`, `router`, `server`, `server-cog`, `settings`, `shield`, `shield-check`, `smartphone`, `split`, `springboot`, `terminal`, `user-cog`, `user-round`, `users`, `vuedotjs`, `warehouse`, `waypoints`, `workflow` | Pictogram before the name: the technology or the role of the element. | | `shape=` | attribute | one of `db`, `queue`, `store`, `job`, `app` | Form of the box: `db` cylinder, `queue` tube, `store` folded sheet, `job`, `app`. | | `width=` | attribute | a whole number from 48 to 960 | Width of the box in pixels; needs `layout=adaptive`. | | `height=` | attribute | a whole number from 24 to 480 | Height of the box in pixels; needs `layout=adaptive`. | | `tone=` | attribute | one of `blue`, `indigo`, `purple`, `maroon`, `green`, `teal`, `slate`, `red`, `orange`, `peach`, `sky` | Colour of the icon circle in `look=cards` and of the block in `look=blocks`. | | `form=` | attribute | one of `card`, `circle`, `text` | `card` or `circle` in `look=cards`; `text` draws only the name in `look=blocks`. | | `status=` | attribute | one of `planned`, `deprecated` | `planned` draws the box dashed, `deprecated` grey; both name it beside `tech`. | | `replicas=` | attribute | a whole number from 2 to 99 | Number of instances from 2, shown as `x3` in the corner. | | `span=` | attribute | the last column like `mobile`, or `column/row` like `edge/data` | Last column, or `column/row`, of the area the element covers; needs `layout=adaptive`. | | `slot=` | attribute | `i/n` with 1 ≤ i ≤ n ≤ 64, like `2/3` | Takes place `i` of `n` equal places in its area, like `2/3`; needs `layout=adaptive`. | | `style=` | attribute | the id of a `style` declared in this diagram | A `style` whose values apply where the element sets none. | | `mark=` | attribute | the id of an `adr` declared in this diagram | Id of a decision of the bar below, such as `E1`; the mark stands at the corner. | | `emph` | flag | | Draws the border thick: the core decision of the picture. | Example: ```dgr node orders "Orders" tech="business logic" replicas=3 at web/business in cloud ``` ### `edge` [Section titled “edge”](#edge) ```text edge <from> <arrow> <to> [label] [via=<text>] [schedule=<text>] [volume=<text>] [sla=<text>] [mark=<ref>] [bundle=<word>] [lane=<grid-name>] [tone=<choice>] [style=<ref>] ``` An edge outside of flows, without number. Its ends may be groups too. Written at the top level. | Part | Kind | Value | Meaning | | ----------- | ----------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------ | | `<from>` | argument | the id of a `person`, `system`, `container`, `node` or `group` declared in this diagram | Where it starts: an element or a group. | | `<arrow>` | argument | one of the arrows `->` synchronous call (filled head), `~>` asynchronous message or event (dashed, open head), `-->` dependency (dashed, open head), `=>` data flow (thick line, filled head), `--` connection without direction (no head), `<->` call in both directions (a head at each end) | The kind of edge, which also decides how it is drawn. | | `<to>` | argument | the id of a `person`, `system`, `container`, `node` or `group` declared in this diagram | Where it ends: an element or a group. | | `[label]` | optional argument | a text in double quotes like `"Order service"` | What happens, such as `"reads documents"`; first line of the label. | | `via=` | attribute | a text in double quotes like `"Order service"` | Protocol or transport, such as `HTTPS`; second line of the label. | | `schedule=` | attribute | a text in double quotes like `"Order service"` | When it runs, such as `"nightly 02:00"`; joins the second line. | | `volume=` | attribute | a text in double quotes like `"Order service"` | How much, such as `"10k/day"`; joins the second line. | | `sla=` | attribute | a text in double quotes like `"Order service"` | What is promised, such as `"< 200 ms"`; joins the second line. | | `mark=` | attribute | the id of an `adr` declared in this diagram | Id of a decision of the bar below, such as `E1`; the mark stands near the end. | | `bundle=` | attribute | a single word without quotes | Edges with the same bundle and a shared end share one trunk; needs `layout=adaptive`. | | `lane=` | attribute | a column or row name like `api` or `backend.1` | Column a vertical edge runs in, reaching into frames at its ends; needs `layout=adaptive`. | | `tone=` | attribute | one of `blue`, `indigo`, `purple`, `maroon`, `green`, `teal`, `slate`, `red`, `orange`, `peach`, `sky` | Colour of line and heads, such as `red` for a highlighted way. | | `style=` | attribute | the id of a `style` declared in this diagram | A `style` whose `tone` applies when the edge sets none. | The values of `arrow` and what they mean: | Value | Meaning | | ----- | ------------------------------------------------- | | `->` | synchronous call (filled head) | | `~>` | asynchronous message or event (dashed, open head) | | `-->` | dependency (dashed, open head) | | `=>` | data flow (thick line, filled head) | | `--` | connection without direction (no head) | | `<->` | call in both directions (a head at each end) | Examples: ```dgr edge abgleich => db "check inventory" schedule="daily 03:00" edge web -> gateway via=HTTPS ``` ### `flow` [Section titled “flow”](#flow) ```text flow <id> [primary] [accent] ``` A numbered path: its steps are indented below it. Numbers run on across all flows in source order. Written at the top level. | Part | Kind | Value | Meaning | | --------- | -------- | ------------------------------------------------------------------------------- | --------------------------------------------------------------- | | `<id>` | argument | an identifier like `api` (letters, digits, `_` and `-`, starting with a letter) | Name of the flow, shown in the legend. | | `primary` | flag | | Draws the steps in the line colour (default). | | `accent` | flag | | Draws the steps, their labels and numbers in the accent colour. | Example: ```dgr flow import primary ``` Indented lines that start without one of these keywords have this form: ```text <from> <arrow> <to> [label] [via=<text>] [schedule=<text>] [volume=<text>] [sla=<text>] [mark=<ref>] [bundle=<word>] [lane=<grid-name>] [tone=<choice>] [style=<ref>] ``` A step of the flow: an edge without keyword, numbered after the steps before it, across all flows. | Part | Kind | Value | Meaning | | ----------- | ----------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------ | | `<from>` | argument | the id of a `person`, `system`, `container`, `node` or `group` declared in this diagram | Where it starts: an element or a group. | | `<arrow>` | argument | one of the arrows `->` synchronous call (filled head), `~>` asynchronous message or event (dashed, open head), `-->` dependency (dashed, open head), `=>` data flow (thick line, filled head), `--` connection without direction (no head), `<->` call in both directions (a head at each end) | The kind of edge, which also decides how it is drawn. | | `<to>` | argument | the id of a `person`, `system`, `container`, `node` or `group` declared in this diagram | Where it ends: an element or a group. | | `[label]` | optional argument | a text in double quotes like `"Order service"` | What happens, such as `"reads documents"`; first line of the label. | | `via=` | attribute | a text in double quotes like `"Order service"` | Protocol or transport, such as `HTTPS`; second line of the label. | | `schedule=` | attribute | a text in double quotes like `"Order service"` | When it runs, such as `"nightly 02:00"`; joins the second line. | | `volume=` | attribute | a text in double quotes like `"Order service"` | How much, such as `"10k/day"`; joins the second line. | | `sla=` | attribute | a text in double quotes like `"Order service"` | What is promised, such as `"< 200 ms"`; joins the second line. | | `mark=` | attribute | the id of an `adr` declared in this diagram | Id of a decision of the bar below, such as `E1`; the mark stands near the end. | | `bundle=` | attribute | a single word without quotes | Edges with the same bundle and a shared end share one trunk; needs `layout=adaptive`. | | `lane=` | attribute | a column or row name like `api` or `backend.1` | Column a vertical edge runs in, reaching into frames at its ends; needs `layout=adaptive`. | | `tone=` | attribute | one of `blue`, `indigo`, `purple`, `maroon`, `green`, `teal`, `slate`, `red`, `orange`, `peach`, `sky` | Colour of line and heads, such as `red` for a highlighted way. | | `style=` | attribute | the id of a `style` declared in this diagram | A `style` whose `tone` applies when the edge sets none. | The values of `arrow` and what they mean: | Value | Meaning | | ----- | ------------------------------------------------- | | `->` | synchronous call (filled head) | | `~>` | asynchronous message or event (dashed, open head) | | `-->` | dependency (dashed, open head) | | `=>` | data flow (thick line, filled head) | | `--` | connection without direction (no head) | | `<->` | call in both directions (a head at each end) | Examples: ```dgr kafka ~> importer "consume event" storage -> bucket "read object" via="S3 HEAD" ``` ### `note` [Section titled “note”](#note) ```text note <text> [on <ref>] ``` A dashed note above an element, with a tip pointing at it. It is no element and no edge. Written at the top level. | Part | Kind | Value | Meaning | | ---------- | -------- | ------------------------------------------------------------------------------ | ----------------------------------- | | `<text>` | argument | a text in double quotes like `"Order service"` | What the note says. | | `on <ref>` | clause | the id of a `person`, `system`, `container` or `node` declared in this diagram | The element it points at. Required. | Example: ```dgr note "replaced in Q3" on portal ``` ### `adr` [Section titled “adr”](#adr) ```text adr <id> <question> <equals> <choice> [then] [consequence] [open=<text>] ``` An architecture decision in the bar below the picture: question, the chosen option after `=`, and the consequence after `=>`. `mark=` with its id puts the mark into the picture. Written at the top level. | Part | Kind | Value | Meaning | | --------------- | ----------------- | ------------------------------------------------------------------------------- | ------------------------------------------------------------- | | `<id>` | argument | an identifier like `api` (letters, digits, `_` and `-`, starting with a letter) | Id of the decision, such as `E1`; `mark=E1` refers to it. | | `<question>` | argument | a text in double quotes like `"Order service"` | The question that was decided. | | `<equals>` | argument | one of the arrows `=` | Separates the question from the choice. | | `<choice>` | argument | a text in double quotes like `"Order service"` | The chosen option. | | `[then]` | optional argument | one of the arrows `=>` | Introduces the consequence. | | `[consequence]` | optional argument | a text in double quotes like `"Order service"` | What follows from the choice. | | `open=` | attribute | a text in double quotes like `"Order service"` | Who still decides an open question; the card is drawn dashed. | Example: ```dgr adr E1 "How do the services coordinate?" = "Events over Kafka" => "No central coordinator" ``` ## Diagnostic codes [Section titled “Diagnostic codes”](#diagnostic-codes) Besides the codes of the language and the kernel, listed in [the overview](/docs/language/#diagnostic-codes), the rules of `container` report these. An error stops the build; a warning is printed and the picture is still drawn. | Code | Severity | What it checks | | ------ | -------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `A001` | error | A note names the element it points at with `on`. | | `A007` | error | A group has exactly one role: `own`, `shared` or `external`. The role draws its frame and mutes shared elements. | | `A008` | error | Every element has a place in the grid with `at column/row`. | | `A103` | error | Column and row of `at` are names of the grid. | | `A105` | error | An edge connects two different elements or groups. | | `A106` | error | Every column and every row is named once. | | `A107` | error | An edge does not lead from an element to the group that holds it, or back. | | `A109` | error | Areas (`span`, `slot`, `width`, `height`), bundles and layers need `layout=adaptive`; areas reach right and down within the grid; `cover` names a column; groups nest without a cycle; a bundle shares an end and a kind; a row has one layer. | | `A710` | warning | An edge says what happens: a label or a protocol (`via=`). | | `A801` | warning | A decision of the bar has a mark in the picture, on an element or a step (`mark=`). | # context > A C4 system context diagram (level 1): the system as one box, the people who use it and the systems around it, placed in a named grid. A C4 system context diagram (level 1): the system as one box, the people who use it and the systems around it, placed in a named grid. This page lists everything a `context` diagram may contain. The same grammar is available as data with `dgr grammar context --json`, and [the overview](/docs/language/) explains how lines, texts and attributes are written and lists the codes every kind shares. ## The first line [Section titled “The first line”](#the-first-line) ```text diagram context "Title" [subtitle=<text>] [label=<text>] [look=<plain|cards|blocks|paper|columns>] [decisions=<right|below|auto>] [layout=<adaptive>] [locale=<en|de>] ``` Every context diagram starts with this line. | Part | Kind | Value | Meaning | | ------------ | --------- | ----------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `subtitle=` | attribute | a text in double quotes like `"Order service"` | Second line below the title. | | `label=` | attribute | a text in double quotes like `"Order service"` | Name before the title instead of the kind; an empty `label=""` leaves only the title. | | `look=` | attribute | one of `plain`, `cards`, `blocks`, `paper`, `columns` | `plain` (default) boxes with a legend, `cards` toned icon cards, `blocks` filled blocks as in pattern books, `paper` a quiet print look: Inter on paper, zones as areas, the core in yellow, decisions in the margin, `columns` a technical sheet: columns in bands under grey heads, names in the top edge of square boxes, the focus flow heavy. | | `decisions=` | attribute | one of `right`, `below`, `auto` | Where a look that writes decisions as notes sets them: `right` (default) in a column beside the picture, `below` side by side under it, `auto` below once the picture is wider than 1,100 pixels, as a printed page needs. | | `layout=` | attribute | one of `adaptive` | Columns grow to their content and edges find their own way around obstacles; without it the grid is fixed. | | `locale=` | attribute | one of `en`, `de` | Language of the texts Diagrist adds to the picture and of the description: `en` (default) or `de`. | Example: ```dgr diagram context "Title" ``` ## Statements [Section titled “Statements”](#statements) Each statement is one line that starts with its keyword. Statements inside blocks are indented below them. Like every kind, `context` also has `use`, `variant`, `set` and `drop`, described in [the overview](/docs/language/#statements-of-every-kind). | Statement | Where | What it does | | ------------------- | --------- | ----------------------------------------------------------------------------------------------------------------------------- | | [`grid`](#grid) | top level | The named columns from left to right, or the rows from top to bottom. | | [`layer`](#layer) | top level | Names a row in a box right of the picture, joined by one bracket for all layers; needs `layout=adaptive`. | | [`group`](#group) | top level | A frame around elements by responsibility; it grows from its members. | | [`style`](#style) | top level | Named values for elements, and a tone for edges, so sizes and colours stand in one place. | | [`person`](#person) | top level | A person who uses the system, drawn as a stick figure with name and role below it. | | [`system`](#system) | top level | A software system, as a box with name and a second line. | | [`node`](#node) | top level | A neutral element for any level, such as a queue, a job or a layer of a pattern. | | [`edge`](#edge) | top level | An edge outside of flows, without number. | | [`flow`](#flow) | top level | A numbered path: its steps are indented below it. | | [`note`](#note) | top level | A dashed note above an element, with a tip pointing at it. | | [`adr`](#adr) | top level | An architecture decision in the bar below the picture: question, the chosen option after `=`, and the consequence after `=>`. | ### `grid` [Section titled “grid”](#grid) ```text grid <axis> <names> ``` The named columns from left to right, or the rows from top to bottom. Names with the same prefix before a dot stand close, such as `api.1,api.2`. Written at the top level. | Part | Kind | Value | Meaning | | --------- | -------- | ----------------------------------------------------------------- | ------------------------------------------------------- | | `<axis>` | argument | one of `cols`, `rows` | `cols` for the columns, `rows` for the rows. | | `<names>` | argument | names separated by commas without spaces, like `user,api.1,api.2` | The names in order, separated by commas without spaces. | Examples: ```dgr grid cols user,backend.1,backend.2,edge grid rows top,main,data ``` ### `layer` [Section titled “layer”](#layer) ```text layer <row> <label> ``` Names a row in a box right of the picture, joined by one bracket for all layers; needs `layout=adaptive`. Written at the top level. | Part | Kind | Value | Meaning | | --------- | -------- | ---------------------------------------------- | ------------------ | | `<row>` | argument | a column or row name like `api` or `backend.1` | The row it names. | | `<label>` | argument | a text in double quotes like `"Order service"` | Name of the layer. | Example: ```dgr layer business "Business logic" ``` ### `group` [Section titled “group”](#group) ```text group <id> <title> [in <ref>] [team=<text>] [heading=<top|side>] [tag=<text>] [cover=<grid-name>] [tone=<choice>] [own] [shared] [external] ``` A frame around elements by responsibility; it grows from its members. Exactly one of `own`, `shared`, `external`. `in` nests it into another group; an empty title draws only the frame. Written at the top level. | Part | Kind | Value | Meaning | | ---------- | --------- | ------------------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------- | | `<id>` | argument | an identifier like `api` (letters, digits, `_` and `-`, starting with a letter) | Id that `in` of elements and groups and the ends of edges use. | | `<title>` | argument | a text in double quotes like `"Order service"` | Title in the head of the frame. | | `in <ref>` | clause | the id of a `group` declared in this diagram | The group whose frame holds this one. | | `team=` | attribute | a text in double quotes like `"Order service"` | Who is responsible; second line of the head, else the role in words. | | `heading=` | attribute | one of `top`, `side` | `top` (default) or `side`: title left in the middle, as for layer bands. | | `tag=` | attribute | a text in double quotes like `"Order service"` | A tag right in the frame, such as `"CLOSED"` for a closed layer. | | `cover=` | attribute | a column or row name like `api` or `backend.1` | A column the frame also covers, at the height of its members; needs `layout=adaptive`. | | `tone=` | attribute | one of `blue`, `indigo`, `purple`, `maroon`, `green`, `teal`, `slate`, `red`, `orange`, `peach`, `sky` | Fills the frame lightly in this tone; in `look=blocks` the colour of its area. | | `own` | flag | | Our own system: a solid frame on a light area. | | `shared` | flag | | Shared infrastructure: its elements are drawn muted. | | `external` | flag | | Someone else’s system: a dashed frame. | Examples: ```dgr group backend "Backend" own team="Kotlin · Team Ausleihe" group api "API" own in backend ``` ### `style` [Section titled “style”](#style) ```text style <id> [icon=<choice>] [shape=<db|queue|store|job|app>] [width=<integer>] [height=<integer>] [tone=<choice>] [form=<card|circle|text>] ``` Named values for elements, and a tone for edges, so sizes and colours stand in one place. `style=name` applies them where the element or edge sets none. Written at the top level. | Part | Kind | Value | Meaning | | --------- | --------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------- | | `<id>` | argument | an identifier like `api` (letters, digits, `_` and `-`, starting with a letter) | Name that `style=` refers to. | | `icon=` | attribute | one of `apachekafka`, `archive`, `boxes`, `brick-wall`, `building-2`, `chart-line`, `cloud`, `container`, `copy`, `cpu`, `database`, `earth`, `file-cog`, `file-text`, `files`, `flame`, `folder`, `gauge`, `globe`, `hard-drive`, `hexagon`, `key-round`, `keycloak`, `kubernetes`, `layers`, `layout-dashboard`, `lock`, `map-pin`, `minio`, `monitor`, `network`, `package`, `postgresql`, `puzzle`, `receipt`, `route`, `router`, `server`, `server-cog`, `settings`, `shield`, `shield-check`, `smartphone`, `split`, `springboot`, `terminal`, `user-cog`, `user-round`, `users`, `vuedotjs`, `warehouse`, `waypoints`, `workflow` | Pictogram before the name: the technology or the role of the element. | | `shape=` | attribute | one of `db`, `queue`, `store`, `job`, `app` | Form of the box: `db` cylinder, `queue` tube, `store` folded sheet, `job`, `app`. | | `width=` | attribute | a whole number from 48 to 960 | Width of the box in pixels; needs `layout=adaptive`. | | `height=` | attribute | a whole number from 24 to 480 | Height of the box in pixels; needs `layout=adaptive`. | | `tone=` | attribute | one of `blue`, `indigo`, `purple`, `maroon`, `green`, `teal`, `slate`, `red`, `orange`, `peach`, `sky` | Colour of the icon circle in `look=cards` and of the block in `look=blocks`. | | `form=` | attribute | one of `card`, `circle`, `text` | `card` or `circle` in `look=cards`; `text` draws only the name in `look=blocks`. | Examples: ```dgr style component height=80 style store shape=db height=96 ``` ### `person` [Section titled “person”](#person) ```text person <id> <label> [at <place>] [in <ref>] [tech=<text>] [icon=<choice>] [shape=<db|queue|store|job|app>] [width=<integer>] [height=<integer>] [tone=<choice>] [form=<card|circle|text>] [status=<planned|deprecated>] [replicas=<integer>] [span=<span>] [slot=<slot>] [style=<ref>] [mark=<ref>] [emph] ``` A person who uses the system, drawn as a stick figure with name and role below it. `at` places it in the grid, `in` puts it into a group. `emph` marks a core decision with a thick border. Written at the top level. | Part | Kind | Value | Meaning | | ------------ | --------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------- | | `<id>` | argument | an identifier like `api` (letters, digits, `_` and `-`, starting with a letter) | Id that edges, flows, notes and `in` use for this element. | | `<label>` | argument | a text in double quotes like `"Order service"` | Name in the picture. | | `at <place>` | clause | a place `column/row` like `backend.1/main` | Place in the grid as `column/row`. Required. | | `in <ref>` | clause | the id of a `group` declared in this diagram | The group whose frame holds the element. | | `tech=` | attribute | a text in double quotes like `"Order service"` | Second line: technology or role, such as `"PostgreSQL"`. | | `icon=` | attribute | one of `apachekafka`, `archive`, `boxes`, `brick-wall`, `building-2`, `chart-line`, `cloud`, `container`, `copy`, `cpu`, `database`, `earth`, `file-cog`, `file-text`, `files`, `flame`, `folder`, `gauge`, `globe`, `hard-drive`, `hexagon`, `key-round`, `keycloak`, `kubernetes`, `layers`, `layout-dashboard`, `lock`, `map-pin`, `minio`, `monitor`, `network`, `package`, `postgresql`, `puzzle`, `receipt`, `route`, `router`, `server`, `server-cog`, `settings`, `shield`, `shield-check`, `smartphone`, `split`, `springboot`, `terminal`, `user-cog`, `user-round`, `users`, `vuedotjs`, `warehouse`, `waypoints`, `workflow` | Pictogram before the name: the technology or the role of the element. | | `shape=` | attribute | one of `db`, `queue`, `store`, `job`, `app` | Form of the box: `db` cylinder, `queue` tube, `store` folded sheet, `job`, `app`. | | `width=` | attribute | a whole number from 48 to 960 | Width of the box in pixels; needs `layout=adaptive`. | | `height=` | attribute | a whole number from 24 to 480 | Height of the box in pixels; needs `layout=adaptive`. | | `tone=` | attribute | one of `blue`, `indigo`, `purple`, `maroon`, `green`, `teal`, `slate`, `red`, `orange`, `peach`, `sky` | Colour of the icon circle in `look=cards` and of the block in `look=blocks`. | | `form=` | attribute | one of `card`, `circle`, `text` | `card` or `circle` in `look=cards`; `text` draws only the name in `look=blocks`. | | `status=` | attribute | one of `planned`, `deprecated` | `planned` draws the box dashed, `deprecated` grey; both name it beside `tech`. | | `replicas=` | attribute | a whole number from 2 to 99 | Number of instances from 2, shown as `x3` in the corner. | | `span=` | attribute | the last column like `mobile`, or `column/row` like `edge/data` | Last column, or `column/row`, of the area the element covers; needs `layout=adaptive`. | | `slot=` | attribute | `i/n` with 1 ≤ i ≤ n ≤ 64, like `2/3` | Takes place `i` of `n` equal places in its area, like `2/3`; needs `layout=adaptive`. | | `style=` | attribute | the id of a `style` declared in this diagram | A `style` whose values apply where the element sets none. | | `mark=` | attribute | the id of an `adr` declared in this diagram | Id of a decision of the bar below, such as `E1`; the mark stands at the corner. | | `emph` | flag | | Draws the border thick: the core decision of the picture. | Example: ```dgr person customer "Customer" tech="account holder" at user/main ``` ### `system` [Section titled “system”](#system) ```text system <id> <label> [at <place>] [in <ref>] [tech=<text>] [icon=<choice>] [shape=<db|queue|store|job|app>] [width=<integer>] [height=<integer>] [tone=<choice>] [form=<card|circle|text>] [status=<planned|deprecated>] [replicas=<integer>] [span=<span>] [slot=<slot>] [style=<ref>] [mark=<ref>] [emph] ``` A software system, as a box with name and a second line. `at` places it in the grid, `in` puts it into a group. `emph` marks a core decision with a thick border. Written at the top level. | Part | Kind | Value | Meaning | | ------------ | --------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------- | | `<id>` | argument | an identifier like `api` (letters, digits, `_` and `-`, starting with a letter) | Id that edges, flows, notes and `in` use for this element. | | `<label>` | argument | a text in double quotes like `"Order service"` | Name in the picture. | | `at <place>` | clause | a place `column/row` like `backend.1/main` | Place in the grid as `column/row`. Required. | | `in <ref>` | clause | the id of a `group` declared in this diagram | The group whose frame holds the element. | | `tech=` | attribute | a text in double quotes like `"Order service"` | Second line: technology or role, such as `"PostgreSQL"`. | | `icon=` | attribute | one of `apachekafka`, `archive`, `boxes`, `brick-wall`, `building-2`, `chart-line`, `cloud`, `container`, `copy`, `cpu`, `database`, `earth`, `file-cog`, `file-text`, `files`, `flame`, `folder`, `gauge`, `globe`, `hard-drive`, `hexagon`, `key-round`, `keycloak`, `kubernetes`, `layers`, `layout-dashboard`, `lock`, `map-pin`, `minio`, `monitor`, `network`, `package`, `postgresql`, `puzzle`, `receipt`, `route`, `router`, `server`, `server-cog`, `settings`, `shield`, `shield-check`, `smartphone`, `split`, `springboot`, `terminal`, `user-cog`, `user-round`, `users`, `vuedotjs`, `warehouse`, `waypoints`, `workflow` | Pictogram before the name: the technology or the role of the element. | | `shape=` | attribute | one of `db`, `queue`, `store`, `job`, `app` | Form of the box: `db` cylinder, `queue` tube, `store` folded sheet, `job`, `app`. | | `width=` | attribute | a whole number from 48 to 960 | Width of the box in pixels; needs `layout=adaptive`. | | `height=` | attribute | a whole number from 24 to 480 | Height of the box in pixels; needs `layout=adaptive`. | | `tone=` | attribute | one of `blue`, `indigo`, `purple`, `maroon`, `green`, `teal`, `slate`, `red`, `orange`, `peach`, `sky` | Colour of the icon circle in `look=cards` and of the block in `look=blocks`. | | `form=` | attribute | one of `card`, `circle`, `text` | `card` or `circle` in `look=cards`; `text` draws only the name in `look=blocks`. | | `status=` | attribute | one of `planned`, `deprecated` | `planned` draws the box dashed, `deprecated` grey; both name it beside `tech`. | | `replicas=` | attribute | a whole number from 2 to 99 | Number of instances from 2, shown as `x3` in the corner. | | `span=` | attribute | the last column like `mobile`, or `column/row` like `edge/data` | Last column, or `column/row`, of the area the element covers; needs `layout=adaptive`. | | `slot=` | attribute | `i/n` with 1 ≤ i ≤ n ≤ 64, like `2/3` | Takes place `i` of `n` equal places in its area, like `2/3`; needs `layout=adaptive`. | | `style=` | attribute | the id of a `style` declared in this diagram | A `style` whose values apply where the element sets none. | | `mark=` | attribute | the id of an `adr` declared in this diagram | Id of a decision of the bar below, such as `E1`; the mark stands at the corner. | | `emph` | flag | | Draws the border thick: the core decision of the picture. | Example: ```dgr system shop "Web shop" tech="sells online" at core/main emph mark=E1 ``` ### `node` [Section titled “node”](#node) ```text node <id> <label> [at <place>] [in <ref>] [tech=<text>] [icon=<choice>] [shape=<db|queue|store|job|app>] [width=<integer>] [height=<integer>] [tone=<choice>] [form=<card|circle|text>] [status=<planned|deprecated>] [replicas=<integer>] [span=<span>] [slot=<slot>] [style=<ref>] [mark=<ref>] [emph] ``` A neutral element for any level, such as a queue, a job or a layer of a pattern. `at` places it in the grid, `in` puts it into a group. `emph` marks a core decision with a thick border. Written at the top level. | Part | Kind | Value | Meaning | | ------------ | --------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------- | | `<id>` | argument | an identifier like `api` (letters, digits, `_` and `-`, starting with a letter) | Id that edges, flows, notes and `in` use for this element. | | `<label>` | argument | a text in double quotes like `"Order service"` | Name in the picture. | | `at <place>` | clause | a place `column/row` like `backend.1/main` | Place in the grid as `column/row`. Required. | | `in <ref>` | clause | the id of a `group` declared in this diagram | The group whose frame holds the element. | | `tech=` | attribute | a text in double quotes like `"Order service"` | Second line: technology or role, such as `"PostgreSQL"`. | | `icon=` | attribute | one of `apachekafka`, `archive`, `boxes`, `brick-wall`, `building-2`, `chart-line`, `cloud`, `container`, `copy`, `cpu`, `database`, `earth`, `file-cog`, `file-text`, `files`, `flame`, `folder`, `gauge`, `globe`, `hard-drive`, `hexagon`, `key-round`, `keycloak`, `kubernetes`, `layers`, `layout-dashboard`, `lock`, `map-pin`, `minio`, `monitor`, `network`, `package`, `postgresql`, `puzzle`, `receipt`, `route`, `router`, `server`, `server-cog`, `settings`, `shield`, `shield-check`, `smartphone`, `split`, `springboot`, `terminal`, `user-cog`, `user-round`, `users`, `vuedotjs`, `warehouse`, `waypoints`, `workflow` | Pictogram before the name: the technology or the role of the element. | | `shape=` | attribute | one of `db`, `queue`, `store`, `job`, `app` | Form of the box: `db` cylinder, `queue` tube, `store` folded sheet, `job`, `app`. | | `width=` | attribute | a whole number from 48 to 960 | Width of the box in pixels; needs `layout=adaptive`. | | `height=` | attribute | a whole number from 24 to 480 | Height of the box in pixels; needs `layout=adaptive`. | | `tone=` | attribute | one of `blue`, `indigo`, `purple`, `maroon`, `green`, `teal`, `slate`, `red`, `orange`, `peach`, `sky` | Colour of the icon circle in `look=cards` and of the block in `look=blocks`. | | `form=` | attribute | one of `card`, `circle`, `text` | `card` or `circle` in `look=cards`; `text` draws only the name in `look=blocks`. | | `status=` | attribute | one of `planned`, `deprecated` | `planned` draws the box dashed, `deprecated` grey; both name it beside `tech`. | | `replicas=` | attribute | a whole number from 2 to 99 | Number of instances from 2, shown as `x3` in the corner. | | `span=` | attribute | the last column like `mobile`, or `column/row` like `edge/data` | Last column, or `column/row`, of the area the element covers; needs `layout=adaptive`. | | `slot=` | attribute | `i/n` with 1 ≤ i ≤ n ≤ 64, like `2/3` | Takes place `i` of `n` equal places in its area, like `2/3`; needs `layout=adaptive`. | | `style=` | attribute | the id of a `style` declared in this diagram | A `style` whose values apply where the element sets none. | | `mark=` | attribute | the id of an `adr` declared in this diagram | Id of a decision of the bar below, such as `E1`; the mark stands at the corner. | | `emph` | flag | | Draws the border thick: the core decision of the picture. | Example: ```dgr node orders "Orders" tech="business logic" replicas=3 at web/business in cloud ``` ### `edge` [Section titled “edge”](#edge) ```text edge <from> <arrow> <to> [label] [via=<text>] [schedule=<text>] [volume=<text>] [sla=<text>] [mark=<ref>] [bundle=<word>] [lane=<grid-name>] [tone=<choice>] [style=<ref>] ``` An edge outside of flows, without number. Its ends may be groups too. Written at the top level. | Part | Kind | Value | Meaning | | ----------- | ----------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------ | | `<from>` | argument | the id of a `person`, `system`, `node` or `group` declared in this diagram | Where it starts: an element or a group. | | `<arrow>` | argument | one of the arrows `->` synchronous call (filled head), `~>` asynchronous message or event (dashed, open head), `-->` dependency (dashed, open head), `=>` data flow (thick line, filled head), `--` connection without direction (no head), `<->` call in both directions (a head at each end) | The kind of edge, which also decides how it is drawn. | | `<to>` | argument | the id of a `person`, `system`, `node` or `group` declared in this diagram | Where it ends: an element or a group. | | `[label]` | optional argument | a text in double quotes like `"Order service"` | What happens, such as `"reads documents"`; first line of the label. | | `via=` | attribute | a text in double quotes like `"Order service"` | Protocol or transport, such as `HTTPS`; second line of the label. | | `schedule=` | attribute | a text in double quotes like `"Order service"` | When it runs, such as `"nightly 02:00"`; joins the second line. | | `volume=` | attribute | a text in double quotes like `"Order service"` | How much, such as `"10k/day"`; joins the second line. | | `sla=` | attribute | a text in double quotes like `"Order service"` | What is promised, such as `"< 200 ms"`; joins the second line. | | `mark=` | attribute | the id of an `adr` declared in this diagram | Id of a decision of the bar below, such as `E1`; the mark stands near the end. | | `bundle=` | attribute | a single word without quotes | Edges with the same bundle and a shared end share one trunk; needs `layout=adaptive`. | | `lane=` | attribute | a column or row name like `api` or `backend.1` | Column a vertical edge runs in, reaching into frames at its ends; needs `layout=adaptive`. | | `tone=` | attribute | one of `blue`, `indigo`, `purple`, `maroon`, `green`, `teal`, `slate`, `red`, `orange`, `peach`, `sky` | Colour of line and heads, such as `red` for a highlighted way. | | `style=` | attribute | the id of a `style` declared in this diagram | A `style` whose `tone` applies when the edge sets none. | The values of `arrow` and what they mean: | Value | Meaning | | ----- | ------------------------------------------------- | | `->` | synchronous call (filled head) | | `~>` | asynchronous message or event (dashed, open head) | | `-->` | dependency (dashed, open head) | | `=>` | data flow (thick line, filled head) | | `--` | connection without direction (no head) | | `<->` | call in both directions (a head at each end) | Examples: ```dgr edge abgleich => db "check inventory" schedule="daily 03:00" edge web -> gateway via=HTTPS ``` ### `flow` [Section titled “flow”](#flow) ```text flow <id> [primary] [accent] ``` A numbered path: its steps are indented below it. Numbers run on across all flows in source order. Written at the top level. | Part | Kind | Value | Meaning | | --------- | -------- | ------------------------------------------------------------------------------- | --------------------------------------------------------------- | | `<id>` | argument | an identifier like `api` (letters, digits, `_` and `-`, starting with a letter) | Name of the flow, shown in the legend. | | `primary` | flag | | Draws the steps in the line colour (default). | | `accent` | flag | | Draws the steps, their labels and numbers in the accent colour. | Example: ```dgr flow import primary ``` Indented lines that start without one of these keywords have this form: ```text <from> <arrow> <to> [label] [via=<text>] [schedule=<text>] [volume=<text>] [sla=<text>] [mark=<ref>] [bundle=<word>] [lane=<grid-name>] [tone=<choice>] [style=<ref>] ``` A step of the flow: an edge without keyword, numbered after the steps before it, across all flows. | Part | Kind | Value | Meaning | | ----------- | ----------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------ | | `<from>` | argument | the id of a `person`, `system`, `node` or `group` declared in this diagram | Where it starts: an element or a group. | | `<arrow>` | argument | one of the arrows `->` synchronous call (filled head), `~>` asynchronous message or event (dashed, open head), `-->` dependency (dashed, open head), `=>` data flow (thick line, filled head), `--` connection without direction (no head), `<->` call in both directions (a head at each end) | The kind of edge, which also decides how it is drawn. | | `<to>` | argument | the id of a `person`, `system`, `node` or `group` declared in this diagram | Where it ends: an element or a group. | | `[label]` | optional argument | a text in double quotes like `"Order service"` | What happens, such as `"reads documents"`; first line of the label. | | `via=` | attribute | a text in double quotes like `"Order service"` | Protocol or transport, such as `HTTPS`; second line of the label. | | `schedule=` | attribute | a text in double quotes like `"Order service"` | When it runs, such as `"nightly 02:00"`; joins the second line. | | `volume=` | attribute | a text in double quotes like `"Order service"` | How much, such as `"10k/day"`; joins the second line. | | `sla=` | attribute | a text in double quotes like `"Order service"` | What is promised, such as `"< 200 ms"`; joins the second line. | | `mark=` | attribute | the id of an `adr` declared in this diagram | Id of a decision of the bar below, such as `E1`; the mark stands near the end. | | `bundle=` | attribute | a single word without quotes | Edges with the same bundle and a shared end share one trunk; needs `layout=adaptive`. | | `lane=` | attribute | a column or row name like `api` or `backend.1` | Column a vertical edge runs in, reaching into frames at its ends; needs `layout=adaptive`. | | `tone=` | attribute | one of `blue`, `indigo`, `purple`, `maroon`, `green`, `teal`, `slate`, `red`, `orange`, `peach`, `sky` | Colour of line and heads, such as `red` for a highlighted way. | | `style=` | attribute | the id of a `style` declared in this diagram | A `style` whose `tone` applies when the edge sets none. | The values of `arrow` and what they mean: | Value | Meaning | | ----- | ------------------------------------------------- | | `->` | synchronous call (filled head) | | `~>` | asynchronous message or event (dashed, open head) | | `-->` | dependency (dashed, open head) | | `=>` | data flow (thick line, filled head) | | `--` | connection without direction (no head) | | `<->` | call in both directions (a head at each end) | Examples: ```dgr kafka ~> importer "consume event" storage -> bucket "read object" via="S3 HEAD" ``` ### `note` [Section titled “note”](#note) ```text note <text> [on <ref>] ``` A dashed note above an element, with a tip pointing at it. It is no element and no edge. Written at the top level. | Part | Kind | Value | Meaning | | ---------- | -------- | ----------------------------------------------------------------- | ----------------------------------- | | `<text>` | argument | a text in double quotes like `"Order service"` | What the note says. | | `on <ref>` | clause | the id of a `person`, `system` or `node` declared in this diagram | The element it points at. Required. | Example: ```dgr note "replaced in Q3" on portal ``` ### `adr` [Section titled “adr”](#adr) ```text adr <id> <question> <equals> <choice> [then] [consequence] [open=<text>] ``` An architecture decision in the bar below the picture: question, the chosen option after `=`, and the consequence after `=>`. `mark=` with its id puts the mark into the picture. Written at the top level. | Part | Kind | Value | Meaning | | --------------- | ----------------- | ------------------------------------------------------------------------------- | ------------------------------------------------------------- | | `<id>` | argument | an identifier like `api` (letters, digits, `_` and `-`, starting with a letter) | Id of the decision, such as `E1`; `mark=E1` refers to it. | | `<question>` | argument | a text in double quotes like `"Order service"` | The question that was decided. | | `<equals>` | argument | one of the arrows `=` | Separates the question from the choice. | | `<choice>` | argument | a text in double quotes like `"Order service"` | The chosen option. | | `[then]` | optional argument | one of the arrows `=>` | Introduces the consequence. | | `[consequence]` | optional argument | a text in double quotes like `"Order service"` | What follows from the choice. | | `open=` | attribute | a text in double quotes like `"Order service"` | Who still decides an open question; the card is drawn dashed. | Example: ```dgr adr E1 "How do the services coordinate?" = "Events over Kafka" => "No central coordinator" ``` ## Diagnostic codes [Section titled “Diagnostic codes”](#diagnostic-codes) Besides the codes of the language and the kernel, listed in [the overview](/docs/language/#diagnostic-codes), the rules of `context` report these. An error stops the build; a warning is printed and the picture is still drawn. | Code | Severity | What it checks | | ------ | -------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `A001` | error | A note names the element it points at with `on`. | | `A007` | error | A group has exactly one role: `own`, `shared` or `external`. The role draws its frame and mutes shared elements. | | `A008` | error | Every element has a place in the grid with `at column/row`. | | `A103` | error | Column and row of `at` are names of the grid. | | `A105` | error | An edge connects two different elements or groups. | | `A106` | error | Every column and every row is named once. | | `A107` | error | An edge does not lead from an element to the group that holds it, or back. | | `A109` | error | Areas (`span`, `slot`, `width`, `height`), bundles and layers need `layout=adaptive`; areas reach right and down within the grid; `cover` names a column; groups nest without a cycle; a bundle shares an end and a kind; a row has one layer. | | `A710` | warning | An edge says what happens: a label or a protocol (`via=`). | | `A801` | warning | A decision of the bar has a mark in the picture, on an element or a step (`mark=`). | # sequence > A UML sequence diagram (UML 2.5.1, chapter 17): lifelines from left to right in source order, messages and fragments from top to bottom. Fragments nest by indentation. A UML sequence diagram (UML 2.5.1, chapter 17): lifelines from left to right in source order, messages and fragments from top to bottom. Fragments nest by indentation. This page lists everything a `sequence` diagram may contain. The same grammar is available as data with `dgr grammar sequence --json`, and [the overview](/docs/language/) explains how lines, texts and attributes are written and lists the codes every kind shares. ## The first line [Section titled “The first line”](#the-first-line) ```text diagram sequence "Title" [subtitle=<text>] [look=<plain|cards>] [locale=<en|de>] ``` Every sequence diagram starts with this line. | Part | Kind | Value | Meaning | | ----------- | --------- | ---------------------------------------------- | -------------------------------------------------------------------------------------------------- | | `subtitle=` | attribute | a text in double quotes like `"Order service"` | Second line below the title. | | `look=` | attribute | one of `plain`, `cards` | `plain` (default) draws the UML notation, `cards` toned cards. | | `locale=` | attribute | one of `en`, `de` | Language of the texts Diagrist adds to the picture and of the description: `en` (default) or `de`. | Example: ```dgr diagram sequence "Title" ``` ## Statements [Section titled “Statements”](#statements) Each statement is one line that starts with its keyword. Statements inside blocks are indented below them. Like every kind, `sequence` also has `use`, `variant`, `set` and `drop`, described in [the overview](/docs/language/#statements-of-every-kind). | Statement | Where | What it does | | ----------------------------- | ----------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | [`participant`](#participant) | top level | A lifeline drawn as a box, from left to right in source order. | | [`actor`](#actor) | top level | A lifeline drawn as a stick figure, from left to right in source order. | | [`database`](#database) | top level | A lifeline drawn as a cylinder, from left to right in source order. | | [`queue`](#queue) | top level | A lifeline drawn as a horizontal tube, from left to right in source order. | | [`boundary`](#boundary) | top level | A lifeline drawn as the boundary symbol of robustness analysis, from left to right in source order. | | [`control`](#control) | top level | A lifeline drawn as the control symbol of robustness analysis, from left to right in source order. | | [`entity`](#entity) | top level | A lifeline drawn as the entity symbol of robustness analysis, from left to right in source order. | | [`autonumber`](#autonumber) | top level | Numbers all messages in source order (1, 2, 3 …), across fragments; the number stands before the label. | | [`frame`](#frame) | top level | A frame around the whole interaction with `sd Name` in its tag. | | [`msg`](#msg) | top level and inside blocks | A message in source order; its arrow says what kind. | | [`create`](#create) | top level and inside blocks | A creation message: dashed with an open head, and the head of the receiver stands at its height. | | [`destroy`](#destroy) | top level and inside blocks | Destruction: the lifeline ends here with an X. | | [`activate`](#activate) | top level and inside blocks | Starts an activation bar by hand, for processing after an asynchronous message. | | [`deactivate`](#deactivate) | top level and inside blocks | Ends the bar the last `activate` of this lifeline started. | | [`note`](#note) | top level and inside blocks | A note at this point of the time axis, over the lifelines of `over=`. | | [`ref`](#ref) | top level and inside blocks | A reference to another interaction (interaction use): a frame tagged `ref` over the lifelines of `over=`. | | [`invariant`](#invariant) | top level and inside blocks | A state invariant at this point on the lifeline `on=`: a condition in `{...}`, or with `state` a state in a rounded box. | | [`divider`](#divider) | top level | A divider on the time axis: a double line across all lifelines with the text in a box in the middle. | | [`coregion`](#coregion) | top level and inside blocks | A coregion on the lifeline: the order of the indented events is arbitrary, drawn as square brackets on the lifeline. | | [`alt`](#alt) | top level and inside blocks | Alternatives: the first operand whose guard holds is taken; further operands start with `else`. | | [`else`](#else) | inside `alt` | The next operand of `alt`, written inside `alt` with its statements indented below it. | | [`opt`](#opt) | top level and inside blocks | An optional part, taken when its guard holds. | | [`loop`](#loop) | top level and inside blocks | A repetition while the guard holds. | | [`par`](#par) | top level and inside blocks | Parallel operands, separated by `and`; their events interleave freely. | | [`and`](#and) | inside `par`, `seq`, `strict` | The next operand of `par`, `seq` or `strict`, written inside the fragment with its statements indented below it. | | [`break`](#break) | top level and inside blocks | Ends the enclosing interaction when the guard holds. | | [`critical`](#critical) | top level and inside blocks | A critical region: its events are not interleaved. | | [`seq`](#seq) | top level and inside blocks | Weak sequencing of operands, separated by `and`. | | [`strict`](#strict) | top level and inside blocks | Strict sequencing of operands, separated by `and`. | | [`neg`](#neg) | top level and inside blocks | An invalid trace: what must not happen. | | [`assert`](#assert) | top level and inside blocks | The only valid trace at this point. | | [`ignore`](#ignore) | top level and inside blocks | Messages that may appear anywhere and are ignored; the guard lists their names and shows as `ignore {...}`. | | [`consider`](#consider) | top level and inside blocks | Only the listed messages are considered; the guard lists their names and shows as `consider {...}`. | | [`duration`](#duration) | top level | A duration constraint between two messages with `id=`: a bracket from the first to the second, left of the lifeline both touch when there is room, otherwise mirrored to the right or at the left edge. | | [`time`](#time) | top level | A time constraint of one message with `id=`: a tick at its height left of its lifeline or at the left edge, the text in `{...}`. | | [`adr`](#adr) | top level | An architecture decision in the bar below the picture: question, the chosen option after `=`, and the consequence after `=>`. | ### `participant` [Section titled “participant”](#participant) ```text participant <id> <label> [stereotype=<text>] [tone=<choice>] [external] ``` A lifeline drawn as a box, from left to right in source order. Messages, notes and references name it by its id. UML 2.5.1: 17.3.3.1 Lifeline. Written at the top level. | Part | Kind | Value | Meaning | | ------------- | --------- | ------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------- | | `<id>` | argument | an identifier like `api` (letters, digits, `_` and `-`, starting with a letter) | Id that messages, `activate`, `note` and `ref` use for this lifeline. | | `<label>` | argument | a text in double quotes like `"Order service"` | Name shown in the head. | | `stereotype=` | attribute | a text in double quotes like `"Order service"` | Stereotype above the name, written without guillemets: `service` shows `«service»`. | | `tone=` | attribute | one of `blue`, `indigo`, `purple`, `maroon`, `green`, `teal`, `slate`, `red`, `orange`, `peach`, `sky` | Colour of the head and its bars in `look=cards`; without it the head is slate. | | `external` | flag | | Draws the head dashed: the system is outside the scope of the diagram. | Example: ```dgr participant api "api-service" stereotype="service" ``` ### `actor` [Section titled “actor”](#actor) ```text actor <id> <label> [stereotype=<text>] [tone=<choice>] [external] ``` A lifeline drawn as a stick figure, from left to right in source order. Messages, notes and references name it by its id. UML 2.5.1: 17.3.3.1 Lifeline. Written at the top level. | Part | Kind | Value | Meaning | | ------------- | --------- | ------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------- | | `<id>` | argument | an identifier like `api` (letters, digits, `_` and `-`, starting with a letter) | Id that messages, `activate`, `note` and `ref` use for this lifeline. | | `<label>` | argument | a text in double quotes like `"Order service"` | Name shown in the head. | | `stereotype=` | attribute | a text in double quotes like `"Order service"` | Stereotype above the name, written without guillemets: `service` shows `«service»`. | | `tone=` | attribute | one of `blue`, `indigo`, `purple`, `maroon`, `green`, `teal`, `slate`, `red`, `orange`, `peach`, `sky` | Colour of the head and its bars in `look=cards`; without it the head is slate. | | `external` | flag | | Draws the head dashed: the system is outside the scope of the diagram. | Example: ```dgr actor customer "Customer" ``` ### `database` [Section titled “database”](#database) ```text database <id> <label> [stereotype=<text>] [tone=<choice>] [external] ``` A lifeline drawn as a cylinder, from left to right in source order. Messages, notes and references name it by its id. UML 2.5.1: 17.3.3.1 Lifeline. Written at the top level. | Part | Kind | Value | Meaning | | ------------- | --------- | ------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------- | | `<id>` | argument | an identifier like `api` (letters, digits, `_` and `-`, starting with a letter) | Id that messages, `activate`, `note` and `ref` use for this lifeline. | | `<label>` | argument | a text in double quotes like `"Order service"` | Name shown in the head. | | `stereotype=` | attribute | a text in double quotes like `"Order service"` | Stereotype above the name, written without guillemets: `service` shows `«service»`. | | `tone=` | attribute | one of `blue`, `indigo`, `purple`, `maroon`, `green`, `teal`, `slate`, `red`, `orange`, `peach`, `sky` | Colour of the head and its bars in `look=cards`; without it the head is slate. | | `external` | flag | | Draws the head dashed: the system is outside the scope of the diagram. | Example: ```dgr database db "Orders DB" ``` ### `queue` [Section titled “queue”](#queue) ```text queue <id> <label> [stereotype=<text>] [tone=<choice>] [external] ``` A lifeline drawn as a horizontal tube, from left to right in source order. Messages, notes and references name it by its id. UML 2.5.1: 17.3.3.1 Lifeline. Written at the top level. | Part | Kind | Value | Meaning | | ------------- | --------- | ------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------- | | `<id>` | argument | an identifier like `api` (letters, digits, `_` and `-`, starting with a letter) | Id that messages, `activate`, `note` and `ref` use for this lifeline. | | `<label>` | argument | a text in double quotes like `"Order service"` | Name shown in the head. | | `stereotype=` | attribute | a text in double quotes like `"Order service"` | Stereotype above the name, written without guillemets: `service` shows `«service»`. | | `tone=` | attribute | one of `blue`, `indigo`, `purple`, `maroon`, `green`, `teal`, `slate`, `red`, `orange`, `peach`, `sky` | Colour of the head and its bars in `look=cards`; without it the head is slate. | | `external` | flag | | Draws the head dashed: the system is outside the scope of the diagram. | Example: ```dgr queue broker "Kafka" ``` ### `boundary` [Section titled “boundary”](#boundary) ```text boundary <id> <label> [stereotype=<text>] [tone=<choice>] [external] ``` A lifeline drawn as the boundary symbol of robustness analysis, from left to right in source order. Messages, notes and references name it by its id. UML 2.5.1: 17.3.3.1 Lifeline. Written at the top level. | Part | Kind | Value | Meaning | | ------------- | --------- | ------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------- | | `<id>` | argument | an identifier like `api` (letters, digits, `_` and `-`, starting with a letter) | Id that messages, `activate`, `note` and `ref` use for this lifeline. | | `<label>` | argument | a text in double quotes like `"Order service"` | Name shown in the head. | | `stereotype=` | attribute | a text in double quotes like `"Order service"` | Stereotype above the name, written without guillemets: `service` shows `«service»`. | | `tone=` | attribute | one of `blue`, `indigo`, `purple`, `maroon`, `green`, `teal`, `slate`, `red`, `orange`, `peach`, `sky` | Colour of the head and its bars in `look=cards`; without it the head is slate. | | `external` | flag | | Draws the head dashed: the system is outside the scope of the diagram. | Example: ```dgr boundary form "Order form" ``` ### `control` [Section titled “control”](#control) ```text control <id> <label> [stereotype=<text>] [tone=<choice>] [external] ``` A lifeline drawn as the control symbol of robustness analysis, from left to right in source order. Messages, notes and references name it by its id. UML 2.5.1: 17.3.3.1 Lifeline. Written at the top level. | Part | Kind | Value | Meaning | | ------------- | --------- | ------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------- | | `<id>` | argument | an identifier like `api` (letters, digits, `_` and `-`, starting with a letter) | Id that messages, `activate`, `note` and `ref` use for this lifeline. | | `<label>` | argument | a text in double quotes like `"Order service"` | Name shown in the head. | | `stereotype=` | attribute | a text in double quotes like `"Order service"` | Stereotype above the name, written without guillemets: `service` shows `«service»`. | | `tone=` | attribute | one of `blue`, `indigo`, `purple`, `maroon`, `green`, `teal`, `slate`, `red`, `orange`, `peach`, `sky` | Colour of the head and its bars in `look=cards`; without it the head is slate. | | `external` | flag | | Draws the head dashed: the system is outside the scope of the diagram. | Example: ```dgr control checkout "Checkout" ``` ### `entity` [Section titled “entity”](#entity) ```text entity <id> <label> [stereotype=<text>] [tone=<choice>] [external] ``` A lifeline drawn as the entity symbol of robustness analysis, from left to right in source order. Messages, notes and references name it by its id. UML 2.5.1: 17.3.3.1 Lifeline. Written at the top level. | Part | Kind | Value | Meaning | | ------------- | --------- | ------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------- | | `<id>` | argument | an identifier like `api` (letters, digits, `_` and `-`, starting with a letter) | Id that messages, `activate`, `note` and `ref` use for this lifeline. | | `<label>` | argument | a text in double quotes like `"Order service"` | Name shown in the head. | | `stereotype=` | attribute | a text in double quotes like `"Order service"` | Stereotype above the name, written without guillemets: `service` shows `«service»`. | | `tone=` | attribute | one of `blue`, `indigo`, `purple`, `maroon`, `green`, `teal`, `slate`, `red`, `orange`, `peach`, `sky` | Colour of the head and its bars in `look=cards`; without it the head is slate. | | `external` | flag | | Draws the head dashed: the system is outside the scope of the diagram. | Example: ```dgr entity order "Order" ``` ### `autonumber` [Section titled “autonumber”](#autonumber) ```text autonumber ``` Numbers all messages in source order (1, 2, 3 …), across fragments; the number stands before the label. Written at the top level. Example: ```dgr autonumber ``` ### `frame` [Section titled “frame”](#frame) ```text frame [label] ``` A frame around the whole interaction with `sd Name` in its tag. Without a name it shows the title. Gates (`gate` in `msg`) draw the frame without this line too. UML 2.5.1: 17.2.3.1 Interaction, drawn as a frame. Written at the top level. | Part | Kind | Value | Meaning | | --------- | ----------------- | ---------------------------------------------- | ---------------------------------------------------------- | | `[label]` | optional argument | a text in double quotes like `"Order service"` | Name of the interaction in the tag; defaults to the title. | Example: ```dgr frame "OAuth callback" ``` ### `msg` [Section titled “msg”](#msg) ```text msg <from> <arrow> <to> [label] [id=<id>] [mark=<ref>] [duration=<text>] [emph] ``` A message in source order; its arrow says what kind. Sender equal to receiver is a self call. Calls and replies activate the receiver by themselves. `found` as sender and `lost` as receiver are found and lost messages; `gate` is a gate on the frame of the interaction (`gate -> a` comes in from the left, `a --> gate` replies to the left, `a -> gate` leaves to the right), `gate.name` names it. The `id=` of a `ref` or fragment as an end leads the message to its edge. UML 2.5.1: 17.4.3.1 Message. Written at the top level and inside `coregion`, `alt`, `else`, `opt`, `loop`, `par`, `and`, `break`, `critical`, `seq`, `strict`, `neg`, `assert`, `ignore` or `consider`. | Part | Kind | Value | Meaning | | ----------- | ----------------- | ----------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | `<from>` | argument | a lifeline id like `api`, `found`, `lost`, `gate`, `gate.name`, or the `id=` of a `ref` or fragment, optionally with `.name` | Sender: a lifeline, `found`, `gate`, or a frame with `id=`. UML 2.5.1: `found` 17.4.3.1 Found message, without sender; `gate` 17.4.3.5 Gate on the frame of the interaction. | | `<arrow>` | argument | one of the arrows `->` synchronous call (filled head), `~>` asynchronous message (open head), `-->` reply (dashed, open head) | The kind of message, which also decides how it is drawn. UML 2.5.1: `->` 17.4.3.1 Synchronous call; `~>` 17.4.3.1 Asynchronous call or signal; `-->` 17.4.3.1 Reply to a call. | | `<to>` | argument | a lifeline id like `api`, `found`, `lost`, `gate`, `gate.name`, or the `id=` of a `ref` or fragment, optionally with `.name` | Receiver: a lifeline, `lost`, `gate`, or a frame with `id=`. UML 2.5.1: `lost` 17.4.3.1 Lost message, without receiver; `gate` 17.4.3.5 Gate on the frame of the interaction. | | `[label]` | optional argument | a text in double quotes like `"Order service"` | What is sent; without it the arrow has no label. | | `id=` | attribute | an identifier like `api` (letters, digits, `_` and `-`, starting with a letter) | Name of the message that `duration` and `time` refer to. | | `mark=` | attribute | the id of an `adr` declared in this diagram | Id of a decision of the decision bar, such as `E1`; the mark is drawn after the label. | | `duration=` | attribute | a text in double quotes like `"Order service"` | Duration of the transmission: the arrow slopes down and shows the text in `{...}`. UML 2.5.1: 8.5.3.2 Duration constraint. | | `emph` | flag | | Highlights the message in the accent colour. | The values of `arrow` and what they mean: | Value | Meaning | | ----- | -------------------------------- | | `->` | synchronous call (filled head) | | `~>` | asynchronous message (open head) | | `-->` | reply (dashed, open head) | Examples: ```dgr msg client -> api "GET /orders" id=request msg api --> client "200 OK" msg gate.order -> api "place(order)" emph ``` ### `create` [Section titled “create”](#create) ```text create <from> <arrow> <to> [label] [id=<id>] [mark=<ref>] [duration=<text>] [emph] ``` A creation message: dashed with an open head, and the head of the receiver stands at its height. Before it the lifeline does not exist. UML 2.5.1: 17.4.3.1 Message that creates a lifeline. Written at the top level and inside `alt`, `else`, `opt`, `loop`, `par`, `and`, `break`, `critical`, `seq`, `strict`, `neg`, `assert`, `ignore` or `consider`. | Part | Kind | Value | Meaning | | ----------- | ----------------- | ------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------- | | `<from>` | argument | the id of a `participant`, `actor`, `database`, `queue`, `boundary`, `control` or `entity` declared in this diagram | The lifeline that creates. | | `<arrow>` | argument | one of the arrows `->` | Always `->`. | | `<to>` | argument | the id of a `participant`, `actor`, `database`, `queue`, `boundary`, `control` or `entity` declared in this diagram | The lifeline that is created. | | `[label]` | optional argument | a text in double quotes like `"Order service"` | The constructor call; without it the arrow has no label. | | `id=` | attribute | an identifier like `api` (letters, digits, `_` and `-`, starting with a letter) | Name of the message that `duration` and `time` refer to. | | `mark=` | attribute | the id of an `adr` declared in this diagram | Id of a decision of the decision bar, such as `E1`; the mark is drawn after the label. | | `duration=` | attribute | a text in double quotes like `"Order service"` | Duration of the transmission: the arrow slopes down and shows the text in `{...}`. UML 2.5.1: 8.5.3.2 Duration constraint. | | `emph` | flag | | Highlights the message in the accent colour. | Example: ```dgr create client -> meter "new MeterData()" ``` ### `destroy` [Section titled “destroy”](#destroy) ```text destroy <target> ``` Destruction: the lifeline ends here with an X. No message reaches it afterwards. UML 2.5.1: 17.4.3.4 End of a lifeline (destruction). Written at the top level and inside `alt`, `else`, `opt`, `loop`, `par`, `and`, `break`, `critical`, `seq`, `strict`, `neg`, `assert`, `ignore` or `consider`. | Part | Kind | Value | Meaning | | ---------- | -------- | ------------------------------------------------------------------------------------------------------------------- | ----------------------- | | `<target>` | argument | the id of a `participant`, `actor`, `database`, `queue`, `boundary`, `control` or `entity` declared in this diagram | The lifeline that ends. | Example: ```dgr destroy session ``` ### `activate` [Section titled “activate”](#activate) ```text activate <target> ``` Starts an activation bar by hand, for processing after an asynchronous message. Calls and replies need none, their bars appear by themselves. Ends with `deactivate`. UML 2.5.1: 17.2.3.4 Execution on a lifeline (activation bar). Written at the top level and inside `coregion`, `alt`, `else`, `opt`, `loop`, `par`, `and`, `break`, `critical`, `seq`, `strict`, `neg`, `assert`, `ignore` or `consider`. | Part | Kind | Value | Meaning | | ---------- | -------- | ------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------- | | `<target>` | argument | the id of a `participant`, `actor`, `database`, `queue`, `boundary`, `control` or `entity` declared in this diagram | The lifeline whose bar starts at the last message. | Example: ```dgr activate worker ``` ### `deactivate` [Section titled “deactivate”](#deactivate) ```text deactivate <target> ``` Ends the bar the last `activate` of this lifeline started. UML 2.5.1: 17.2.3.4 Execution on a lifeline (activation bar). Written at the top level and inside `coregion`, `alt`, `else`, `opt`, `loop`, `par`, `and`, `break`, `critical`, `seq`, `strict`, `neg`, `assert`, `ignore` or `consider`. | Part | Kind | Value | Meaning | | ---------- | -------- | ------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------ | | `<target>` | argument | the id of a `participant`, `actor`, `database`, `queue`, `boundary`, `control` or `entity` declared in this diagram | The lifeline whose bar ends at the last message. | Example: ```dgr deactivate worker ``` ### `note` [Section titled “note”](#note) ```text note <text> [over=<lifelines>] ``` A note at this point of the time axis, over the lifelines of `over=`. Long texts wrap. UML 2.5.1: 7.2.3.2 Comment (note). Written at the top level and inside `coregion`, `alt`, `else`, `opt`, `loop`, `par`, `and`, `break`, `critical`, `seq`, `strict`, `neg`, `assert`, `ignore` or `consider`. | Part | Kind | Value | Meaning | | -------- | --------- | --------------------------------------------------------------------- | ---------------------------------------------------------------------------------------- | | `<text>` | argument | a text in double quotes like `"Order service"` | What the note says. | | `over=` | attribute | lifeline ids separated by commas without spaces, like `auftrag,lager` | Lifelines it spans, comma separated without spaces, like `over=auftrag,lager`. Required. | Example: ```dgr note "Idempotency key = order number" over=api,db ``` ### `ref` [Section titled “ref”](#ref) ```text ref <label> [over=<lifelines>] [id=<id>] [file=<text>] ``` A reference to another interaction (interaction use): a frame tagged `ref` over the lifelines of `over=`. With `id=r` the messages right after it that name `r` as an end run to its edge (actual gates, `r.name` names them), and the frame grows to hold them. UML 2.5.1: 17.7.3.1 Use of another interaction (`ref`). Written at the top level and inside `alt`, `else`, `opt`, `loop`, `par`, `and`, `break`, `critical`, `seq`, `strict`, `neg`, `assert`, `ignore` or `consider`. | Part | Kind | Value | Meaning | | --------- | --------- | ------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------- | | `<label>` | argument | a text in double quotes like `"Order service"` | Name of the referenced interaction. | | `over=` | attribute | lifeline ids separated by commas without spaces, like `auftrag,lager` | Lifelines it spans, comma separated without spaces, like `over=auftrag,lager`. Required. | | `id=` | attribute | an identifier like `api` (letters, digits, `_` and `-`, starting with a letter) | Name of the frame, for messages that start or end at its edge. UML 2.5.1: 17.4.3.5 Gate on an interaction use. | | `file=` | attribute | a text in double quotes like `"Order service"` | File of the referenced sequence diagram, relative to this one; named in the description. | Example: ```dgr ref "Authorize payment" over=payment,psp id=pay file="authorize-payment.dgr" ``` ### `invariant` [Section titled “invariant”](#invariant) ```text invariant <text> [on=<ref>] [state] ``` A state invariant at this point on the lifeline `on=`: a condition in `{...}`, or with `state` a state in a rounded box. UML 2.5.1: 17.2.3.5 State invariant. Written at the top level and inside `alt`, `else`, `opt`, `loop`, `par`, `and`, `break`, `critical`, `seq`, `strict`, `neg`, `assert`, `ignore` or `consider`. | Part | Kind | Value | Meaning | | -------- | --------- | ------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------- | | `<text>` | argument | a text in double quotes like `"Order service"` | The condition or state, without braces. | | `on=` | attribute | the id of a `participant`, `actor`, `database`, `queue`, `boundary`, `control` or `entity` declared in this diagram | The lifeline the invariant holds on. Required. | | `state` | flag | | Draws a state in a rounded box instead of a condition in braces. | Example: ```dgr invariant "logged in" on=bff state ``` ### `divider` [Section titled “divider”](#divider) ```text divider [label] ``` A divider on the time axis: a double line across all lifelines with the text in a box in the middle. Only at the top level, not inside a fragment. Written at the top level. | Part | Kind | Value | Meaning | | --------- | ----------------- | ---------------------------------------------- | ------------------------------------- | | `[label]` | optional argument | a text in double quotes like `"Order service"` | Name of the section that starts here. | Example: ```dgr divider "Accept the webhook" ``` ### `coregion` [Section titled “coregion”](#coregion) ```text coregion <on> ``` A coregion on the lifeline: the order of the indented events is arbitrary, drawn as square brackets on the lifeline. Only messages from or to it, `activate`, `deactivate` and `note` may stand in it. UML 2.5.1: 17.6.4.10 Coregion, unordered events on one lifeline. Written at the top level and inside `alt`, `else`, `opt`, `loop`, `par`, `and`, `break`, `critical`, `seq`, `strict`, `neg`, `assert`, `ignore` or `consider`. Indented below it: `msg`, `activate`, `deactivate`, `note`. | Part | Kind | Value | Meaning | | ------ | -------- | ------------------------------------------------------------------------------------------------------------------- | ---------------------------------------- | | `<on>` | argument | the id of a `participant`, `actor`, `database`, `queue`, `boundary`, `control` or `entity` declared in this diagram | The lifeline whose events are unordered. | Example: ```dgr coregion notify ``` ### `alt` [Section titled “alt”](#alt) ```text alt [guard] [id=<id>] ``` Alternatives: the first operand whose guard holds is taken; further operands start with `else`. The statements indented below it belong to the fragment; fragments nest. UML 2.5.1: 17.6.3.3 Combined fragment, 17.6.3.7 Alternatives (`alt`), 17.6.3.1 Operand of a combined fragment. Written at the top level and inside `alt`, `else`, `opt`, `loop`, `par`, `and`, `break`, `critical`, `seq`, `strict`, `neg`, `assert`, `ignore` or `consider`. Indented below it: `msg`, `create`, `destroy`, `activate`, `deactivate`, `note`, `ref`, `invariant`, `coregion`, `alt`, `opt`, `loop`, `par`, `break`, `critical`, `seq`, `strict`, `neg`, `assert`, `ignore`, `consider`, `else`. | Part | Kind | Value | Meaning | | --------- | ----------------- | ------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | `[guard]` | optional argument | a text in double quotes like `"Order service"` | Condition of the first operand, without brackets; Diagrist adds `[...]`. UML 2.5.1: 17.6.3.2 Guard of an operand. | | `id=` | attribute | an identifier like `api` (letters, digits, `_` and `-`, starting with a letter) | Name of the frame: a message with this name as an end starts or ends at its edge (a gate of the fragment, `f.name` names it). UML 2.5.1: 17.4.3.5 Gate on a combined fragment. | Example: ```dgr alt "token valid" ``` ### `else` [Section titled “else”](#else) ```text else [guard] ``` The next operand of `alt`, written inside `alt` with its statements indented below it. Without a guard it shows `[else]`. A dashed line separates the operands. UML 2.5.1: 17.6.3.1 Operand of a combined fragment. Written only inside `alt`. Indented below it: `msg`, `create`, `destroy`, `activate`, `deactivate`, `note`, `ref`, `invariant`, `coregion`, `alt`, `opt`, `loop`, `par`, `break`, `critical`, `seq`, `strict`, `neg`, `assert`, `ignore`, `consider`. | Part | Kind | Value | Meaning | | --------- | ----------------- | ---------------------------------------------- | ------------------------------------------------------------------------------------- | | `[guard]` | optional argument | a text in double quotes like `"Order service"` | Condition of this operand, without brackets. UML 2.5.1: 17.6.3.2 Guard of an operand. | Example: ```dgr else "invalid token" ``` ### `opt` [Section titled “opt”](#opt) ```text opt [guard] [id=<id>] ``` An optional part, taken when its guard holds. The statements indented below it belong to the fragment; fragments nest. UML 2.5.1: 17.6.3.3 Combined fragment, 17.6.3.8 Option (`opt`), 17.6.3.1 Operand of a combined fragment. Written at the top level and inside `alt`, `else`, `opt`, `loop`, `par`, `and`, `break`, `critical`, `seq`, `strict`, `neg`, `assert`, `ignore` or `consider`. Indented below it: `msg`, `create`, `destroy`, `activate`, `deactivate`, `note`, `ref`, `invariant`, `coregion`, `alt`, `opt`, `loop`, `par`, `break`, `critical`, `seq`, `strict`, `neg`, `assert`, `ignore`, `consider`. | Part | Kind | Value | Meaning | | --------- | ----------------- | ------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | `[guard]` | optional argument | a text in double quotes like `"Order service"` | Condition of the first operand, without brackets; Diagrist adds `[...]`. UML 2.5.1: 17.6.3.2 Guard of an operand. | | `id=` | attribute | an identifier like `api` (letters, digits, `_` and `-`, starting with a letter) | Name of the frame: a message with this name as an end starts or ends at its edge (a gate of the fragment, `f.name` names it). UML 2.5.1: 17.4.3.5 Gate on a combined fragment. | Example: ```dgr opt "3-D Secure required" ``` ### `loop` [Section titled “loop”](#loop) ```text loop [guard] [id=<id>] ``` A repetition while the guard holds. The statements indented below it belong to the fragment; fragments nest. UML 2.5.1: 17.6.3.3 Combined fragment, 17.6.3.17 Loop (`loop`), 17.6.3.1 Operand of a combined fragment. Written at the top level and inside `alt`, `else`, `opt`, `loop`, `par`, `and`, `break`, `critical`, `seq`, `strict`, `neg`, `assert`, `ignore` or `consider`. Indented below it: `msg`, `create`, `destroy`, `activate`, `deactivate`, `note`, `ref`, `invariant`, `coregion`, `alt`, `opt`, `loop`, `par`, `break`, `critical`, `seq`, `strict`, `neg`, `assert`, `ignore`, `consider`. | Part | Kind | Value | Meaning | | --------- | ----------------- | ------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | `[guard]` | optional argument | a text in double quotes like `"Order service"` | Condition of the first operand, without brackets; Diagrist adds `[...]`. UML 2.5.1: 17.6.3.2 Guard of an operand. | | `id=` | attribute | an identifier like `api` (letters, digits, `_` and `-`, starting with a letter) | Name of the frame: a message with this name as an end starts or ends at its edge (a gate of the fragment, `f.name` names it). UML 2.5.1: 17.4.3.5 Gate on a combined fragment. | Example: ```dgr loop "at most 3 times" id=retry ``` ### `par` [Section titled “par”](#par) ```text par [guard] [id=<id>] ``` Parallel operands, separated by `and`; their events interleave freely. The statements indented below it belong to the fragment; fragments nest. UML 2.5.1: 17.6.3.3 Combined fragment, 17.6.3.10 Parallel (`par`), 17.6.3.1 Operand of a combined fragment. Written at the top level and inside `alt`, `else`, `opt`, `loop`, `par`, `and`, `break`, `critical`, `seq`, `strict`, `neg`, `assert`, `ignore` or `consider`. Indented below it: `msg`, `create`, `destroy`, `activate`, `deactivate`, `note`, `ref`, `invariant`, `coregion`, `alt`, `opt`, `loop`, `par`, `break`, `critical`, `seq`, `strict`, `neg`, `assert`, `ignore`, `consider`, `and`. | Part | Kind | Value | Meaning | | --------- | ----------------- | ------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | `[guard]` | optional argument | a text in double quotes like `"Order service"` | Condition of the first operand, without brackets; Diagrist adds `[...]`. UML 2.5.1: 17.6.3.2 Guard of an operand. | | `id=` | attribute | an identifier like `api` (letters, digits, `_` and `-`, starting with a letter) | Name of the frame: a message with this name as an end starts or ends at its edge (a gate of the fragment, `f.name` names it). UML 2.5.1: 17.4.3.5 Gate on a combined fragment. | Example: ```dgr par ``` ### `and` [Section titled “and”](#and) ```text and [guard] ``` The next operand of `par`, `seq` or `strict`, written inside the fragment with its statements indented below it. UML 2.5.1: 17.6.3.1 Operand of a combined fragment. Written only inside `par`, `seq` or `strict`. Indented below it: `msg`, `create`, `destroy`, `activate`, `deactivate`, `note`, `ref`, `invariant`, `coregion`, `alt`, `opt`, `loop`, `par`, `break`, `critical`, `seq`, `strict`, `neg`, `assert`, `ignore`, `consider`. | Part | Kind | Value | Meaning | | --------- | ----------------- | ---------------------------------------------- | ------------------------------------------------------------------------------------- | | `[guard]` | optional argument | a text in double quotes like `"Order service"` | Condition of this operand, without brackets. UML 2.5.1: 17.6.3.2 Guard of an operand. | Example: ```dgr and ``` ### `break` [Section titled “break”](#break) ```text break [guard] [id=<id>] ``` Ends the enclosing interaction when the guard holds. The statements indented below it belong to the fragment; fragments nest. UML 2.5.1: 17.6.3.3 Combined fragment, 17.6.3.9 Break (`break`), 17.6.3.1 Operand of a combined fragment. Written at the top level and inside `alt`, `else`, `opt`, `loop`, `par`, `and`, `break`, `critical`, `seq`, `strict`, `neg`, `assert`, `ignore` or `consider`. Indented below it: `msg`, `create`, `destroy`, `activate`, `deactivate`, `note`, `ref`, `invariant`, `coregion`, `alt`, `opt`, `loop`, `par`, `break`, `critical`, `seq`, `strict`, `neg`, `assert`, `ignore`, `consider`. | Part | Kind | Value | Meaning | | --------- | ----------------- | ------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | `[guard]` | optional argument | a text in double quotes like `"Order service"` | Condition of the first operand, without brackets; Diagrist adds `[...]`. UML 2.5.1: 17.6.3.2 Guard of an operand. | | `id=` | attribute | an identifier like `api` (letters, digits, `_` and `-`, starting with a letter) | Name of the frame: a message with this name as an end starts or ends at its edge (a gate of the fragment, `f.name` names it). UML 2.5.1: 17.4.3.5 Gate on a combined fragment. | Example: ```dgr break "timeout" ``` ### `critical` [Section titled “critical”](#critical) ```text critical [guard] [id=<id>] ``` A critical region: its events are not interleaved. The statements indented below it belong to the fragment; fragments nest. UML 2.5.1: 17.6.3.3 Combined fragment, 17.6.3.14 Critical region (`critical`), 17.6.3.1 Operand of a combined fragment. Written at the top level and inside `alt`, `else`, `opt`, `loop`, `par`, `and`, `break`, `critical`, `seq`, `strict`, `neg`, `assert`, `ignore` or `consider`. Indented below it: `msg`, `create`, `destroy`, `activate`, `deactivate`, `note`, `ref`, `invariant`, `coregion`, `alt`, `opt`, `loop`, `par`, `break`, `critical`, `seq`, `strict`, `neg`, `assert`, `ignore`, `consider`. | Part | Kind | Value | Meaning | | --------- | ----------------- | ------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | `[guard]` | optional argument | a text in double quotes like `"Order service"` | Condition of the first operand, without brackets; Diagrist adds `[...]`. UML 2.5.1: 17.6.3.2 Guard of an operand. | | `id=` | attribute | an identifier like `api` (letters, digits, `_` and `-`, starting with a letter) | Name of the frame: a message with this name as an end starts or ends at its edge (a gate of the fragment, `f.name` names it). UML 2.5.1: 17.4.3.5 Gate on a combined fragment. | Example: ```dgr critical ``` ### `seq` [Section titled “seq”](#seq) ```text seq [guard] [id=<id>] ``` Weak sequencing of operands, separated by `and`. The statements indented below it belong to the fragment; fragments nest. UML 2.5.1: 17.6.3.3 Combined fragment, 17.6.3.11 Weak sequencing (`seq`), 17.6.3.1 Operand of a combined fragment. Written at the top level and inside `alt`, `else`, `opt`, `loop`, `par`, `and`, `break`, `critical`, `seq`, `strict`, `neg`, `assert`, `ignore` or `consider`. Indented below it: `msg`, `create`, `destroy`, `activate`, `deactivate`, `note`, `ref`, `invariant`, `coregion`, `alt`, `opt`, `loop`, `par`, `break`, `critical`, `seq`, `strict`, `neg`, `assert`, `ignore`, `consider`, `and`. | Part | Kind | Value | Meaning | | --------- | ----------------- | ------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | `[guard]` | optional argument | a text in double quotes like `"Order service"` | Condition of the first operand, without brackets; Diagrist adds `[...]`. UML 2.5.1: 17.6.3.2 Guard of an operand. | | `id=` | attribute | an identifier like `api` (letters, digits, `_` and `-`, starting with a letter) | Name of the frame: a message with this name as an end starts or ends at its edge (a gate of the fragment, `f.name` names it). UML 2.5.1: 17.4.3.5 Gate on a combined fragment. | Example: ```dgr seq ``` ### `strict` [Section titled “strict”](#strict) ```text strict [guard] [id=<id>] ``` Strict sequencing of operands, separated by `and`. The statements indented below it belong to the fragment; fragments nest. UML 2.5.1: 17.6.3.3 Combined fragment, 17.6.3.12 Strict sequencing (`strict`), 17.6.3.1 Operand of a combined fragment. Written at the top level and inside `alt`, `else`, `opt`, `loop`, `par`, `and`, `break`, `critical`, `seq`, `strict`, `neg`, `assert`, `ignore` or `consider`. Indented below it: `msg`, `create`, `destroy`, `activate`, `deactivate`, `note`, `ref`, `invariant`, `coregion`, `alt`, `opt`, `loop`, `par`, `break`, `critical`, `seq`, `strict`, `neg`, `assert`, `ignore`, `consider`, `and`. | Part | Kind | Value | Meaning | | --------- | ----------------- | ------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | `[guard]` | optional argument | a text in double quotes like `"Order service"` | Condition of the first operand, without brackets; Diagrist adds `[...]`. UML 2.5.1: 17.6.3.2 Guard of an operand. | | `id=` | attribute | an identifier like `api` (letters, digits, `_` and `-`, starting with a letter) | Name of the frame: a message with this name as an end starts or ends at its edge (a gate of the fragment, `f.name` names it). UML 2.5.1: 17.4.3.5 Gate on a combined fragment. | Example: ```dgr strict ``` ### `neg` [Section titled “neg”](#neg) ```text neg [guard] [id=<id>] ``` An invalid trace: what must not happen. The statements indented below it belong to the fragment; fragments nest. UML 2.5.1: 17.6.3.3 Combined fragment, 17.6.3.13 Invalid traces (`neg`), 17.6.3.1 Operand of a combined fragment. Written at the top level and inside `alt`, `else`, `opt`, `loop`, `par`, `and`, `break`, `critical`, `seq`, `strict`, `neg`, `assert`, `ignore` or `consider`. Indented below it: `msg`, `create`, `destroy`, `activate`, `deactivate`, `note`, `ref`, `invariant`, `coregion`, `alt`, `opt`, `loop`, `par`, `break`, `critical`, `seq`, `strict`, `neg`, `assert`, `ignore`, `consider`. | Part | Kind | Value | Meaning | | --------- | ----------------- | ------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | `[guard]` | optional argument | a text in double quotes like `"Order service"` | Condition of the first operand, without brackets; Diagrist adds `[...]`. UML 2.5.1: 17.6.3.2 Guard of an operand. | | `id=` | attribute | an identifier like `api` (letters, digits, `_` and `-`, starting with a letter) | Name of the frame: a message with this name as an end starts or ends at its edge (a gate of the fragment, `f.name` names it). UML 2.5.1: 17.4.3.5 Gate on a combined fragment. | Example: ```dgr neg ``` ### `assert` [Section titled “assert”](#assert) ```text assert [guard] [id=<id>] ``` The only valid trace at this point. The statements indented below it belong to the fragment; fragments nest. UML 2.5.1: 17.6.3.3 Combined fragment, 17.6.3.16 Assertion (`assert`), 17.6.3.1 Operand of a combined fragment. Written at the top level and inside `alt`, `else`, `opt`, `loop`, `par`, `and`, `break`, `critical`, `seq`, `strict`, `neg`, `assert`, `ignore` or `consider`. Indented below it: `msg`, `create`, `destroy`, `activate`, `deactivate`, `note`, `ref`, `invariant`, `coregion`, `alt`, `opt`, `loop`, `par`, `break`, `critical`, `seq`, `strict`, `neg`, `assert`, `ignore`, `consider`. | Part | Kind | Value | Meaning | | --------- | ----------------- | ------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | `[guard]` | optional argument | a text in double quotes like `"Order service"` | Condition of the first operand, without brackets; Diagrist adds `[...]`. UML 2.5.1: 17.6.3.2 Guard of an operand. | | `id=` | attribute | an identifier like `api` (letters, digits, `_` and `-`, starting with a letter) | Name of the frame: a message with this name as an end starts or ends at its edge (a gate of the fragment, `f.name` names it). UML 2.5.1: 17.4.3.5 Gate on a combined fragment. | Example: ```dgr assert ``` ### `ignore` [Section titled “ignore”](#ignore) ```text ignore [guard] [id=<id>] ``` Messages that may appear anywhere and are ignored; the guard lists their names and shows as `ignore {...}`. The statements indented below it belong to the fragment; fragments nest. UML 2.5.1: 17.6.3.3 Combined fragment, 17.6.3.15 Ignored messages (`ignore`), 17.6.3.1 Operand of a combined fragment. Written at the top level and inside `alt`, `else`, `opt`, `loop`, `par`, `and`, `break`, `critical`, `seq`, `strict`, `neg`, `assert`, `ignore` or `consider`. Indented below it: `msg`, `create`, `destroy`, `activate`, `deactivate`, `note`, `ref`, `invariant`, `coregion`, `alt`, `opt`, `loop`, `par`, `break`, `critical`, `seq`, `strict`, `neg`, `assert`, `ignore`, `consider`. | Part | Kind | Value | Meaning | | --------- | ----------------- | ------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | `[guard]` | optional argument | a text in double quotes like `"Order service"` | Condition of the first operand, without brackets; Diagrist adds `[...]`. | | `id=` | attribute | an identifier like `api` (letters, digits, `_` and `-`, starting with a letter) | Name of the frame: a message with this name as an end starts or ends at its edge (a gate of the fragment, `f.name` names it). UML 2.5.1: 17.4.3.5 Gate on a combined fragment. | Example: ```dgr ignore "ping, status" ``` ### `consider` [Section titled “consider”](#consider) ```text consider [guard] [id=<id>] ``` Only the listed messages are considered; the guard lists their names and shows as `consider {...}`. The statements indented below it belong to the fragment; fragments nest. UML 2.5.1: 17.6.3.3 Combined fragment, 17.6.3.15 Considered messages (`consider`), 17.6.3.1 Operand of a combined fragment. Written at the top level and inside `alt`, `else`, `opt`, `loop`, `par`, `and`, `break`, `critical`, `seq`, `strict`, `neg`, `assert`, `ignore` or `consider`. Indented below it: `msg`, `create`, `destroy`, `activate`, `deactivate`, `note`, `ref`, `invariant`, `coregion`, `alt`, `opt`, `loop`, `par`, `break`, `critical`, `seq`, `strict`, `neg`, `assert`, `ignore`, `consider`. | Part | Kind | Value | Meaning | | --------- | ----------------- | ------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | `[guard]` | optional argument | a text in double quotes like `"Order service"` | Condition of the first operand, without brackets; Diagrist adds `[...]`. | | `id=` | attribute | an identifier like `api` (letters, digits, `_` and `-`, starting with a letter) | Name of the frame: a message with this name as an end starts or ends at its edge (a gate of the fragment, `f.name` names it). UML 2.5.1: 17.4.3.5 Gate on a combined fragment. | Example: ```dgr consider "order, pay" ``` ### `duration` [Section titled “duration”](#duration) ```text duration <from> <to> <text> ``` A duration constraint between two messages with `id=`: a bracket from the first to the second, left of the lifeline both touch when there is room, otherwise mirrored to the right or at the left edge. The text is written without braces; Diagrist adds `{...}`. UML 2.5.1: 8.5.3.2 Duration constraint. Written at the top level. | Part | Kind | Value | Meaning | | -------- | -------- | ------------------------------------------------------ | ------------------------------- | | `<from>` | argument | the id of a `msg` or `create` declared in this diagram | The earlier message. | | `<to>` | argument | the id of a `msg` or `create` declared in this diagram | The later message. | | `<text>` | argument | a text in double quotes like `"Order service"` | The constraint, without braces. | Example: ```dgr duration request response "≤ 300 ms" ``` ### `time` [Section titled “time”](#time) ```text time <at> <text> ``` A time constraint of one message with `id=`: a tick at its height left of its lifeline or at the left edge, the text in `{...}`. UML 2.5.1: 8.5.3.2 Time constraint. Written at the top level. | Part | Kind | Value | Meaning | | -------- | -------- | ------------------------------------------------------ | ------------------------------- | | `<at>` | argument | the id of a `msg` or `create` declared in this diagram | The message. | | `<text>` | argument | a text in double quotes like `"Order service"` | The constraint, without braces. | Example: ```dgr time request "t = now" ``` ### `adr` [Section titled “adr”](#adr) ```text adr <id> <question> <equals> <choice> [then] [consequence] [open=<text>] ``` An architecture decision in the bar below the picture: question, the chosen option after `=`, and the consequence after `=>`. `mark=` with its id puts the mark into the picture. Written at the top level. | Part | Kind | Value | Meaning | | --------------- | ----------------- | ------------------------------------------------------------------------------- | ------------------------------------------------------------- | | `<id>` | argument | an identifier like `api` (letters, digits, `_` and `-`, starting with a letter) | Id of the decision, such as `E1`; `mark=E1` refers to it. | | `<question>` | argument | a text in double quotes like `"Order service"` | The question that was decided. | | `<equals>` | argument | one of the arrows `=` | Separates the question from the choice. | | `<choice>` | argument | a text in double quotes like `"Order service"` | The chosen option. | | `[then]` | optional argument | one of the arrows `=>` | Introduces the consequence. | | `[consequence]` | optional argument | a text in double quotes like `"Order service"` | What follows from the choice. | | `open=` | attribute | a text in double quotes like `"Order service"` | Who still decides an open question; the card is drawn dashed. | Example: ```dgr adr E1 "How do the services coordinate?" = "Events over Kafka" => "No central coordinator" ``` ## Diagnostic codes [Section titled “Diagnostic codes”](#diagnostic-codes) Besides the codes of the language and the kernel, listed in [the overview](/docs/language/#diagnostic-codes), the rules of `sequence` report these. An error stops the build; a warning is printed and the picture is still drawn. | Code | Severity | What it checks | | ------ | -------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `U400` | error | Message ends and `over=` lists name declared lifelines. `lang` checks the other references; these can also be gates, so the plugin checks them. UML 2.5.1: 17.3.3.1 Lifeline. | | `U401` | error | Inside a fragment, the statements of an operand are indented below its `else` or `and`. A statement at the level of the marker after it would silently join the operand above. UML 2.5.1: 17.6.3.1 Operand of a combined fragment. | | `U403` | error | A reply `-->` answers an open synchronous call in the opposite direction; the model pairs them innermost first. UML 2.5.1: 17.4.3.1 Reply to a call, 17.4.3.1 Synchronous call. | | `U404` | error | Before its creation and after its destruction a lifeline does not exist; each happens at most once. UML 2.5.1: 17.4.3.1 Message that creates a lifeline, 17.4.3.4 End of a lifeline (destruction). | | `U405` | error | `deactivate` ends a bar that `activate` started on the same lifeline. UML 2.5.1: 17.2.3.4 Execution on a lifeline (activation bar). | | `U408` | error | A lost message has no receiver, a found one no sender: `lost` only on the right, `found` only on the left, both only on a call or asynchronous message, and neither as a lifeline id. UML 2.5.1: 17.4.3.1 Lost message, without receiver, 17.4.3.1 Found message, without sender. | | `U450` | error | A gate links a message with the frame of the interaction: `gate` is no lifeline id and stands at one end of a message only, never with `lost`, `found` or a creation. UML 2.5.1: 17.4.3.5 Gate on the frame of the interaction. | | `U451` | error | `ignore` and `consider` name the messages they ignore or consider, written as their guard. UML 2.5.1: 17.6.3.15 Ignored messages (`ignore`), 17.6.3.15 Considered messages (`consider`). | | `U452` | error | A note and a reference need `over=`, a state invariant needs `on=`: they stand on lifelines. UML 2.5.1: 17.2.3.5 State invariant, 17.7.3.1 Use of another interaction (`ref`). | | `U453` | error | A coregion is the short form of a `par` whose operands hold one event each on the same lifeline; every message in it is sent or received by that lifeline. The tables allow only `msg`, `activate`, `deactivate` and `note` in it. UML 2.5.1: 17.6.4.10 Coregion, unordered events on one lifeline. | | `U454` | error | A gate links a message with the edge of a reference (actual gate) or of a combined fragment. At a reference the message comes from a lifeline outside it and follows it, with only events beside it in between; at a fragment it stands inside. The frame name is its own. UML 2.5.1: 17.4.3.5 Gate on an interaction use, 17.4.3.5 Gate on a combined fragment. | | `U900` | warning | UML allows `alt` and `par` with one operand, but `opt` or no fragment says it more clearly. UML 2.5.1: 17.6.3.7 Alternatives (`alt`), 17.6.3.10 Parallel (`par`). | | `U901` | warning | UML allows leaving out the reply; it is still named. Exempt are self calls and calls made while the caller handles a call it answers later: that reply implies the inner call returned. Lost and found messages are U907. UML 2.5.1: 17.4.3.1 Synchronous call, 17.4.3.1 Reply to a call. | | `U902` | warning | A lifeline no message, note or reference touches says nothing; remove it or add what it does. UML 2.5.1: 17.3.3.1 Lifeline. | | `U903` | warning | An operand without events draws an empty band; fill it or remove it. UML 2.5.1: 17.6.3.1 Operand of a combined fragment. | | `U904` | warning | In `alt` every operand but the last needs a guard; the last one may stand for `[else]`. UML 2.5.1: 17.6.3.7 Alternatives (`alt`), 17.6.3.2 Guard of an operand. | | `U905` | warning | `activate` without `deactivate`: the bar reaches to the end of the diagram. UML 2.5.1: 17.2.3.4 Execution on a lifeline (activation bar). | | `U906` | warning | A duration runs from the earlier to the later message; swapped, Diagrist still draws it. UML 2.5.1: 8.5.3.2 Duration constraint. | | `U907` | warning | No reply can follow a lost or found message, so as a synchronous call it would wait forever; use `~>`. UML 2.5.1: 17.4.3.1 Lost message, without receiver, 17.4.3.1 Found message, without sender, 17.4.3.1 Synchronous call. | | `U908` | warning | `duration=` slopes the arrow. A self call is a loop and a creation ends at the head at its height: there the arrow stays level and the duration is missing from the picture. UML 2.5.1: 8.5.3.2 Duration constraint. | | `U909` | warning | A coregion with fewer than two messages leaves no order open and says nothing. UML 2.5.1: 17.6.4.10 Coregion, unordered events on one lifeline. | | `U950` | warning | `id=` on a reference or fragment only serves gates; without a message at its edge it has no effect. UML 2.5.1: 17.4.3.5 Gate on an interaction use, 17.4.3.5 Gate on a combined fragment. | | `U951` | warning | A gate is a point on the frame with one message per side; two messages through the same named gate in the same direction leave open which one is meant. UML 2.5.1: 17.4.3.5 Gate on the frame of the interaction, 17.4.3.5 Gate on an interaction use, 17.4.3.5 Gate on a combined fragment. | # state > A UML state machine diagram (UML 2.5.1, chapter 14): states and pseudostates joined by transitions, composite states with substates or orthogonal regions, entry and exit points on their border. {protocol} in the title makes it a protocol state machine. Diagrist lays it out by itself: layers by the longest path from the initial pseudostate, final states last, back and skip transitions on rails beside the states, loops at a free corner. A UML state machine diagram (UML 2.5.1, chapter 14): states and pseudostates joined by transitions, composite states with substates or orthogonal regions, entry and exit points on their border. `{protocol}` in the title makes it a protocol state machine. Diagrist lays it out by itself: layers by the longest path from the initial pseudostate, final states last, back and skip transitions on rails beside the states, loops at a free corner. This page lists everything a `state` diagram may contain. The same grammar is available as data with `dgr grammar state --json`, and [the overview](/docs/language/) explains how lines, texts and attributes are written and lists the codes every kind shares. ## The first line [Section titled “The first line”](#the-first-line) ```text diagram state "Title" [subtitle=<text>] [look=<plain|cards>] [direction=<down|right>] [locale=<en|de>] ``` Every state diagram starts with this line. | Part | Kind | Value | Meaning | | ------------ | --------- | ---------------------------------------------- | --------------------------------------------------------------------------------------------------------------- | | `subtitle=` | attribute | a text in double quotes like `"Order service"` | Second line below the title. | | `look=` | attribute | one of `plain`, `cards` | `plain` (default) draws the UML notation, `cards` the same layout with states as cards with a toned name field. | | `direction=` | attribute | one of `down`, `right` | `down` (default) lays the flow out from top to bottom, `right` from left to right. | | `locale=` | attribute | one of `en`, `de` | Language of the texts Diagrist adds to the picture and of the description: `en` (default) or `de`. | Example: ```dgr diagram state "Title" ``` ## Statements [Section titled “Statements”](#statements) Each statement is one line that starts with its keyword. Statements inside blocks are indented below them. Like every kind, `state` also has `use`, `variant`, `set` and `drop`, described in [the overview](/docs/language/#statements-of-every-kind). | Statement | Where | What it does | | --------------------------- | --------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- | | [`state`](#state) | top level | A state: a rounded box with the name, below it a compartment with `entry`, `do` and `exit`, deferred events and internal transitions. | | [`initial`](#initial) | top level | The initial pseudostate: a filled circle. | | [`final`](#final) | top level | A final state: a circle with a dot. | | [`choice`](#choice) | top level | A choice pseudostate: a diamond. | | [`junction`](#junction) | top level | A junction pseudostate: a small filled circle that joins or splits transitions without a decision of its own. | | [`history`](#history) | top level | A history pseudostate inside a composite state: a circle with `H`, with `deep` `H*`. | | [`fork`](#fork) | top level | A fork pseudostate: a bar across the flow, from one incoming to several outgoing transitions into states, often into the regions of a state. | | [`join`](#join) | top level | A join pseudostate: a bar across the flow that waits for all its incoming transitions from states. | | [`terminate`](#terminate) | top level | A terminate pseudostate: a cross. | | [`entrypoint`](#entrypoint) | top level | An entry point: a small circle on the border of its state. | | [`exitpoint`](#exitpoint) | top level | An exit point: a small circle with a cross on the border of its state. | | [`region`](#region) | top level | An orthogonal region of a state: the regions of a state are active at the same time and stand side by side, separated by dashed lines, the name at the top left. | | [`go`](#go) | top level | A transition from `from` to `to`, labelled `trigger [guard] / effect`; without all three it is a completion transition. | | [`internal`](#internal) | top level | An internal transition: a line `trigger [guard] / effect` in the compartment of its state. | | [`note`](#note) | top level | A comment on a vertex: a dashed box above it with a tip down to it, below it when lines run above. | | [`adr`](#adr) | top level | An architecture decision in the bar below the picture: question, the chosen option after `=`, and the consequence after `=>`. | ### `state` [Section titled “state”](#state) ```text state <id> <label> [in <ref>] [entry=<text>] [do=<text>] [exit=<text>] [defer=<text>] [submachine=<text>] [file=<text>] [tone=<choice>] [mark=<ref>] [emph] ``` A state: a rounded box with the name, below it a compartment with `entry`, `do` and `exit`, deferred events and internal transitions. A state with vertices `in` it is a composite state, drawn as a frame around them; with `submachine=` it calls another state machine. Diagrist lays states out in layers from the initial pseudostate to the final state. UML 2.5.1: 14.2.3.4 Simple state. Written at the top level. | Part | Kind | Value | Meaning | | ------------- | --------- | ------------------------------------------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `<id>` | argument | an identifier like `api` (letters, digits, `_` and `-`, starting with a letter) | Id that `go`, `in`, `internal` and `note` use for this state. | | `<label>` | argument | a text in double quotes like `"Order service"` | Name of the state. | | `in <ref>` | clause | the id of a `state` or `region` declared in this diagram | The composite state or the region the vertex lies in; without it, the vertex stands at the top level. UML 2.5.1: 14.2.3.4 Composite state with substates. | | `entry=` | attribute | a text in double quotes like `"Order service"` | Behaviour on entering, shown as `entry / ...`. UML 2.5.1: 14.2.4 Entry, do and exit behavior in the compartment of a state. | | `do=` | attribute | a text in double quotes like `"Order service"` | Behaviour while in the state, `do / ...`. UML 2.5.1: 14.2.4 Entry, do and exit behavior in the compartment of a state. | | `exit=` | attribute | a text in double quotes like `"Order service"` | Behaviour on leaving, `exit / ...`. UML 2.5.1: 14.2.4 Entry, do and exit behavior in the compartment of a state. | | `defer=` | attribute | a text in double quotes like `"Order service"` | Events the state defers, separated by commas; each shows as `event / defer`. UML 2.5.1: 14.2.4 Deferred event in the compartment of a state. | | `submachine=` | attribute | a text in double quotes like `"Order service"` | Name of the state machine the state calls: the box reads `Name : Machine` and carries the submachine symbol. Entry and exit points `in` it are its connection point references. UML 2.5.1: 14.2.3.4 Submachine state calling another state machine. | | `file=` | attribute | a text in double quotes like `"Order service"` | File of the called state machine, relative to this one; named in the description, not checked yet. | | `tone=` | attribute | one of `blue`, `indigo`, `purple`, `maroon`, `green`, `teal`, `slate`, `red`, `orange`, `peach`, `sky` | Colour of the name field in `look=cards`; without it slate. | | `mark=` | attribute | the id of an `adr` declared in this diagram | Id of a decision of the decision bar, such as `E1`; the mark is drawn beside it. | | `emph` | flag | | Highlights the state in the accent colour. | Examples: ```dgr state open "Open" entry="set deadline" state check "Check" submachine="Credit check" ``` ### `initial` [Section titled “initial”](#initial) ```text initial <id> [label] [in <ref>] ``` The initial pseudostate: a filled circle. Each region, the top level included, has at most one; its transition has neither trigger nor guard. UML 2.5.1: 14.2.3 Initial pseudostate. Written at the top level. | Part | Kind | Value | Meaning | | ---------- | ----------------- | ------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------- | | `<id>` | argument | an identifier like `api` (letters, digits, `_` and `-`, starting with a letter) | Id that `go` uses for this vertex. | | `[label]` | optional argument | a text in double quotes like `"Order service"` | Name shown small beside the symbol. | | `in <ref>` | clause | the id of a `state` or `region` declared in this diagram | The composite state or the region the vertex lies in; without it, the vertex stands at the top level. UML 2.5.1: 14.2.3.4 Composite state with substates. | Example: ```dgr initial start ``` ### `final` [Section titled “final”](#final) ```text final <id> [label] [in <ref>] ``` A final state: a circle with a dot. No transition leaves it. Diagrist puts final states into the last layer. UML 2.5.1: 14.2.3 Final state. Written at the top level. | Part | Kind | Value | Meaning | | ---------- | ----------------- | ------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------- | | `<id>` | argument | an identifier like `api` (letters, digits, `_` and `-`, starting with a letter) | Id that `go` uses for this vertex. | | `[label]` | optional argument | a text in double quotes like `"Order service"` | Name shown small beside the symbol. | | `in <ref>` | clause | the id of a `state` or `region` declared in this diagram | The composite state or the region the vertex lies in; without it, the vertex stands at the top level. UML 2.5.1: 14.2.3.4 Composite state with substates. | Example: ```dgr final end ``` ### `choice` [Section titled “choice”](#choice) ```text choice <id> [label] [in <ref>] ``` A choice pseudostate: a diamond. Its outgoing transitions carry guards, one of them `when=else`. UML 2.5.1: 14.2.3 Choice pseudostate. Written at the top level. | Part | Kind | Value | Meaning | | ---------- | ----------------- | ------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------- | | `<id>` | argument | an identifier like `api` (letters, digits, `_` and `-`, starting with a letter) | Id that `go` uses for this vertex. | | `[label]` | optional argument | a text in double quotes like `"Order service"` | Name shown small beside the symbol. | | `in <ref>` | clause | the id of a `state` or `region` declared in this diagram | The composite state or the region the vertex lies in; without it, the vertex stands at the top level. UML 2.5.1: 14.2.3.4 Composite state with substates. | Example: ```dgr choice paid ``` ### `junction` [Section titled “junction”](#junction) ```text junction <id> [label] [in <ref>] ``` A junction pseudostate: a small filled circle that joins or splits transitions without a decision of its own. UML 2.5.1: 14.2.3 Junction pseudostate. Written at the top level. | Part | Kind | Value | Meaning | | ---------- | ----------------- | ------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------- | | `<id>` | argument | an identifier like `api` (letters, digits, `_` and `-`, starting with a letter) | Id that `go` uses for this vertex. | | `[label]` | optional argument | a text in double quotes like `"Order service"` | Name shown small beside the symbol. | | `in <ref>` | clause | the id of a `state` or `region` declared in this diagram | The composite state or the region the vertex lies in; without it, the vertex stands at the top level. UML 2.5.1: 14.2.3.4 Composite state with substates. | Example: ```dgr junction merge ``` ### `history` [Section titled “history”](#history) ```text history <id> [label] [in <ref>] [deep] ``` A history pseudostate inside a composite state: a circle with `H`, with `deep` `H*`. Entering it resumes the substate last active. UML 2.5.1: 14.2.3 Shallow and deep history pseudostates. Written at the top level. | Part | Kind | Value | Meaning | | ---------- | ----------------- | ------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------- | | `<id>` | argument | an identifier like `api` (letters, digits, `_` and `-`, starting with a letter) | Id that `go` uses for this pseudostate. | | `[label]` | optional argument | a text in double quotes like `"Order service"` | Name shown small beside the symbol. | | `in <ref>` | clause | the id of a `state` or `region` declared in this diagram | The composite state or the region the vertex lies in; without it, the vertex stands at the top level. UML 2.5.1: 14.2.3.4 Composite state with substates. | | `deep` | flag | | Deep history: resumes the innermost substates too, drawn `H*`. | Example: ```dgr history resume in active deep ``` ### `fork` [Section titled “fork”](#fork) ```text fork <id> [label] [in <ref>] ``` A fork pseudostate: a bar across the flow, from one incoming to several outgoing transitions into states, often into the regions of a state. UML 2.5.1: 14.2.3 Fork pseudostate. Written at the top level. | Part | Kind | Value | Meaning | | ---------- | ----------------- | ------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------- | | `<id>` | argument | an identifier like `api` (letters, digits, `_` and `-`, starting with a letter) | Id that `go` uses for this vertex. | | `[label]` | optional argument | a text in double quotes like `"Order service"` | Name shown small beside the symbol. | | `in <ref>` | clause | the id of a `state` or `region` declared in this diagram | The composite state or the region the vertex lies in; without it, the vertex stands at the top level. UML 2.5.1: 14.2.3.4 Composite state with substates. | Example: ```dgr fork split ``` ### `join` [Section titled “join”](#join) ```text join <id> [label] [in <ref>] ``` A join pseudostate: a bar across the flow that waits for all its incoming transitions from states. UML 2.5.1: 14.2.3 Join pseudostate. Written at the top level. | Part | Kind | Value | Meaning | | ---------- | ----------------- | ------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------- | | `<id>` | argument | an identifier like `api` (letters, digits, `_` and `-`, starting with a letter) | Id that `go` uses for this vertex. | | `[label]` | optional argument | a text in double quotes like `"Order service"` | Name shown small beside the symbol. | | `in <ref>` | clause | the id of a `state` or `region` declared in this diagram | The composite state or the region the vertex lies in; without it, the vertex stands at the top level. UML 2.5.1: 14.2.3.4 Composite state with substates. | Example: ```dgr join done ``` ### `terminate` [Section titled “terminate”](#terminate) ```text terminate <id> [label] [in <ref>] ``` A terminate pseudostate: a cross. The state machine ends at once. UML 2.5.1: 14.2.3 Terminate pseudostate. Written at the top level. | Part | Kind | Value | Meaning | | ---------- | ----------------- | ------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------- | | `<id>` | argument | an identifier like `api` (letters, digits, `_` and `-`, starting with a letter) | Id that `go` uses for this vertex. | | `[label]` | optional argument | a text in double quotes like `"Order service"` | Name shown small beside the symbol. | | `in <ref>` | clause | the id of a `state` or `region` declared in this diagram | The composite state or the region the vertex lies in; without it, the vertex stands at the top level. UML 2.5.1: 14.2.3.4 Composite state with substates. | Example: ```dgr terminate abort ``` ### `entrypoint` [Section titled “entrypoint”](#entrypoint) ```text entrypoint <id> [label] [in <ref>] ``` An entry point: a small circle on the border of its state. A transition from outside ends at it and continues inside; on a submachine state the way inside lies in the called machine. UML 2.5.1: 14.2.3 Entry point on the border of a state. Written at the top level. | Part | Kind | Value | Meaning | | ---------- | ----------------- | ------------------------------------------------------------------------------- | --------------------------------------------------------------------------- | | `<id>` | argument | an identifier like `api` (letters, digits, `_` and `-`, starting with a letter) | Id that `go` uses for this point. | | `[label]` | optional argument | a text in double quotes like `"Order service"` | Name shown small outside the circle. | | `in <ref>` | clause | the id of a `state` declared in this diagram | The composite or submachine state on whose border the point sits. Required. | Example: ```dgr entrypoint fresh "New customer" in check ``` ### `exitpoint` [Section titled “exitpoint”](#exitpoint) ```text exitpoint <id> [label] [in <ref>] ``` An exit point: a small circle with a cross on the border of its state. A transition from inside ends at it and continues outside. UML 2.5.1: 14.2.3 Exit point on the border of a state. Written at the top level. | Part | Kind | Value | Meaning | | ---------- | ----------------- | ------------------------------------------------------------------------------- | --------------------------------------------------------------------------- | | `<id>` | argument | an identifier like `api` (letters, digits, `_` and `-`, starting with a letter) | Id that `go` uses for this point. | | `[label]` | optional argument | a text in double quotes like `"Order service"` | Name shown small outside the circle. | | `in <ref>` | clause | the id of a `state` declared in this diagram | The composite or submachine state on whose border the point sits. Required. | Example: ```dgr exitpoint rejected "Rejected" in check ``` ### `region` [Section titled “region”](#region) ```text region <id> [label] [in <ref>] ``` An orthogonal region of a state: the regions of a state are active at the same time and stand side by side, separated by dashed lines, the name at the top left. Vertices come in with `in`; each region has its own initial pseudostate unless a fork enters it. UML 2.5.1: 14.2.3.2 Orthogonal regions of a state, separated by dashed lines. Written at the top level. | Part | Kind | Value | Meaning | | ---------- | ----------------- | ------------------------------------------------------------------------------- | ------------------------------------------ | | `<id>` | argument | an identifier like `api` (letters, digits, `_` and `-`, starting with a letter) | Id that `in` uses for this region. | | `[label]` | optional argument | a text in double quotes like `"Order service"` | Name of the region, shown at its top left. | | `in <ref>` | clause | the id of a `state` declared in this diagram | The state the region belongs to. Required. | Example: ```dgr region payment "Payment" in processing ``` ### `go` [Section titled “go”](#go) ```text go <from> <arrow> <to> [on=<text>] [when=<text>] [do=<text>] [post=<text>] [emph] ``` A transition from `from` to `to`, labelled `trigger [guard] / effect`; without all three it is a completion transition. `when=else` is the else branch of a choice. A transition of a state to itself is a loop at its freest corner. In a protocol state machine (`{protocol}` in the title) it reads `[precondition] operation / [postcondition]`. UML 2.5.1: 14.2.3.8 Transition with trigger, guard and effect, 14.2.3.8 Completion transition without trigger. Written at the top level. | Part | Kind | Value | Meaning | | --------- | --------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `<from>` | argument | the id of a `state`, `initial`, `final`, `choice`, `junction`, `history`, `fork`, `join`, `terminate`, `entrypoint` or `exitpoint` declared in this diagram | The vertex the transition leaves. | | `<arrow>` | argument | one of the arrows `->` transition, with an open arrowhead at `to` | The arrow of a transition. | | `<to>` | argument | the id of a `state`, `initial`, `final`, `choice`, `junction`, `history`, `fork`, `join`, `terminate`, `entrypoint` or `exitpoint` declared in this diagram | The vertex the transition enters. | | `on=` | attribute | a text in double quotes like `"Order service"` | Trigger: the events that fire the transition, separated by commas. A time event is written `after(30 days)`, a change event `when(stock empty)`. In a protocol state machine the operation called. UML 2.5.1: 14.2.3.8 Transition with trigger, guard and effect. | | `when=` | attribute | a text in double quotes like `"Order service"` | Guard, written without brackets; `else` is the predefined else branch. UML 2.5.1: 14.2.3.8 Predefined guard else. | | `do=` | attribute | a text in double quotes like `"Order service"` | Effect: the behaviour the transition runs, shown after `/`. | | `post=` | attribute | a text in double quotes like `"Order service"` | Postcondition of a protocol transition, written without brackets. UML 2.5.1: 14.4.3 Protocol transition with precondition and postcondition. | | `emph` | flag | | Highlights the line in the accent colour. | The values of `arrow` and what they mean: | Value | Meaning | | ----- | ------------------------------------------ | | `->` | transition, with an open arrowhead at `to` | Examples: ```dgr go open -> paid on="pay" when="amount covered" do="send receipt" go choice -> open when=else go open -> cancelled on="after(14 days)" ``` ### `internal` [Section titled “internal”](#internal) ```text internal <state> [on=<text>] [when=<text>] [do=<text>] ``` An internal transition: a line `trigger [guard] / effect` in the compartment of its state. The state is neither left nor entered again, so no entry or exit behaviour runs. UML 2.5.1: 14.2.4 Internal transition in the compartment of a state. Written at the top level. | Part | Kind | Value | Meaning | | --------- | --------- | ---------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `<state>` | argument | the id of a `state` declared in this diagram | The state whose compartment shows the transition. | | `on=` | attribute | a text in double quotes like `"Order service"` | Trigger: the events that fire the transition, separated by commas. A time event is written `after(30 days)`, a change event `when(stock empty)`. In a protocol state machine the operation called. UML 2.5.1: 14.2.3.8 Transition with trigger, guard and effect. | | `when=` | attribute | a text in double quotes like `"Order service"` | Guard, written without brackets. | | `do=` | attribute | a text in double quotes like `"Order service"` | Effect, shown after `/`. | Example: ```dgr internal open on="change item" do="recalculate" ``` ### `note` [Section titled “note”](#note) ```text note <text> [on <ref>] ``` A comment on a vertex: a dashed box above it with a tip down to it, below it when lines run above. UML 2.5.1: 7.2.3.2 Comment (note). Written at the top level. | Part | Kind | Value | Meaning | | ---------- | -------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------- | | `<text>` | argument | a text in double quotes like `"Order service"` | What the note says, in one line. | | `on <ref>` | clause | the id of a `state`, `initial`, `final`, `choice`, `junction`, `history`, `fork`, `join`, `terminate`, `entrypoint` or `exitpoint` declared in this diagram | The vertex the note belongs to. Required. | Example: ```dgr note "Only for new customers" on check ``` ### `adr` [Section titled “adr”](#adr) ```text adr <id> <question> <equals> <choice> [then] [consequence] [open=<text>] ``` An architecture decision in the bar below the picture: question, the chosen option after `=`, and the consequence after `=>`. `mark=` with its id puts the mark into the picture. Written at the top level. | Part | Kind | Value | Meaning | | --------------- | ----------------- | ------------------------------------------------------------------------------- | ------------------------------------------------------------- | | `<id>` | argument | an identifier like `api` (letters, digits, `_` and `-`, starting with a letter) | Id of the decision, such as `E1`; `mark=E1` refers to it. | | `<question>` | argument | a text in double quotes like `"Order service"` | The question that was decided. | | `<equals>` | argument | one of the arrows `=` | Separates the question from the choice. | | `<choice>` | argument | a text in double quotes like `"Order service"` | The chosen option. | | `[then]` | optional argument | one of the arrows `=>` | Introduces the consequence. | | `[consequence]` | optional argument | a text in double quotes like `"Order service"` | What follows from the choice. | | `open=` | attribute | a text in double quotes like `"Order service"` | Who still decides an open question; the card is drawn dashed. | Example: ```dgr adr E1 "How do the services coordinate?" = "Events over Kafka" => "No central coordinator" ``` ## Diagnostic codes [Section titled “Diagnostic codes”](#diagnostic-codes) Besides the codes of the language and the kernel, listed in [the overview](/docs/language/#diagnostic-codes), the rules of `state` report these. An error stops the build; a warning is printed and the picture is still drawn. | Code | Severity | What it checks | | ------ | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | `U440` | error | No transition leaves a final state or a terminate pseudostate, and none enters an initial pseudostate: it is an entry only. UML 2.5.1: 14.2.3 Final state, 14.2.3 Initial pseudostate, 14.2.3 Terminate pseudostate. | | `U441` | error | Each pseudostate has its number of ways in and out: initial and history at most one out, a fork one in and at least two out, a join at least two in and one out, choice and junction at least one each. UML 2.5.1: 14.2.3 Initial pseudostate, 14.2.3 Shallow and deep history pseudostates, 14.2.3 Fork pseudostate, 14.2.3 Join pseudostate, 14.2.3 Choice pseudostate, 14.2.3 Junction pseudostate. | | `U442` | error | The transition from an initial pseudostate and the branches of fork and join have neither trigger nor guard; transitions leaving other pseudostates have no trigger. UML 2.5.1: 14.2.3.8 Transition with trigger, guard and effect. | | `U443` | error | A region, the top level included, has at most one initial pseudostate, one shallow and one deep history. UML 2.5.1: 14.2.3 Initial pseudostate, 14.2.3 Shallow and deep history pseudostates. | | `U444` | error | A history pseudostate remembers the active substate of a composite state, so it lies in one. UML 2.5.1: 14.2.3 Shallow and deep history pseudostates. | | `U445` | error | Nesting with `in` forms no cycle, and an internal transition names its trigger: it fires on an event without leaving the state. UML 2.5.1: 14.2.3.4 Composite state with substates, 14.2.4 Internal transition in the compartment of a state. | | `U446` | error | The branches of a fork end at states, the branches of a join start at states. UML 2.5.1: 14.2.3 Fork pseudostate, 14.2.3 Join pseudostate. | | `U447` | error | The else branch applies when no other guard holds; two of them at one vertex contradict each other. UML 2.5.1: 14.2.3.8 Predefined guard else. | | `U448` | error | A region belongs to a state; a state with regions keeps its substates in them; a transition never crosses the border between two regions of one state, they run at the same time; and the branches of a fork or join lie in different regions. UML 2.5.1: 14.2.3.2 Orthogonal regions of a state, separated by dashed lines, 14.2.3 Fork pseudostate, 14.2.3 Join pseudostate. | | `U449` | error | Entry and exit points sit on the border of a state. An entry point is reached from outside and leads inside, an exit point the other way round. UML 2.5.1: 14.2.3 Entry point on the border of a state, 14.2.3 Exit point on the border of a state. | | `U460` | error | Entry and exit points belong to a composite state, or as connection point references to a submachine state; a simple state has none. UML 2.5.1: 14.2.3 Entry point on the border of a state, 14.2.3 Exit point on the border of a state, 14.2.3.4 Submachine state calling another state machine. | | `U461` | error | A submachine state calls another state machine and has no substates or regions of its own. At its points, transitions from outside end at the entry point and start at the exit point; the way inside lies in the called machine. UML 2.5.1: 14.2.3.4 Submachine state calling another state machine. | | `U462` | error | A time event `after(duration)` and a change event `when(condition)` are triggers: they stand in `on=` with parentheses. In the guard `when=` they would be a condition, not an event. UML 2.5.1: 13.3.3 Time event as a trigger, after(…), 13.3.3 Change event as a trigger, when(…). | | `U463` | error | A protocol state machine (`{protocol}` in the title) says which calls are allowed in which order. Its states have no entry, do or exit behaviour, its transitions no effect, and it has no history. UML 2.5.1: 14.4.3 Protocol state machine, 14.4.3 Protocol transition with precondition and postcondition. | | `U464` | error | Only the transition of a protocol state machine has a postcondition `post=`. UML 2.5.1: 14.4.3 Protocol transition with precondition and postcondition. | | `U465` | error | A note in a state machine diagram is a comment on one vertex: it names it with `on`. UML 2.5.1: 7.2.3.2 Comment (note). | | `U940` | warning | A state machine starts at an initial pseudostate at the top level, and an initial pseudostate leads somewhere. A machine drawn as one state with its own entry and exit points starts at the caller instead. UML 2.5.1: 14.2.3 Initial pseudostate. | | `U941` | warning | Every state can be reached from the initial pseudostate: entering a composite state reaches its inside, and being in a substate means being in its parents too. UML 2.5.1: 14.2.3.4 Simple state. | | `U942` | warning | A simple state that no transition leaves, neither itself nor a parent nor an exit point of it, is a dead end; usually a transition to a final state is missing. UML 2.5.1: 14.2.3.4 Simple state, 14.2.3 Final state. | | `U943` | warning | Every way out of a choice has a guard and one of them is `else`, so the machine never gets stuck there; `else` belongs to a choice or junction. UML 2.5.1: 14.2.3 Choice pseudostate, 14.2.3.8 Predefined guard else. | | `U944` | warning | Two ways out of a state on the same trigger need guards that tell them apart; otherwise the machine is not deterministic. UML 2.5.1: 14.2.3.8 Transition with trigger, guard and effect. | | `U945` | warning | A transition of a state to itself leaves and enters it again and runs its exit and entry behaviour; an internal transition does not. UML 2.5.1: 14.2.4 Internal transition in the compartment of a state, 14.2.4 Entry, do and exit behavior in the compartment of a state. | | `U946` | warning | A transition that ends at the frame of a composite state enters it at its initial pseudostate; without one it is not clear where it continues. States with regions are checked per region. UML 2.5.1: 14.2.3.4 Composite state with substates, 14.2.3 Initial pseudostate. | | `U947` | warning | What a fork splits, a join usually brings together again. UML 2.5.1: 14.2.3 Fork pseudostate, 14.2.3 Join pseudostate. | | `U948` | warning | Each region of a state starts at its own initial pseudostate, unless every way into the state enters the region explicitly, as the branches of a fork do. UML 2.5.1: 14.2.3.2 Orthogonal regions of a state, separated by dashed lines, 14.2.3 Initial pseudostate. | | `U949` | warning | An entry or exit point has a way in and a way out. On a submachine state only the outside counts, and on the frame of a machine drawn with its own points the outside lies with the caller. UML 2.5.1: 14.2.3 Entry point on the border of a state, 14.2.3 Exit point on the border of a state. | | `U960` | warning | A state that defers an event and fires a transition on it in the same state: the transition wins and the deferral says nothing. UML 2.5.1: 14.2.4 Deferred event in the compartment of a state. | | `U961` | warning | A deferred event waits for a later state that fires a transition on it; without one it waits forever. UML 2.5.1: 14.2.4 Deferred event in the compartment of a state. | # usecase > A UML use case diagram (UML 2.5.1, chapter 18): actors outside, use cases inside their subject, relations as straight lines. Diagrist lays it out by itself: use cases in columns by include and extend, actors left or right at the height of their use cases, an order with as few crossings as it finds. A UML use case diagram (UML 2.5.1, chapter 18): actors outside, use cases inside their subject, relations as straight lines. Diagrist lays it out by itself: use cases in columns by include and extend, actors left or right at the height of their use cases, an order with as few crossings as it finds. This page lists everything a `usecase` diagram may contain. The same grammar is available as data with `dgr grammar usecase --json`, and [the overview](/docs/language/) explains how lines, texts and attributes are written and lists the codes every kind shares. ## The first line [Section titled “The first line”](#the-first-line) ```text diagram usecase "Title" [subtitle=<text>] [look=<plain|cards>] [direction=<down|right>] [locale=<en|de>] ``` Every usecase diagram starts with this line. | Part | Kind | Value | Meaning | | ------------ | --------- | ---------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `subtitle=` | attribute | a text in double quotes like `"Order service"` | Second line below the title. | | `look=` | attribute | one of `plain`, `cards` | `plain` (default) draws the UML notation, `cards` the same layout with toned outlines and areas. | | `direction=` | attribute | one of `down`, `right` | Several subjects: `right` side by side, `down` one below the other. Without it they stand below each other, unless an actor works in more than one or the picture would grow too tall; then side by side, more than three in rows of a grid, if that crosses no more lines. With fewer than two subjects it has no effect. | | `locale=` | attribute | one of `en`, `de` | Language of the texts Diagrist adds to the picture and of the description: `en` (default) or `de`. | Example: ```dgr diagram usecase "Title" ``` ## Statements [Section titled “Statements”](#statements) Each statement is one line that starts with its keyword. Statements inside blocks are indented below them. Like every kind, `usecase` also has `use`, `variant`, `set` and `drop`, described in [the overview](/docs/language/#statements-of-every-kind). | Statement | Where | What it does | | --------------------- | --------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------- | | [`actor`](#actor) | top level | An actor: a role outside every subject, drawn as a stick figure with the role below it or, with `kind=system`, as a box with `«actor»` for another system. | | [`subject`](#subject) | top level | A subject: the system the use cases belong to, drawn as a rectangle with its name at the top left around the use cases `in` it. | | [`usecase`](#usecase) | top level | A use case: an ellipse as large as its name inside the subject `in`; names over 18 characters wrap. | | [`rel`](#rel) | top level | A relation, read from `from` to `to`. | | [`note`](#note) | top level | A comment on an actor, a use case or a subject: a box with a folded corner at a free spot nearby, joined to it by a dashed line. | | [`adr`](#adr) | top level | An architecture decision in the bar below the picture: question, the chosen option after `=`, and the consequence after `=>`. | ### `actor` [Section titled “actor”](#actor) ```text actor <id> <label> [kind=<person|system>] [side=<left|right>] [tone=<choice>] [mark=<ref>] [emph] ``` An actor: a role outside every subject, drawn as a stick figure with the role below it or, with `kind=system`, as a box with `«actor»` for another system. It has no `in`: actors stand outside the subject. Diagrist puts it left or right of its use cases. UML 2.5.1: 18.1.3.1 Actor. Written at the top level. | Part | Kind | Value | Meaning | | --------- | --------- | ------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------- | | `<id>` | argument | an identifier like `api` (letters, digits, `_` and `-`, starting with a letter) | Id that `rel` and `note` use for this actor. | | `<label>` | argument | a text in double quotes like `"Order service"` | Name of the role. | | `kind=` | attribute | one of `person`, `system` | `person` (default) draws a stick figure, `system` a box with `«actor»`. UML 2.5.1: `system` 18.1.4 Actor as a rectangle with the keyword «actor». | | `side=` | attribute | one of `left`, `right` | Side of the subject the actor stands on; without it Diagrist chooses. | | `tone=` | attribute | one of `blue`, `indigo`, `purple`, `maroon`, `green`, `teal`, `slate`, `red`, `orange`, `peach`, `sky` | Colour of the figure or box in `look=cards`; without it slate. | | `mark=` | attribute | the id of an `adr` declared in this diagram | Id of a decision of the decision bar, such as `E1`; the mark is drawn beside it. | | `emph` | flag | | Highlights it in the accent colour. | Examples: ```dgr actor customer "Customer" actor psp "Payment provider" kind=system side=right ``` ### `subject` [Section titled “subject”](#subject) ```text subject <id> <label> [tone=<choice>] ``` A subject: the system the use cases belong to, drawn as a rectangle with its name at the top left around the use cases `in` it. UML 2.5.1: 18.1.3.1 Subject a use case applies to. Written at the top level. | Part | Kind | Value | Meaning | | --------- | --------- | ------------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------- | | `<id>` | argument | an identifier like `api` (letters, digits, `_` and `-`, starting with a letter) | Id that `usecase ... in` and `note ... on` use for this subject. | | `<label>` | argument | a text in double quotes like `"Order service"` | Name of the system. | | `tone=` | attribute | one of `blue`, `indigo`, `purple`, `maroon`, `green`, `teal`, `slate`, `red`, `orange`, `peach`, `sky` | Colour of its area in `look=cards`; without it slate. | Example: ```dgr subject shop "Online shop" ``` ### `usecase` [Section titled “usecase”](#usecase) ```text usecase <id> <label> [in <ref>] [points=<text>] [form=<ellipse|classifier>] [stereotype=<text>] [tone=<choice>] [mark=<ref>] [emph] ``` A use case: an ellipse as large as its name inside the subject `in`; names over 18 characters wrap. `points=` lists extension points in a compartment, which `extend` names with `at=`. `form=classifier` draws a rectangle with a small ellipse instead. Diagrist places use cases in columns: included and extending cases right of their base, a special case below its general one. UML 2.5.1: 18.1.3.1 Use case. Written at the top level. | Part | Kind | Value | Meaning | | ------------- | --------- | ------------------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `<id>` | argument | an identifier like `api` (letters, digits, `_` and `-`, starting with a letter) | Id that `rel` and `note` use for this use case. | | `<label>` | argument | a text in double quotes like `"Order service"` | Name of the goal, as a verb phrase. | | `in <ref>` | clause | the id of a `subject` declared in this diagram | The subject the use case belongs to; without it, the use case stands outside every subject. UML 2.5.1: 18.1.3.1 Subject a use case applies to. | | `points=` | attribute | a text in double quotes like `"Order service"` | Extension points separated by commas, like `"before checkout, after payment"`. UML 2.5.1: 18.1.3.2 Extension point, 18.1.4 Compartment listing the extension points. | | `form=` | attribute | one of `ellipse`, `classifier` | `ellipse` (default), or `classifier`: a rectangle with an ellipse. UML 2.5.1: `classifier` 18.1.4 Use case as a rectangle with an ellipse icon. | | `stereotype=` | attribute | a text in double quotes like `"Order service"` | Stereotype above the name, written without guillemets: `batch` shows `«batch»`. UML 2.5.1: 18.1.4 Keyword or stereotype above a use case. | | `tone=` | attribute | one of `blue`, `indigo`, `purple`, `maroon`, `green`, `teal`, `slate`, `red`, `orange`, `peach`, `sky` | Colour of the outline in `look=cards`; without it slate. | | `mark=` | attribute | the id of an `adr` declared in this diagram | Id of a decision of the decision bar, such as `E1`; the mark is drawn beside it. | | `emph` | flag | | Highlights it in the accent colour. | Example: ```dgr usecase order "Place order" in shop points="before checkout" ``` ### `rel` [Section titled “rel”](#rel) ```text rel <from> <arrow> <to> [label] [source=<multiplicity>] [card=<multiplicity>] [when=<text>] [at=<text>] [include] [extend] [emph] ``` A relation, read from `from` to `to`. `a -- b` is an association between an actor and a use case, with multiplicities `source=` at `a` and `card=` at `b`. `a -|> b` is a generalization: `a` is a special kind of `b`, both actors or both use cases. `a --> b include` means `a` always includes `b`; `a --> b extend` means `a` extends `b` under the condition `when=` at the extension points `at=` of `b`, shown in a note on the line. Lines run straight from outline to outline. Written at the top level. | Part | Kind | Value | Meaning | | --------- | ----------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `<from>` | argument | the id of an `actor` or `usecase` declared in this diagram | Actor or use case the relation starts at. | | `<arrow>` | argument | one of the arrows `--` association between an actor and a use case, `-\|>` generalization from the special to the general actor or use case, hollow triangle at the general one, `-->` include or extend between two use cases, dashed with an open head; needs the flag `include` or `extend` | What kind of relation it is. UML 2.5.1: `--` 18.1.3.1 Association of an actor with a use case; `-\|>` 9.2.3.2 Generalization between actors or between use cases. | | `<to>` | argument | the id of an `actor` or `usecase` declared in this diagram | Actor or use case the relation points to. | | `[label]` | optional argument | a text in double quotes like `"Order service"` | Name of the relation, shown at the middle of the line. | | `source=` | attribute | a UML multiplicity like `1`, `0..1`, `1..*` or `*`, the lower bound not above the upper one | Multiplicity at `from`, on an association only. UML 2.5.1: 18.1.3.1 Multiplicity at an end of that association. | | `card=` | attribute | a UML multiplicity like `1`, `0..1`, `1..*` or `*`, the lower bound not above the upper one | Multiplicity at `to`, on an association only. UML 2.5.1: 18.1.3.1 Multiplicity at an end of that association. | | `when=` | attribute | a text in double quotes like `"Order service"` | Condition of an `extend`, written without braces: Diagrist shows `{condition}` in a note. UML 2.5.1: 18.1.3.2 Condition of an extend, 18.1.4 Condition and extension points in a note on the extend. | | `at=` | attribute | a text in double quotes like `"Order service"` | Extension points of the extended use case `to`, separated by commas; on an `extend` only. UML 2.5.1: 18.1.3.2 Extension point, 18.1.4 Condition and extension points in a note on the extend. | | `include` | flag | | With `-->`: `from` always includes the behaviour of `to` («include»). UML 2.5.1: 18.1.3.3 Include. | | `extend` | flag | | With `-->`: `from` extends `to` under a condition («extend»). UML 2.5.1: 18.1.3.2 Extend. | | `emph` | flag | | Highlights the line in the accent colour. | The values of `arrow` and what they mean: | Value | Meaning | | ------ | ------------------------------------------------------------------------------------------------------- | | `--` | association between an actor and a use case | | `-\|>` | generalization from the special to the general actor or use case, hollow triangle at the general one | | `-->` | include or extend between two use cases, dashed with an open head; needs the flag `include` or `extend` | Examples: ```dgr rel customer -- order source=1 card=0..* rel regular -|> customer rel order --> pay include rel voucher --> order extend when="voucher present" at="before checkout" ``` ### `note` [Section titled “note”](#note) ```text note <text> [on <ref>] ``` A comment on an actor, a use case or a subject: a box with a folded corner at a free spot nearby, joined to it by a dashed line. On a subject it stands outside every subject. UML 2.5.1: 7.2.3.2 Comment (note). Written at the top level. | Part | Kind | Value | Meaning | | ---------- | -------- | --------------------------------------------------------------------- | ------------------------------------------------------- | | `<text>` | argument | a text in double quotes like `"Order service"` | What the note says; long texts wrap at word boundaries. | | `on <ref>` | clause | the id of an `actor`, `usecase` or `subject` declared in this diagram | The element the note belongs to. Required. | Example: ```dgr note "Only private customers" on shop ``` ### `adr` [Section titled “adr”](#adr) ```text adr <id> <question> <equals> <choice> [then] [consequence] [open=<text>] ``` An architecture decision in the bar below the picture: question, the chosen option after `=`, and the consequence after `=>`. `mark=` with its id puts the mark into the picture. Written at the top level. | Part | Kind | Value | Meaning | | --------------- | ----------------- | ------------------------------------------------------------------------------- | ------------------------------------------------------------- | | `<id>` | argument | an identifier like `api` (letters, digits, `_` and `-`, starting with a letter) | Id of the decision, such as `E1`; `mark=E1` refers to it. | | `<question>` | argument | a text in double quotes like `"Order service"` | The question that was decided. | | `<equals>` | argument | one of the arrows `=` | Separates the question from the choice. | | `<choice>` | argument | a text in double quotes like `"Order service"` | The chosen option. | | `[then]` | optional argument | one of the arrows `=>` | Introduces the consequence. | | `[consequence]` | optional argument | a text in double quotes like `"Order service"` | What follows from the choice. | | `open=` | attribute | a text in double quotes like `"Order service"` | Who still decides an open question; the card is drawn dashed. | Example: ```dgr adr E1 "How do the services coordinate?" = "Events over Kafka" => "No central coordinator" ``` ## Diagnostic codes [Section titled “Diagnostic codes”](#diagnostic-codes) Besides the codes of the language and the kernel, listed in [the overview](/docs/language/#diagnostic-codes), the rules of `usecase` report these. An error stops the build; a warning is printed and the picture is still drawn. | Code | Severity | What it checks | | ------ | -------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `U421` | error | `include` and `extend` join two use cases, never an actor. An actor takes part through an association `--`. UML 2.5.1: 18.1.3.3 Include, 18.1.3.2 Extend. | | `U422` | error | An association joins an actor with a use case: not two actors, not two use cases, not an element with itself. UML 2.5.1: 18.1.3.1 Association of an actor with a use case. | | `U423` | error | A generalization joins an actor with an actor or a use case with a use case, never one with itself, and runs in no cycle: the triangle points at the more general one. UML 2.5.1: 9.2.3.2 Generalization between actors or between use cases. | | `U424` | error | The extension points named by `at=` of an `extend` belong to the extended use case `to`, and the points of one use case have distinct names. UML 2.5.1: 18.1.3.2 Extension point, 18.1.3.2 Extend. | | `U425` | error | A use case includes itself neither directly nor through others. The arrow points from the base to the included case. UML 2.5.1: 18.1.3.3 Include. | | `U426` | error | `-->` names exactly one of the flags `include` and `extend`; `--` and `-\|>` name neither. Multiplicities `source=` and `card=` belong to associations, `when=` and `at=` to `extend`. UML 2.5.1: 18.1.3.3 Include, 18.1.3.2 Extend, 18.1.3.1 Multiplicity at an end of that association, 18.1.3.2 Condition of an extend. | | `U427` | error | `«include»` and `«extend»` mark relations, `«actor»` an actor and `«subsystem»` a subject. As the stereotype of a use case the picture claims something the model is not. UML 2.5.1: 18.1.4 Keyword or stereotype above a use case. | | `U428` | error | A note in a use case diagram is a comment on one element: it names its actor, use case or subject with `on`. UML 2.5.1: 7.2.3.2 Comment (note). | | `U920` | warning | UML allows use cases without a subject, but in a diagram with one, exam practice expects every use case inside it. UML 2.5.1: 18.1.3.1 Subject a use case applies to. | | `U921` | warning | A use case yields a result for an actor. It is reached when an actor takes part in it, or through `include`, `extend` or a generalization from a reached use case; otherwise an association is probably missing. UML 2.5.1: 18.1.3.1 Association of an actor with a use case. | | `U922` | warning | In UML the condition of an `extend` is optional; without it the extension always applies. Exam practice asks for it, and for the extension point when the extended use case has some. UML 2.5.1: 18.1.3.2 Condition of an extend, 18.1.3.2 Extension point. | | `U923` | warning | An actor without an association or generalization takes part in nothing, and a diagram without actors describes no use of the system. Both are valid UML. UML 2.5.1: 18.1.3.1 Actor. | | `U924` | warning | Between two use cases behaviour is either always part (`include`) or optional (`extend`), not both; usually one direction is swapped. UML 2.5.1: 18.1.3.3 Include, 18.1.3.2 Extend. | | `U926` | warning | A subject encloses the use cases of its system. Without one it has no content and is not drawn; a note on it finds no frame. UML 2.5.1: 18.1.3.1 Subject a use case applies to. | | `U927` | warning | `direction=` places several subjects side by side or below each other; with fewer than two it changes nothing. |