Request Lifecycle
Every API request follows the same path: authenticate, validate, authorize, execute.
Steps
-
API Gateway receives the request and forwards the JWT or API key to the Lambda authorizer.
-
Lambda Authorizer resolves the caller's identity from DynamoDB and returns a context with
principalId,scopeId, and permissions. -
Handler validates the request body, path, and query params against a DTO. If validation fails, returns 400.
-
Authorization —
requirePermission(resource, action)checks that the caller has the required permission in the target scope. If not, returns 403. -
Service executes the business logic. Repositories handle data access. Domain entities enforce invariants.
-
Response is returned to the client. Audit events and webhooks fire asynchronously — they don't add latency to the response.