sequenceDiagram
participant C as Client
participant LB as Load balancer
participant API as API server
participant R as Redis cache
participant DB as PostgreSQL
C->>LB: GET /api/products/42
LB->>API: Forward request
API->>API: Validate token
API->>R: GET product:42
alt cache hit
R-->>API: Cached product
else cache miss
R-->>API: null
API->>DB: SELECT * FROM products WHERE id = 42
DB-->>API: Row
API->>R: SET product:42 (TTL 5m)
end
API-->>LB: 200 OK JSON
LB-->>C: ResponseAbout this template
Explains what happens when a client calls your API: CDN and load balancer hops, authentication, cache lookups and the database fallback on a cache miss. Great for performance discussions and onboarding backend engineers.
How to customise it
- Add a rate-limiter step
- Add a message queue for async work
- Replace Redis with your cache
This template is a Mermaid sequence diagram. See the sequence diagram page for the full syntax reference and more examples.
Frequently asked questions
How do I use this rest api request lifecycle template?
Click "Use this template" to open it in the MermaidViewer editor. Edit the Mermaid code on the left and the diagram updates instantly. No account is needed.
Can I export the template as an image?
Yes. In the editor use Export to download PNG, SVG or PDF, or copy the image to your clipboard. You can also copy the code as a Markdown block for GitHub, GitLab or Notion.
Can AI customise this template for me?
Yes. Open the AI assistant (Ctrl/Cmd+K) and describe the change, for example "Add a rate-limiter step". The updated diagram streams into the editor.