Mermaid Sequence Diagram Example

Sequence diagrams are essential for documenting how components interact over time. Whether you're building API documentation, mapping an authentication flow, or designing microservice communication, Mermaid sequence diagrams make it effortless to communicate complex interactions.

Render this diagram instantly — free, no signup

Open Marmady Editor →

Example: API Authentication Flow

This sequence diagram models a standard token-based authentication flow between a browser client, an API server, and a database:

sequenceDiagram participant Client participant API participant DB Client->>API: POST /login (credentials) API->>DB: Query user by email DB-->>API: Return user record API->>API: Validate password hash API->>API: Generate JWT token API-->>Client: 200 OK + JWT

Example: Microservice Request Chain

This example shows how an API gateway routes a request through multiple internal services:

sequenceDiagram participant Gateway participant AuthService participant UserService participant DB Gateway->>AuthService: Validate token AuthService-->>Gateway: Token valid Gateway->>UserService: GET /user/:id UserService->>DB: Fetch user data DB-->>UserService: User record UserService-->>Gateway: User JSON Gateway-->>Client: 200 Response

Sequence Diagram Syntax Reference

Try it live in Marmady

Paste any example above into Marmady and export it as SVG, PNG, or PDF — instantly. Free, built for developers.

Open Marmady Editor →