REST API call sequence diagram
An app calling a REST API through a gateway, auth server, service and database. An opt box covers refreshing an expired token.
The diagram
Reading it step by step
- [opt: Token expired]
- 1. 'App' sends a request to 'Auth server': 'Refresh token'.
- 2. 'Auth server' replies to 'App': 'New token'.
- 3. 'App' sends a request to 'API gateway': 'GET orders'.
- 4. 'API gateway' sends a request to 'Auth server': 'Verify token'.
- 5. 'Auth server' replies to 'API gateway': 'Valid'.
- 6. 'API gateway' sends a request to 'Order service': 'Forward'.
- 7. 'Order service' sends a request to 'Database': 'Query'.
- 8. 'Database' replies to 'Order service': 'Rows'.
- 9. 'Order service' replies to 'API gateway': 'Order list'.
- 10. 'API gateway' replies to 'App': '200 response'.
Shape by shape
| Shape | Symbol | Connections |
|---|---|---|
| App | Participant and lifeline | → Auth server(Refresh token), API gateway(GET orders) · ← Auth server, API gateway |
| API gateway | Participant and lifeline | → Auth server(Verify token), Order service(Forward), App(200 response) · ← App, Auth server, Order service |
| Auth server | Participant and lifeline | → App(New token), API gateway(Valid) · ← App, API gateway |
| Order service | Participant and lifeline | → Database(Query), API gateway(Order list) · ← API gateway, Database |
| Database | Participant and lifeline | → Order service(Rows) · ← Order service |
Symbols used here
| Symbol | Meaning |
|---|---|
| Participant and lifeline | A box on top and a dashed line below. |
| Synchronous message | A call that waits; solid line, filled head. |
| Reply | The answer; dashed line, open head. |
| Combined fragment | loop, alt and opt boxes. |
Diagram text
Paste this text into the editor to get the same picture, then change the names to fit your own work.
# REST API call sequence diagram
sequenceDiagram
participant App
participant G as API gateway
participant Auth as Auth server
participant Svc as Order service
participant DB as Database
opt Token expired
App->>Auth: Refresh token
Auth-->>App: New token
end
App->>G: GET orders
G->>Auth: Verify token
Auth-->>G: Valid
G->>Svc: Forward
Svc->>DB: Query
DB-->>Svc: Rows
Svc-->>G: Order list
G-->>App: 200 response