Sequence Diagramapisequencearchitecture
API Request Sequence
Use this Mermaid sequence diagram to explain how a client request moves through gateway, auth, services, cache, and database layers.
Use Cases
Show request and response order during an API review
Document auth checks and cache lookup behavior
Align frontend and backend teams on integration timing
Explain alternate paths such as cache hits, cache misses, retries, and downstream failures
How This Workflow Works
| Step | Purpose |
|---|---|
| Client request | Begins the interaction when the client sends a request to the gateway or API boundary. |
| Token validation | Shows the authentication check that must succeed before the request reaches business logic. |
| Route to service | Moves the valid request from the gateway to the domain service responsible for the work. |
| Cache lookup | Branches the sequence between fast cached responses and slower database-backed responses. |
| Return response | Completes the sequence by sending the assembled service response back through the gateway. |
How To Customize
Rename participants to match your services
Add alternate paths for errors, retries, or cache misses
Change messages to the real method names or API endpoints
Add latency, timeout, or ownership notes to calls that are important during incident review
Split one domain service into multiple participants when the integration spans several teams
Edit This Template Visually
Open this template in the editor to work from the rendered diagram and the Mermaid source together. Click a node in supported flowchart and sequence diagrams to locate the matching code, select source lines to find the related shape, or ask AI to rename, expand, restyle, or rewrite the selected part of the workflow.
Mermaid Source
sequenceDiagram
participant Client
participant Gateway as API Gateway
participant Auth as Auth Service
participant Service as Domain Service
participant Cache
participant DB as Database
Client->>Gateway: Send request
Gateway->>Auth: Validate token
Auth-->>Gateway: Token valid
Gateway->>Service: Route request
Service->>Cache: Read cached result
alt Cache hit
Cache-->>Service: Return cached data
else Cache miss
Service->>DB: Query records
DB-->>Service: Return records
Service->>Cache: Store result
end
Service-->>Gateway: Build response
Gateway-->>Client: Return response