GATEWAY
API Gateway
A single, hardened front door for money-movement APIs, built on YARP.
- Client
- Auth policy
- Rate limit (Redis)
- Resilience pipeline
- Service cluster
The problem
// ContextServices were exposed with inconsistent authentication and per-instance rate limiting. A gateway had to protect money-movement routes under load spikes without retrying anything unsafe.
Approach
// What I built- YARP chosen over alternatives for raw throughput on the hot routes.
- Three authentication schemes (end-user JWT, internal service JWT, partner API key) selected per route by authorization policy.
- Redis-backed rate limiting coordinated across gateway replicas; Redis is a hard dependency that fails fast at startup.
- A Polly pipeline per cluster: bulkhead, timeout, circuit breaker and optional retry. Retries are never enabled on money routes.
- Correlation IDs, security headers, CIDR-gated internal routes and config-toggled routes.
Decisions and trade-offs
// Why it is built this wayYARP instead of Ocelot
Chosen for raw throughput on money-movement routes during load spikes.
Redis-backed rate limiting
Per-instance in-memory limits cannot be coordinated across replicas, so a client could multiply its allowance by the replica count.
No retries on money routes
A retry after a timeout can post the same transfer twice.
One project, no MediatR
A proxy has no business logic to protect, so extra layers would add ceremony without benefit.
Outcomes
// Result- A clear, documented decision record for the gateway choice.
- Safe-by-default behaviour: no silent degradation and no double-posting from retries.