Production-grade rate limiter and async job queue built from scratch — 1000+ req/s, no Redis, no Celery.
FlowGuard implements two critical backend infrastructure components using only Python standard library data structures:
| Component | Implementation | Complexity |
|---|---|---|
| Sliding Window Rate Limiter | collections.deque |
O(1) amortized |
| Priority Job Queue | heapq with worker threads |
O(log n) |
Key Specs:
- 1000+ req/s on a single Flask instance
- Exponential backoff — failed jobs retry: 1s → 2s → 4s
- Thread-safe —
threading.Lock()+Conditionon all shared state - MongoDB persistence — best-effort sync every 30s, works without DB (graceful degradation)
- Real-time dashboard — React + recharts, auto-refresh every 5s
React Dashboard (Vercel) ── fetch/5s ──→ Flask API (Render)
├── Sliding Window Rate Limiter (deque)
├── Priority Job Queue (heapq + worker threads)
└── MongoDB Atlas (optional persistence)
| Component | Technology |
|---|---|
| Backend | Python 3.11+, Flask |
| Rate Limiter | collections.deque (O(1)) |
| Job Queue | heapq (O(log n)) + threading |
| Database | MongoDB Atlas (optional) |
| Dashboard | React + recharts |
| Deployment | Docker, Render + Vercel |
I selected the sliding window algorithm over token bucket, designed the thread synchronization strategy, and planned the graceful degradation model (works with or without MongoDB). Code generation was accelerated using AI tools; algorithm selection, concurrency design, and debugging are mine.
git clone https://github.com/AdityaPandey-DEV/flowguard.git && cd flowguard cp .env.example .env # Add MongoDB URI docker-compose up # Or: cd backend && python app.py
Architected & built by Aditya Pandey — AI-augmented development