Sequence Diagram Examples You Can Copy
A sequence diagram shows who talks to whom, in what order. These are the flows that come up again and again in projects, interviews and design docs — each explained message by message, and each one editable.
UML · 2026-10-23 · 8 min read
The parts of a sequence diagram
- Participants (actors or systems) sit across the top; a dashed lifeline runs down from each.
- Messages are arrows between lifelines, in time order from top to bottom.
- A solid arrow is a call or request; a dashed arrow is a reply.
- An activation bar (thin rectangle) shows when a participant is busy handling a request.
- Fragments — alt (if/else), opt (optional), loop — wrap messages that only happen sometimes or repeat.
1. Login with JWT
The user submits credentials, the server checks them against the database, and returns a signed token the browser sends with every later request.
Example: JWT login: credentials in, signed token out, token sent with each API call.
2. OTP verification
The app asks the server to send an OTP, the server stores it with an expiry and sends it through an SMS provider; the user types it back and the server compares the two.
Example: OTP login: generate, send by SMS, verify, create session.
3. UPI payment
The merchant app creates a collect request; the payer's UPI app asks for the PIN; the banks move the money and both apps get the result.
Example: UPI payment between user, app, PSP and banks.
More flows in the templates
| Flow | Participants | Watch out for |
|---|---|---|
| Google sign-in (OAuth) | User, app, Google, backend | The app never sees the password; the backend verifies the ID token |
| Password reset | User, app, server, email service | One-time token with an expiry, invalidated after use |
| Checkout | Customer, store, payment gateway, inventory | Reserve stock before charging; release it if payment fails |
| Ride booking | Rider, app, matching service, driver | A loop of offers until a driver accepts |
| File upload to S3 | Browser, backend, S3 | Pre-signed URL so files skip your server |
| Cache-aside read | Service, cache, database | Miss → read DB → write cache |
Tip: Keep one sequence diagram to one scenario. If you find yourself drawing every error case, split it: a happy-path diagram, then one for the important failure.
Generate: Google sign-in sequence →
Frequently asked questions
What is the difference between a sequence diagram and a flowchart?
A flowchart shows the steps and decisions of one process; a sequence diagram shows the messages exchanged between several participants over time.
What does a dashed arrow mean in a sequence diagram?
A reply (return message) to an earlier request.
How do I show an if/else in a sequence diagram?
Wrap the messages in an alt fragment with one section per condition, for example [valid OTP] and [invalid OTP].