Request Path
Layer sequence
Consumer → Edge API Gateway Worker → Plugin chain (auth, rate-limit, transform) → Upstream API → Response transform → ConsumerWithin a Worker
route → handler → service → repository → D1 / KV- Route: HTTP path + method wiring only
- Handler: validate input, call service, return JSON
- Service: business logic and orchestration
- Repository: Drizzle queries against D1 or KV reads
Inter-service calls
Workers call each other using trust-kit HMAC-signed internal requests over fetch(). No public internet hop.
Auth flow
- Consumer sends
Authorization: Bearer <api-key> - Gateway verifies key against
core-platformKV cache - On miss, calls
core-platform/internal/api-keys/verify - Result is cached in KV with 60s TTL