Request Flow
Version: 1.0
Status: Approved
Last updated: 2026-07-06
Overview
All client applications communicate with backend services through a single API Gateway. Nginx terminates TLS and routes path prefixes to the correct container. The gateway validates authentication, applies rate limits, and proxies to the target microservice.
System diagram
HTTP request lifecycle
- Client sends request to
/api/v1/{service}/{resource} - Nginx routes
/api/*to API Gateway container - Gateway assigns
X-Request-Idfor correlation - Rate limiter checks Redis sliding window per IP/user
- JWT middleware validates Bearer token (public routes exempt)
- Proxy forwards to target service with identity headers
- Service runs guards, validation, use case, repository
- Response returns through gateway with consistent error envelope
Path routing (Nginx)
| Path prefix | Target |
|---|---|
/ | Website (Next.js) |
/helpdesk/ | HelpDesk SaaS |
/analytics/ | Analytics Dashboard |
/admin/ | Admin Portal |
/chat/ | Realtime Chat |
/api/ | API Gateway |
/socket.io/ | WebSocket upgrade via Gateway |
Observability
| Signal | Implementation |
|---|---|
| Request ID | X-Request-Id header propagated via @novadesk/logger |
| Metrics | Prometheus /metrics on each service |
| Health | /health and /health/ready endpoints |
| Logs | Structured JSON (Pino) with correlation |
Error handling
Gateway normalizes error responses:
| Status | Meaning |
|---|---|
| 401 | Missing or invalid JWT |
| 403 | Valid token, insufficient role |
| 429 | Rate limit exceeded |
| 502 | Upstream service unavailable |
| 504 | Upstream timeout |