Back to all diagrams

Sequence Diagrams

Document interactions between different actors or systems over time. Ideal for API documentation and system design.

What is Sequence Diagrams?

Sequence diagrams are UML interaction diagrams that show how objects or systems communicate with each other over time. They display the chronological order of message exchanges between different actors, making them invaluable for documenting API flows, system interactions, and multi-step processes. Each participant is represented by a vertical lifeline, with horizontal arrows showing message exchanges.

Edit and preview

Build a Sequence Diagrams with Mermaid syntax and see changes instantly.

Editor
100%

Common Use Cases

API Documentation

Document API endpoints and their interaction flows. Visualize request-response cycles, authentication flows, error handling, and data exchanges between client and server.

Microservices Architecture

Map communication patterns between microservices, message queues, and databases. Essential for understanding distributed system behavior and debugging integration issues.

Authentication & Authorization

Model multi-step authentication processes like OAuth, SAML, or JWT token flows. Show the sequence of redirects, token exchanges, and validation steps.

System Integration

Visualize how different systems interact in complex integration scenarios. Document webhook callbacks, event-driven architectures, and third-party service integrations.

Key Features

Participant Management

Define multiple actors, systems, or services with aliases and activation boxes to show when components are actively processing.

Message Types

Support for synchronous calls, asynchronous messages, return values, and self-calls with different arrow styles for clarity.

Control Structures

Model loops, conditional branches (alt/else), optional blocks, and parallel processing with intuitive syntax.

Notes & Annotations

Add explanatory notes to any point in the sequence to provide context, clarify business logic, or document edge cases.

Best Practices

Focus on One Scenario

Each sequence diagram should represent a single use case or interaction flow. Create separate diagrams for different scenarios rather than combining everything.

Use Meaningful Names

Give participants clear, descriptive names. Use actual service names or role titles rather than generic labels like 'System A' or 'Component 1'.

Show Error Paths

Don't just document the happy path. Include alternative flows for error conditions, timeouts, and exception handling.

Keep Time Top-to-Bottom

Follow the convention that time flows from top to bottom. Earlier interactions should appear higher in the diagram than later ones.