How adityass2004/load-balancer works
TrackIt is a project-aware reverse proxy and dynamic load balancer, with administrative tools for configuring projects and servers and viewing operational data. The main runtime flow accepts a client request, applies middleware and rate limits, resolves project and backend state, selects and forwards to an upstream, then records request data. Separate branches cover project administration, health monitoring, and analytics/logging. Some UI, health, and persistence connections are documented only broadly or were not sampled; those links are omitted or marked unverified rather than inferred as calls.
Main entry points: route.ts Proxy Handler · CacheService.ts Runtime Cache · RetryService.ts Retry Orchestrator · project.service.ts Project Service
Components 21
Proxy Runtime
- Request Middleware
middleware.ts - Proxy Handler
app/api/[...path]/route.ts - Rate Limiter
lib/rate-limit/index.ts - Runtime Cache
services/cache/CacheService.ts - Backend Selector
services/load-balancer/ServerSelector.ts - Retry Orchestrator
services/load-balancer/RetryService.ts - Request Forwarder
services/load-balancer/RequestForwarder.ts
Administration
- Admin Dashboard
app/(dashboard)/dashboard/page.tsx - Server Actions
actions/server.actions.ts - Server Service
services/server.service.ts - Project API
app/api/admin/projects/route.ts - Project Service
services/project.service.ts
Operations
- Health Monitoring
services/health/HealthScheduler.ts - Analytics Service
services/analytics/AnalyticsService.ts - Request Logging
services/logging/LogQueue.ts
Persistence
- Project Repository
repositories/project.repository.ts - Server Repository
repositories/server.repository.ts - Settings Repository
repositories/settings.repository.ts
Other components
- External Client
- Backend Servers
- PostgreSQL
Connections 21
- External Client → Request Middleware: sends request
- Request Middleware → Proxy Handler: passes request
- Proxy Handler → Rate Limiter: checks limits
app/api/[...path]/route.ts - Proxy Handler → Runtime Cache: resolves project
app/api/[...path]/route.ts - Proxy Handler → Retry Orchestrator: dispatches request
app/api/[...path]/route.ts - Retry Orchestrator → Backend Selector: selects backend
services/load-balancer/RetryService.ts - Retry Orchestrator → Request Forwarder: forwards attempt
services/load-balancer/RetryService.ts - Request Forwarder → Backend Servers: sends request
- Retry Orchestrator → Request Logging: enqueues log
services/load-balancer/RetryService.ts - Admin Dashboard → Server Actions: manages servers
- Server Actions → Server Service: invokes service
actions/server.actions.ts - Server Service → Server Repository: reads and writes
services/server.service.ts - Project API → Project Service: invokes service
app/api/admin/projects/route.ts - Project Service → Project Repository: reads and writes
services/project.service.ts - Project Service → Settings Repository: creates settings
services/project.service.ts - Runtime Cache → Project Repository: loads projects
services/cache/CacheService.ts - Runtime Cache → Server Repository: loads servers
services/cache/CacheService.ts - Runtime Cache → Settings Repository: loads settings
services/cache/CacheService.ts - Health Monitoring → PostgreSQL: persists health
- Analytics Service → PostgreSQL: queries metrics
- Request Logging → PostgreSQL: persists logs