How chirag-codex/rate-limiter works
RateGuard is a multi-tenant rate-limiting service with a React developer dashboard and an Express API. The main workflow is: a developer registers and signs in, creates a project and obtains its API key, then an integrating service submits a client ID and that key to the public check endpoint. The endpoint validates the project, atomically updates that client’s token bucket, records project counters, and returns an allow/deny result. The dashboard also exposes project management and an endpoint test bench; demo routes provide sample limited endpoints. Arrows reflect shown calls or README-documented relationships; unsampled behavior is not inferred.
Main entry points: App.jsx Dashboard routes · api.js API URL helper · index.js Express API · v1Controller.js Check controller
Components 25
Developer dashboard
- Dashboard routes
client/src/App.jsx - Auth state
client/src/context/AuthContext.jsx - Sign in
client/src/pages/LoginPage.jsx - Registration
client/src/pages/RegisterPage.jsx - Project list
client/src/pages/ProjectsPage.jsx - Project details
client/src/pages/ProjectDetailPage.jsx - Endpoint test bench
client/src/pages/Testendpointpage.jsx - API URL helper
client/src/lib/api.js
API gateway
- Express API
server/src/index.js - Auth routes
server/src/routes/authRoutes.js - Project routes
server/src/routes/projectRoutes.js - Check routes
server/src/routes/v1Routes.js - Demo routes
server/src/routes/demoRoutes.js
Accounts and projects
- Auth controller
server/src/controllers/authController.js - User records
server/src/models/User.js - JWT protection
server/src/middleware/protectRoute.js - Project controller
server/src/controllers/projectController.js - Project records
server/src/models/Project.js
Rate limiting
- Check controller
server/src/controllers/v1Controller.js - Atomic bucket service
server/src/lib/bucketService.js - Token buckets
server/src/models/Bucket.js - Demo limiter
server/src/middleware/rateLimiter.js - Client ID validation
server/src/lib/validateClientId.js
Other components
- Developer
- Integrating service
Connections 32
- Developer → Dashboard routes: uses
- Dashboard routes → Sign in: routes to
client/src/App.jsx - Dashboard routes → Registration: routes to
client/src/App.jsx - Dashboard routes → Project list: routes to
client/src/App.jsx - Dashboard routes → Project details: routes to
client/src/App.jsx - Dashboard routes → Endpoint test bench: routes to
client/src/App.jsx - Sign in → Auth state: updates
client/src/pages/LoginPage.jsx - Registration → Auth state: updates
client/src/pages/RegisterPage.jsx - Sign in → API URL helper: requests via
client/src/pages/LoginPage.jsx - Registration → API URL helper: requests via
client/src/pages/RegisterPage.jsx - Project list → API URL helper: requests via
client/src/pages/ProjectsPage.jsx - Project details → API URL helper: requests via
client/src/pages/ProjectDetailPage.jsx - Endpoint test bench → API URL helper: requests via
client/src/pages/Testendpointpage.jsx - API URL helper → Express API: sends HTTP
- Express API → Auth routes: mounts
server/src/index.js - Express API → Project routes: mounts
server/src/index.js - Express API → Check routes: mounts
server/src/index.js - Express API → Demo routes: mounts
server/src/index.js - Auth routes → Auth controller: dispatches
server/src/routes/authRoutes.js - Project routes → Project controller: dispatches
server/src/routes/projectRoutes.js - Project routes → JWT protection: applies
server/src/routes/projectRoutes.js - Auth controller → User records: reads and writes
server/src/controllers/authController.js - Project controller → Project records: reads and writes
server/src/controllers/projectController.js - Project controller → Token buckets: deletes buckets
server/src/controllers/projectController.js - Check routes → Check controller: dispatches
server/src/routes/v1Routes.js - Integrating service → Check controller: submits check
README.md - Check controller → Project records: validates key; updates counts
server/src/controllers/v1Controller.js - Check controller → Atomic bucket service: checks limit
server/src/controllers/v1Controller.js - Atomic bucket service → Token buckets: atomically updates
server/src/lib/bucketService.js - Demo routes → Demo limiter: applies limits
server/src/routes/demoRoutes.js - Demo limiter → Atomic bucket service: uses
server/src/middleware/rateLimiter.js - Demo limiter → Client ID validation: uses
server/src/middleware/rateLimiter.js