Vending machine sequence diagram
Buying a drink as messages between the user, the controller and stock. Compare with the vending-machine flowchart to see what each diagram shows.
The diagram
Reading it step by step
- 1. 'User' sends a request to 'Controller': 'Insert coins'.
- 2. 'User' sends a request to 'Controller': 'Choose drink'.
- 3. 'Controller' sends a request to 'Stock unit': 'Check stock'.
- 4. 'Stock unit' replies to 'Controller': 'In stock'.
- 5. 'Controller' sends a request to 'Stock unit': 'Take one'.
- 6. 'Controller' replies to 'User': 'Drink and change'.
Shape by shape
| Shape | Symbol | Connections |
|---|---|---|
| User | Actor | → Controller(Insert coins), Controller(Choose drink) · ← Controller |
| Controller | Participant and lifeline | → Stock unit(Check stock), Stock unit(Take one), User(Drink and change) · ← User, User, Stock unit |
| Stock unit | Participant and lifeline | → Controller(In stock) · ← Controller, Controller |
Symbols used here
| Symbol | Meaning |
|---|---|
| Participant and lifeline | A box on top and a dashed line below. |
| Actor | A human participant; a stick figure. |
| Synchronous message | A call that waits; solid line, filled head. |
| Reply | The answer; dashed line, open head. |
Diagram text
Paste this text into the editor to get the same picture, then change the names to fit your own work.
# Vending machine sequence diagram
sequenceDiagram
actor U as User
participant C as Controller
participant I as Stock unit
U->>C: Insert coins
U->>C: Choose drink
C->>I: Check stock
I-->>C: In stock
C->>I: Take one
C-->>U: Drink and change