API Gateway + Rate Limiter
Reverse proxy gateway with per-user sliding window rate limiting
Overview
What this is
A reverse proxy API gateway sitting in front of internal services, handling authentication and rate limiting centrally instead of duplicating that logic across every downstream service.
Problem
Why it needed building
Without a central gateway, every service ends up reimplementing its own auth checks and rate limiting inconsistently — some routes unprotected, quotas untracked, and no unified view of who's hitting the API too hard.
Solution
How it works
JWT authentication middleware validates every request before it reaches a downstream service. A sliding window rate limiter backed by Redis tracks usage per user, with configurable quotas per route and per user tier, returning standard 429 responses with a Retry-After header when limits are exceeded.
Architecture
How it's put together
- →JWT validation middleware sitting at the edge of the gateway, rejecting unauthenticated requests before any downstream call
- →Sliding window rate limiting implemented in Redis for low-latency quota checks under load
- →Per-route, per-user-tier quota configuration instead of one global limit
- →Centralized request logging with per-IP volume tracking in PostgreSQL to flag abuse patterns
Challenges
The hard part
Sliding window rate limiting is deceptively easy to get wrong at the boundary — a naive fixed-window implementation lets a user burst 2x their quota right at the window edge. Redis-backed sliding windows avoid that.
Trade-offs
What I gave up on purpose
Centralizing auth and rate limiting in a gateway adds one more network hop and a single point that must stay highly available, in exchange for removing duplicated, inconsistent logic from every downstream service.
Performance
What changed, measurably
Unauthorized request throughput reduced by 100% via the token validation layer, with abuse patterns now visible through per-IP request volume tracking.
Next
What I'd build next
Add per-route circuit breaking so a struggling downstream service degrades gracefully instead of the gateway continuing to forward requests it can't fulfill.