Skip to content

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.

This page lists everything a usecase diagram may contain. The same grammar is available as data with dgr grammar usecase --json, and the overview explains how lines, texts and attributes are written and lists the codes every kind shares.

diagram usecase "Title" [subtitle=<text>] [look=<plain|cards>] [direction=<down|right>] [locale=<en|de>]

Every usecase diagram starts with this line.

PartKindValueMeaning
subtitle=attributea text in double quotes like "Order service"Second line below the title.
look=attributeone of plain, cardsplain (default) draws the UML notation, cards the same layout with toned outlines and areas.
direction=attributeone of down, rightSeveral 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=attributeone of en, deLanguage of the texts Diagrist adds to the picture and of the description: en (default) or de.

Example:

diagram usecase "Title"

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.

StatementWhereWhat it does
actortop levelAn 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.
subjecttop levelA 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.
usecasetop levelA use case: an ellipse as large as its name inside the subject in; names over 18 characters wrap.
reltop levelA relation, read from from to to.
notetop levelA 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.
adrtop levelAn architecture decision in the bar below the picture: question, the chosen option after =, and the consequence after =>.
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.

PartKindValueMeaning
<id>argumentan identifier like api (letters, digits, _ and -, starting with a letter)Id that rel and note use for this actor.
<label>argumenta text in double quotes like "Order service"Name of the role.
kind=attributeone of person, systemperson (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=attributeone of left, rightSide of the subject the actor stands on; without it Diagrist chooses.
tone=attributeone of blue, indigo, purple, maroon, green, teal, slate, red, orange, peach, skyColour of the figure or box in look=cards; without it slate.
mark=attributethe id of an adr declared in this diagramId of a decision of the decision bar, such as E1; the mark is drawn beside it.
emphflagHighlights it in the accent colour.

Examples:

actor customer "Customer"
actor psp "Payment provider" kind=system side=right
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.

PartKindValueMeaning
<id>argumentan identifier like api (letters, digits, _ and -, starting with a letter)Id that usecase ... in and note ... on use for this subject.
<label>argumenta text in double quotes like "Order service"Name of the system.
tone=attributeone of blue, indigo, purple, maroon, green, teal, slate, red, orange, peach, skyColour of its area in look=cards; without it slate.

Example:

subject shop "Online shop"
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.

PartKindValueMeaning
<id>argumentan identifier like api (letters, digits, _ and -, starting with a letter)Id that rel and note use for this use case.
<label>argumenta text in double quotes like "Order service"Name of the goal, as a verb phrase.
in <ref>clausethe id of a subject declared in this diagramThe 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=attributea 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=attributeone of ellipse, classifierellipse (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=attributea 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=attributeone of blue, indigo, purple, maroon, green, teal, slate, red, orange, peach, skyColour of the outline in look=cards; without it slate.
mark=attributethe id of an adr declared in this diagramId of a decision of the decision bar, such as E1; the mark is drawn beside it.
emphflagHighlights it in the accent colour.

Example:

usecase order "Place order" in shop points="before checkout"
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.

PartKindValueMeaning
<from>argumentthe id of an actor or usecase declared in this diagramActor or use case the relation starts at.
<arrow>argumentone 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 extendWhat 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>argumentthe id of an actor or usecase declared in this diagramActor or use case the relation points to.
[label]optional argumenta text in double quotes like "Order service"Name of the relation, shown at the middle of the line.
source=attributea UML multiplicity like 1, 0..1, 1..* or *, the lower bound not above the upper oneMultiplicity at from, on an association only. UML 2.5.1: 18.1.3.1 Multiplicity at an end of that association.
card=attributea UML multiplicity like 1, 0..1, 1..* or *, the lower bound not above the upper oneMultiplicity at to, on an association only. UML 2.5.1: 18.1.3.1 Multiplicity at an end of that association.
when=attributea 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=attributea 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.
includeflagWith -->: from always includes the behaviour of to («include»). UML 2.5.1: 18.1.3.3 Include.
extendflagWith -->: from extends to under a condition («extend»). UML 2.5.1: 18.1.3.2 Extend.
emphflagHighlights the line in the accent colour.

The values of arrow and what they mean:

ValueMeaning
--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:

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 <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.

PartKindValueMeaning
<text>argumenta text in double quotes like "Order service"What the note says; long texts wrap at word boundaries.
on <ref>clausethe id of an actor, usecase or subject declared in this diagramThe element the note belongs to. Required.

Example:

note "Only private customers" on shop
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.

PartKindValueMeaning
<id>argumentan identifier like api (letters, digits, _ and -, starting with a letter)Id of the decision, such as E1; mark=E1 refers to it.
<question>argumenta text in double quotes like "Order service"The question that was decided.
<equals>argumentone of the arrows =Separates the question from the choice.
<choice>argumenta text in double quotes like "Order service"The chosen option.
[then]optional argumentone of the arrows =>Introduces the consequence.
[consequence]optional argumenta text in double quotes like "Order service"What follows from the choice.
open=attributea text in double quotes like "Order service"Who still decides an open question; the card is drawn dashed.

Example:

adr E1 "How do the services coordinate?" = "Events over Kafka" => "No central coordinator"

Besides the codes of the language and the kernel, listed in the overview, the rules of usecase report these. An error stops the build; a warning is printed and the picture is still drawn.

CodeSeverityWhat it checks
U421errorinclude 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.
U422errorAn 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.
U423errorA 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.
U424errorThe 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.
U425errorA 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.
U426error--> 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.
U427error«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.
U428errorA 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).
U920warningUML 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.
U921warningA 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.
U922warningIn 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.
U923warningAn 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.
U924warningBetween 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.
U926warningA 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.
U927warningdirection= places several subjects side by side or below each other; with fewer than two it changes nothing.