Skip to content

Sequence diagram

Messages between user, interface, server and database, in time order.

What it explains and when it is useful

A sequence diagram shows one scenario as messages passed between participants over time, read from top to bottom. Combined fragments (alt, opt, loop) show alternatives and repetition.

When to use it: When the interaction between parts matters: a web request reaching a database, an app calling an API, objects co-operating in OOP, a client and server in a game.

Worked example

Illustrative: PracticePal is a fictional project used throughout this guide.

Sequence diagram for booking a slot in PracticePal: the student taps a free slot, the browser posts to the /book route, the route asks rules.py to run three checks against the database, then either inserts the booking in a transaction and confirms, or returns the reasonStudentBrowser(week.js)/book route(views.py)rules.pydb.py +SQLite1 tap free slot P5, Tue 12:302 POST /book {room, start, loud}3 check(student, room, start, loud)4 overlapping bookings? (SQL Q1)rows5 count this week (SQL Q2)n6 loud neighbour bookings? (SQL Q3)rows7 ok, or first broken rulealt[all rules pass]8 BEGIN IMMEDIATE; INSERT; COMMITbooking_id (or UNIQUE error → else)9 201 Created {booking}10 shows “Booked”[else: a rule is broken or the insert failed]8′ 409 Conflict {reason}9′ shows reasonsolid arrow = call / request · dashed arrow = reply · shaded bar = object is busy (activation)
Booking a slot, with the success and failure alternatives.

Scroll sideways to see the whole diagram.

Notation and legend

Symbol or partMeaning
Box or figure at the topParticipant (user, component or object)
Dashed vertical lineLifeline: time runs downwards
Shaded barActivation: the participant is busy
Solid arrowRequest or call
Dashed arrowReply
alt frameAlternatives; the condition is in brackets

Design decisions it communicates

A diagram earns marks when you explain the decisions it shows. In PracticePal's documentation these would each be one sentence:

  • Three rule checks run before the transaction, so most refusals never take the write lock.
  • The browser receives a reason (409) rather than an error page, which becomes the message the user sees.
  • Numbered messages match the SQL query design table (Q1–Q3).

Common mistakes

  • Too many participants or messages: one scenario per diagram.
  • No return messages.
  • Using it instead of algorithms: it shows who talks to whom, not the logic inside.

Checklist for your own version

Ticks are saved in this browser only, so you can use the list while you draft.