Skip to content

Use Case Diagram

Last updated:

Mermaid Studio recognizes and renders UML use case diagrams inside IntelliJ IDEA and other JetBrains IDEs. A use case diagram shows who interacts with a system and what they can do with it: actors on the outside, use cases inside a system boundary, and the associations, includes, and extends between them.

Mermaid Studio opens a use case diagram in a split editor with the highlighted source on the left and the rendered diagram on the right. The example below groups an online store’s use cases inside one boundary, with a customer and a staff member outside it and classes coloring each part, rendered under three IDE themes:

A use case diagram with classDef and style lines carrying color swatches in the gutter, and two actors outside a styled ordering-system boundary in the live preview under the Armada Dark theme

Use case diagrams are a basic syntax highlighting type with a few editing aids on top.

IDE feature supportSelect a feature for its description.
Editing
Code Intelligence
Validation
Refactoring
Appearance

At the start of a line, completion offers the statement keywords such as actor, systemBoundary, and note for, plus each direction value. Press Enter Enter after a systemBoundary header and the editor inserts the closing end, and every boundary folds like any other block. When the diagram shows in a preview, Mermaid.js parser errors are marked in the editor on the token they point to, so a mistake in the body shows up where you typed it (see Diagram Validation).

Frontmatter completion covers the config.usecase block, and the sample picker includes basic and styled use case samples to start from.

Style actors, use cases, and boundaries with classDef, class, and style statements, or attach a class inline with the ::: suffix. The editor completes CSS properties and values inside these statements, completes class names wherever a class is referenced, and shows a color swatch in the gutter next to each color. Renaming a classDef updates every use of that class, and an inspection flags a class that is defined but never used or used but never defined.

In the styled sample below, the gutter shows the colors of each classDef, and the preview shows the classes applied:

The styled use case sample in the split editor, with color swatches in the gutter beside each classDef and the actors, boundary, and use cases painted with their classes in the live preview

Mermaid Studio bundles live templates for the statements a use case diagram is built from, so you can scaffold a boundary or a relationship without recalling the operator syntax. Type the abbreviation, accept it from the completion popup, and tab through the variables. See Live Templates for the cross-cutting mechanics (triggering, contextual visibility, configuration).

AbbreviationExpansion
actorActor with a display label (actor id("Label"))
boundarySystem boundary block (systemBoundary id("Title") … end)
includeInclude relationship (source ..> : include target)
extendExtend relationship (source ..> : extend target)
noteNote attached to an element (note for target "text")
jsonJSON table node (json id@{ … })

Declare every actor with actor; a use case is drawn as an ellipse with id("Label") or as a rectangle with id[Label]. An endpoint of a relationship that has no declaration becomes an ellipse use case:

usecase-beta
actor Customer
actor Admin("Main administrator")
Login("Sign in")
Report[Generate report]
Customer --> Login
Admin --> Report

Add metadata to an actor to change how it’s drawn: @{ type: hollow }, @{ type: awesome }, @{ business: true }, or an icon from any registered icon set with @{ icon: "fa:user" }.

Associations use -->, <--, and --, with an optional label between the dashes. Includes and extends connect two use cases, and --|> draws a generalization:

usecase-beta
actor Admin
actor Person
Admin --|> Person
Admin -- "opens" --> Checkout
Checkout ..> : include Payment
ApplyCoupon ..> : extend Checkout

A systemBoundary block groups the actors and use cases inside it and closes with end:

usecase-beta
systemBoundary payments["Payment service"]
Authorize("Authorize payment")
Refund("Issue refund")
end
actor Clerk
Clerk --> Authorize

For complete syntax details, see the Mermaid.js use case documentation.