The primer

Docs · Learn

Copy as Markdown
View as Markdown

UJN primer

UJN 0.1 draft. UI Journey Notation in five minutes, for people and for language models. This is a summary of the spec (revision 21, November 27, 2026). Where the two differ, the spec wins: llms-full.txt (markdown), or the Docs page of the site. Names and rules may still change.

UJN 0.1 draft · revision 23 · November 29, 2026 · Changes

UJN writes a UI journey as text: the screens a user sees, what the system does between them, where the user leaves the app and comes back, and how it ends. A PlantUML module (not public yet) draws the text, checks it (warnings are listed under the drawing) and writes a model JSON for tools.

1. File and statements#

A diagram runs from @startujn to @endujn and holds one journey. One statement per line; a block { … } may run over several lines. The journey line comes before every node and arrow. Only preprocessor lines, increment, color blocks and render may come before it. Sections 9 and 10 are complete examples.

Statement Form
Journey line journey ID "Title", then key: value lines directly under it: description, context, trace, a11y, unique_id, unique_id_friendly
Node keyword handle [DISPLAY-ID] { key: value; key: value }. Only keyword and handle are required: view register is complete
Arrow from TOKEN to : [Trigger] guard { key: value }
Blocks increment { … } (display ids), render { … } (drawing switches), color blocks such as view_color { … } and view_color_modal { … }
  • Handles are letters, digits and _, starting with a letter. Arrows use them. Not drawn, except as the title when there is no title.
  • Values: text is bare, or in double quotes when it holds ;, }, ' or a comma inside a list. Lists are [a, b] (brackets optional for one item). A key on its own means true. Durations are 5 s, 30 min, 24 h. Colors are #hex or a PlantUML color name.
  • Comments: a line that starts with ', a /' … '/ block, or a ' after a space or a tab outside quotes.
  • Order: references are worked out after the whole file is read, but the layout reads the order of the nodes as the order of the journey. Write nodes in the order the journey goes.

2. The nine kinds#

Keyword What it is Types (default first) Its own keys
view anything the user sees as a window plain, modal, drawer, popover, toast, tabs, wizard, embedded, new-window, waiting route, collapsed, parent; behavior overrides blocks, dismiss, focus, duration, target
action something the system does between views action, message, wait, event, auth, permission, fork, join timeout (action, wait, event, auth), channel (message)
handoff the user leaves the app or its channel (email link, bank app, identity provider) returns, no-return channel, timeout, resume
data a store an action reads or writes server-database, file, folder, browser-cache, browser-storage, api location
actor a person: who starts the journey, or an agent inline doing a manual task none role
system a service the flow calls while the user stays in the app internal, external host
start where the journey begins plain, deep-link, notification, handoff-return route
end how it ends success, failure, abandoned none
ref another journey, drawn in its own diagram none journey (required), point

Every node also takes type, title (default: the handle), flags, description, trace, a11y, context, tooltip, unique_id, unique_id_friendly, id_position and the colors color_frame, color_icon, color_title, color_description, color_background. A key that does not apply is a warning, and its value is kept under extra in the model.

3. Arrows#

Token Kind Drawn Use it for
--> (or ->) navigation solid the flow moves on
-x-> negative solid, with a cross a failure path: an error, a rejection
..> (or .>) return dashed going back: a modal closes, Back, a toast goes away
.x.> failed return dashed, with a cross going back because something failed
  • Label: : [Trigger] guard. The trigger is what the user does; the guard says when this exit is the one taken. The pill shows Trigger · guard.
  • Direction hints sit in the token: -down->, -up-x->, .left.>, -r->. A hint is a wish, never an error.
  • Arrow block keys: payload (what crosses), returns (draws the way back of a call into a ref or a handoff), flags, trace, context, a11y, tooltip, arrow_spacing, color_line, color_text, color_background.

Exit rules, by what the arrow leaves:

  • A view: every --> and -x-> needs a trigger. Exits that share a trigger each need a guard. A ..> may stay unlabeled.
  • An actor inline: the outcome is the trigger: [Approve], [Reject].
  • An action: no trigger. Exits without a guard all fire; among guarded exits exactly one fires. Do not mix the two on one action (put a fork after the guarded exit instead). An action with a timeout needs an exit guarded timeout.
  • Calls and data: only an action calls a system (-->, no label); the system replies with ..>. A write goes from the action into the store, a read from the store into the action, no label.
  • A handoff: left only by resume arrows (..>, or .x.> for a failed resume), each with a trigger; or write { returns } on the arrow into it. A no-return handoff has neither.
  • A start: as an action. Into a start: only the actor who starts the journey (no trigger), or a handoff's resume into a handoff-return start. Nothing leaves an end.
  • A ref: { returns } on the arrow in makes it a call that comes back. Only ..> arrows leave a ref, with no trigger; when there are several, a guard names each outcome.
  • Reachability: once a journey has a start, every node needs a path from a start (actors and data stores aside).

