RateGuard: Distributed Rate Limiter with Redis, Lua and an AI Policy Advisor

Over nine phases you build RateGuard like a professional team: requirements and threats, design with ADRs, a test-first implementation of a token bucket and a sliding window counter as pure functions and as atomic Redis Lua scripts that use one clock, a Redis Cluster-ready key layout with hash tags, tenants with SHA-256 hashed API keys and a constant-time admin token, the standard rate-limit headers and Retry-After, per-minute usage statistics and an AI policy advisor with an offline fallback, integration tests that race parallel requests for the last token, CI/CD with GitHub Actions, Docker, optional free-tier deployment, a game day that freezes Redis, a circuit breaker with per-tenant fail modes, observability and a retrospective. Pick Java, Python or TypeScript; the spec, the Lua scripts and the tests are shared. Everything runs on your laptop, and the AI feature works offline.

advancedJavaPythonTypeScriptSpring BootFastAPIFastifyRedisLuaDockerGitHub ActionsOpenAPISHA-256

What you will build, step by step

  1. Phase 0 · Setup and orientation
  2. Phase 1 · Requirements, threats and user stories
  3. Phase 2 · Design: algorithms, Lua scripts, key layout, failure policy, API contract
  4. Phase 3 · Implementation in five milestones
  5. Phase 4 · Testing: Lua parity, concurrency across instances, security, coverage gate
  6. Phase 5 · Continuous integration with GitHub Actions
  7. Phase 6 · Containerise, deliver and (optionally) deploy
  8. Phase 7 · Observability, game day and resilience (v1.1.0)
  9. Phase 8 · Retrospective and portfolio