Sequence diagram (PlantUML)

PlantUML sequence diagrams handle everything Mermaid's do and rather more besides. This one uses activation bars, a group, and a divider.


#What this example shows

  • Explicit activate and deactivate, which draw the busy bars.

  • group and alt, for optional and conditional stretches.

  • A divider, which splits a long sequence into readable phases.


#A worked example

Open it, edit it, or copy the source below.

Sequence diagram (PlantUML)

The source, which you can paste into a new diagram and edit:

@startuml
autonumber
actor Customer
participant "Checkout" as UI
participant "Order API" as API
database "Orders" as DB
participant "Payments" as PAY

Customer -> UI: Confirm order
activate UI
UI -> API: POST /orders
activate API
API -> DB: INSERT order (pending)
API -> PAY: authorise(amount)
activate PAY

alt authorised
  PAY --> API: auth code
  API -> DB: UPDATE order = paid
  API --> UI: 201 Created
else declined
  PAY --> API: declined
  API -> DB: UPDATE order = failed
  API --> UI: 402 Payment Required
end
deactivate PAY
deactivate API

== Fulfilment ==

group asynchronous
  API -> API: publish OrderPaid
end

UI --> Customer: Confirmation page
deactivate UI

note over API, PAY
  Authorisation times out after 8 seconds
  and is retried once.
end note
@enduml

#Making it your own

  • Add ' skinparam responseMessageBelowArrow true' to move return labels under the arrows.

  • Use par and end for genuinely concurrent messages.

  • Every diagram needs @startuml and @enduml or it will not be detected as PlantUML.



Verbose, stable, and it draws almost everything.