4. Flags#

flags: [future, risk] in the block of a node or an arrow. A flag never changes a shape: the border goes dotted and a glyph tab shows the flag.

  • Delivery flags propagate to everything reachable only through the flagged node: idea, future, not-implemented, out-of-scope, deprecated.
  • Review flags stay where they are set: experiment, risk, security, needs-decision, needs-updates.
  • Pending: legacy (the proposal: it stays where it is set). Never write inherited flags.
Id Written Use
handle view login inside the file only; may be renamed
display id view login [AUTH-10], or assigned by increment { auto; view_prefix: "AUTH" } for viewing only; it may change; never link to it
unique id unique_id: {{auto}}, filled once by -populate_ids with 11 random lowercase hex digits permanent: tests, code and other diagrams link to it
friendly id namespace.name: unique_id_friendly of the journey (else the journey id in lowercase), then unique_id_friendly of the node (else the handle) readable; changes when edited
  • Fill every {{auto}} before the file's first commit: java -jar plantuml.jar -populate_ids file.puml.
  • Trace links point out of the diagram: trace: [req:AUTH-01, test:e2e/login.spec.ts]. Kinds: req, story, design, component, test, code, doc; other kinds are passed on. A node with trace links and no unique_id gets a warning.

6. The render block#

Key Values (default first)
colors color, mono (black and white)
corners rounded, square
direction right, down
legend false, true
warnings show, hide
id_position outside, inside, inside-top, inside-bottom, hidden
arrow_spacing default (70 px), or pixels

render { direction: down; legend }: one per diagram; it changes the drawing, never the model.

7. The model JSON#

java -jar plantuml.jar -tsvg --ujn-model file.puml writes file.ujn.json beside the drawing. Its JSON Schema is ujn-model-v5.schema.json. Every key is always there (null or [] when not written), except extra, which appears only when the text has keys the language does not define.

JSON
{  "language": "ujn-parts-1-4",  "journey": { "id": "SIGNUP", "title": "Sign up", "uniqueId": null, "friendlyNamespace": "signup", "…": "…" },  "nodes": [ { "key": "signup", "kind": "view", "type": "plain", "title": "Create account", "id": "SU-001",               "idAssigned": true, "uniqueId": "5c1e9a07b3d", "friendlyId": "signup.signup", "flags": [],               "inherited": [], "route": "/signup", "…": "…" } ],  "arrows": [ { "from": "signup", "to": "create", "kind": "navigation", "negative": false, "role": "exit",                "trigger": "Create account", "guard": null, "payload": ["email", "password"], "…": "…" } ],  "warnings": [ { "message": "…", "handle": "…", "line": 12 } ]}
  • Nodes and arrows are in the order written. Keys are camelCase.
  • Worked out for you: assigned display ids, inherited flags, a view's effective behavior, arrow roles (exit, call, reply, resume, write, read), colors after the cascade, warnings.
  • Across versions of a file, key a node on uniqueId; never on the display id id.

8. Common warnings and how to fix them#

A warning lets the diagram draw; it is listed under it as line N · handle: message. A syntax error (no journey line, an arrow to an undeclared handle, a block never closed) stops the drawing.

