Sequence Diagrams
Sequence diagrams show interactions between participants over time. They’re perfect for documenting APIs, user flows, and system interactions.
Basic Sequence Diagram
Authentication Flow
Async Communication
Error generating PlantUML diagram: Request failed with status code 520
@startuml
participant "Service A" as A
participant "Message Queue" as MQ
participant "Service B" as B
A -> MQ: Publish event
note right: Async message
MQ -> MQ: Store message
MQ --> A: Acknowledged
... 5 minutes later ...
B -> MQ: Poll for messages
MQ --> B: Deliver event
B -> B: Process event
B -> MQ: Acknowledge
@enduml
Error Handling
Error generating PlantUML diagram: Request failed with status code 520
@startuml
participant Client
participant Server
participant Database
Client -> Server: Request data
Server -> Database: Query
Database --> Server: Error: Connection timeout
alt Database error
Server --> Client: 503 Service Unavailable
note right: Retry later
else Success
Server --> Client: 200 OK with data
end
@enduml
Tips for Sequence Diagrams
- Use meaningful names: Instead of
A
,B
, useClient
,Server
- Add notes: Use
note left/right
to add context - Show timing: Use
...
to indicate time passing - Group related interactions: Use
group
blocks - Handle conditions: Use
alt/else
for different flows