Diagram Desk

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

ControllerStock unitInsert coinsChoose drinkCheck stockIn stockTake oneDrink and changeUser
Sequence diagram · 3 shapes

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

ShapeSymbolConnections
UserActor→ Controller(Insert coins), Controller(Choose drink) · ← Controller
ControllerParticipant and lifeline→ Stock unit(Check stock), Stock unit(Take one), User(Drink and change) · ← User, User, Stock unit
Stock unitParticipant and lifeline→ Controller(In stock) · ← Controller, Controller

Symbols used here

SymbolMeaning
Participant and lifelineA box on top and a dashed line below.
ActorA human participant; a stick figure.
Synchronous messageA call that waits; solid line, filled head.
ReplyThe answer; dashed line, open head.

All sequence diagram symbols and how to draw

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

More sequence diagram examples

All SeewolLabs tools