Warning Fix
an exit from a view needs a trigger, written after a colon: [Trigger] Add what the user does: a --> b : [Next]
2 exits share [Go]; each needs a guard Tell them apart: : [Go] valid and : [Go] invalid
an exit from an action takes no trigger Write a guard or nothing: check --> done : valid
guarded and unguarded exits on one action Guard every exit, or put a fork after the guarded one
a handoff is left only by its resume arrows (..>) Use ..> out of a handoff, with a trigger
a returning handoff needs a way back: … Add { returns } on the arrow into it, a ..> out of it, or type: no-return
only an action calls a system Put an action between the view and the system
a data store connects only to actions Read and write through an action
has trace links but no unique_id, so other files cannot link back to it Add unique_id: {{auto}} and run -populate_ids
unique_id is still {{auto}}. Generate it before your first commit: … Run the command the warning prints
no path from a start reaches it Add an arrow from a node that is reached, or remove the node
has a timeout but no exit guarded timeout Add : timeout on one exit of the action
unknown flag futur Use one of the eleven flags in section 4
key channel does not apply to a view Use the keys of that kind (section 2); the value is kept under extra
Example 1Try it
@startujnjourney SIGNUP "Sign up"description: "Create an account and confirm the email address"unique_id_friendly: signup increment { auto; view_prefix: "SU" } start open { type: deep-link; route: /signup }view signup{  title: "Create account"  description: "Email and password"  route: /signup  trace: [req:SU-01, test:e2e/signup.spec.ts]  ' -populate_ids wrote this id from unique_id: {{auto}}; in a new file write {{auto}}  unique_id: 5c1e9a07b3d                  ' AUTO GENERATED - DO NOT CHANGE}view with_google { title: "Sign up with Google"; flags: [future] }action create { title: "Create account" }system accounts { title: "Account service"; host: accounts.internal }action send_mail { type: message; title: "Send confirmation"; channel: email }view check_mail { title: "Check your email"; route: /signup/sent }handoff inbox { title: "Confirmation link"; channel: email; timeout: 24 h }view welcome { title: "Welcome"; route: /welcome }end done { type: success; description: "Account confirmed" } open --> signupsignup --> create : [Create account] { payload: [email, password] }signup --> with_google : [Use Google]create --> accounts { payload: [email, password] }accounts ..> create { payload: [account_id] }create --> send_mail : createdcreate .x.> signup : email takensend_mail --> check_mailsend_mail --> inboxinbox ..> welcome : [Open link] validinbox .x.> signup : [Open link] expiredwelcome --> done : [Continue]@endujn
Drawing of Example 1: start open, view Create account, view Sign up with Google, action Create account, system Account service, action Send confirmation, view Check your email, handoff Confirmation link, view Welcome, end done. Arrows: open to Create account; Create account to Create account on Create account; Create account to Sign up with Google on Use Google; Create account to Account service; Account service to Create account; Create account to Send confirmation; Create account to Create account; Send confirmation to Check your email; Send confirmation to Confirmation link; Confirmation link to Welcome on Open link; Confirmation link to Create account on Open link; Welcome to done on ...
Drawn from this text10 nodes · 12 arrows0 warnings

The unique_id above was generated by -populate_ids. Never type one yourself: write unique_id: {{auto}} and run the command.

10. Example: a return approved by an agent#

Example 2Try it
@startujnrender { direction: down }journey RETURNS "Return an item"description: "A customer asks to return an item; an agent approves or rejects it" actor customer { title: "Customer" }start from_orders { description: "From the order list" }view order { title: "Order details"; route: /orders/:id }view return_form { type: modal; title: "Return item"; description: "Reason and photos" }action submit { title: "Submit return" }data returns_db { title: "Returns"; location: table returns }actor agent { title: "Support agent"; role: Back office }view label { title: "Return label"; route: /returns/:id/label }view rejected { type: toast; title: "Return rejected" }ref refund { journey: REFUND; title: "Refund" }end done { type: success; description: "Label sent" } customer --> from_ordersfrom_orders --> orderorder --> return_form : [Return item]return_form ..> order : [Cancel]return_form --> submit : [Send] { payload: [reason, photos] }submit --> returns_db { payload: [return] }submit --> agentagent --> label : [Approve]agent -x-> rejected : [Reject]label --> refund : [Track refund] { returns }label --> done : [Done]@endujn
Drawing of Example 2: actor Customer, start from_orders, view Order details, view Return item, action Submit return, data store Returns, actor Support agent, view Return label, view Return rejected, journey reference Refund, end done. Arrows: Customer to from_orders; from_orders to Order details; Order details to Return item on Return item; Return item to Order details on Cancel; Return item to Submit return on Send; Submit return to Returns; Submit return to Support agent; Support agent to Return label on Approve; Support agent to Return rejected on Reject; Return label to Refund on Track refund; Return label to done on Done.
Drawn from this text11 nodes · 11 arrows0 warnings

The full spec covers what this primer leaves out: view behavior per type, colors and themes, how arrows are routed, the palette, and every rule in its errors and warnings table (section 21).