UML Diagram Examples: Class, Use Case, Sequence, State and Activity

UML has fourteen diagram types, but five of them cover almost every project report and design review: class, use case, sequence, state and activity. Below is a real example of each, with the notation explained, and every example opens as an editable template.

UML · 2026-11-03 · 11 min read

Types of UML diagrams

UML 2 splits its 14 diagrams into two groups. Structure diagrams show what the system is made of; behaviour diagrams show what it does over time.

GroupDiagramShows
StructureClass diagramClasses, attributes, methods and relationships
StructureComponent / deployment diagramSoftware parts and the servers they run on
StructureObject, package, composite structure, profileLess common; mostly in large designs
BehaviourUse case diagramWho uses the system and what they can do
BehaviourSequence diagramMessages between parts, in time order
BehaviourState diagramThe states one object moves through
BehaviourActivity diagramThe steps of a process, with parallel paths
BehaviourCommunication, timing, interaction overviewLess common variants of sequence diagrams

Class diagram

A class diagram shows the classes of a system, their attributes and methods, and how they relate. The relationship arrows matter:

LineNameMeaningExample
Hollow triangle ▷Inheritance"is a"Ebook is a Book
Filled diamond ◆CompositionPart cannot exist without the wholeOrder ◆— OrderLine
Hollow diamond ◇AggregationPart can exist on its ownLibrary ◇— Book
Plain lineAssociationClasses use each otherMember — Loan
Dashed with triangleRealizationClass implements an interfaceCardPayment ⇢ Payment

Example: Class diagram for a library: members, books, loans and fines with multiplicities.

Use case diagram

A use case diagram shows who uses the system (actors, drawn outside the box) and what they can do (use cases, ovals inside the system boundary). Use «include» for a step that always happens as part of another use case, and «extend» for an optional one.

Example: Use case diagram for an ATM: customer and bank actors, withdraw, deposit, check balance.

A second example, with more actors: in a food delivery app each kind of user gets their own use cases inside the same system boundary.

Example: Use case diagram for a food delivery app.

Sequence diagram

A sequence diagram shows the messages between parts of a system in time order. Each participant gets a vertical lifeline; solid arrows are calls, dashed arrows are replies, and boxes labelled alt or loop show choices and repeats.

Example: Sequence diagram for login with OTP: user, app, auth service and SMS gateway.

State diagram

A state (state machine) diagram shows the states one object goes through and the events that move it between them — perfect for orders, tickets, documents and devices.

Example: State diagram for an online order: placed, paid, shipped, delivered, cancelled.

Activity diagram

An activity diagram is UML's flowchart, with extras: forks and joins (thick bars) for steps that run in parallel, and swimlane partitions for who does what.

Example: Activity diagram for exam registration with a decision and parallel steps.

Which UML diagram should you use?

You want to show…Use
The data model and code structureClass diagram
What users can do with the systemUse case diagram
How one object changes over timeState diagram
The steps of a process or algorithmActivity diagram
Messages between parts of the systemSequence diagram

Generate: use case diagram →

Frequently asked questions

Which UML diagrams are needed for a final-year project?

Usually a use case diagram, a class diagram, a sequence diagram for the main flow, and an activity diagram. Many reports also include a DFD and an ER diagram.

What is the difference between aggregation and composition?

In composition the part cannot exist without the whole (an order line without its order); in aggregation it can (a book without a particular library).

Is an activity diagram the same as a flowchart?

Nearly. An activity diagram adds parallel steps (fork/join) and partitions, and uses UML notation.

How many types of UML diagrams are there?

UML 2 has 14: seven structure diagrams (class, component, deployment, object, package, composite structure, profile) and seven behaviour diagrams (use case, activity, state, sequence, communication, timing, interaction overview).

Can I edit these UML examples?

Yes. Every example on this page opens in AI Flowchart as an editable diagram, and you can ask the AI to change it for your own system.

Worked examples, explained

Keep reading

← All guides

Try AI Flowchart free →