Sim Racing Team Platform
A production-grade orchestration engine spanning 43,000+ lines of code. The digital nervous system for a competitive sim racing team — binding a Next.js Web Platform with a Python Discord Bot via real-time WebSockets.
Upstash, Discord.py
Core Architecture
Three OAuth Flows. Two Databases. One Bridge.
Triple OAuth
Discord OAuth for identity. iRacing via custom PKCE S256 (321 lines, hand-written code verifier/challenge). Garage61 OpenID Connect with slug resolution and fallback chain.
3 token lifecycles managedDual-Database Layer
Turso (LibSQL) for persistent relational data. Upstash Redis for cache, sessions, rate limiting. Backend-agnostic abstraction — dbGet/dbSet/dbDel works against either engine transparently.
Sub-10ms edge queriesWebSocket Bridge
Python Discord bot on dedicated on-premise server maintains persistent WSS to cloud backend. Authenticated handshake, event-driven broadcasts, bi-directional state mutations.
Real-time syncSystem Topology
Three-tier architecture with real-time bidirectional synchronization
System Depth
264 TypeScript files. 145 API routes. 24 migration scripts. Every feature hand-built.
14 Cron Jobs
Vercel-scheduled sync pipeline: iRacing stats, Garage61 laps, weekly schedules, subscription audits, cache warming — all auth-protected with admin-visible sync logs.
Granular RBAC
Owner/Admin/Member/Guest roles with 6 admin panels, cup/gallery/league editors, and dynamic Discord-role-to-site-access mapping.
Endurance Race Planner
Multi-timezone stint scheduling with iRating-based matching, Garage61 car ownership verification, spotter slot management, and captain assignment.
Gallery Pipeline
3-tier image processing: Sharp resize → WebP conversion → Base64 Turso storage. Thumbnail + Optimized + Original with photographer attribution.
i18n (TR/EN)
Full bilingual support via next-intl. Every UI string, error message, and notification localized across Turkish and English.
DM Queue System
Web → KV → WSS → Discord Bot → DM. Asynchronous notification pipeline ensuring messages reach pilots regardless of which interface they use.
The Challenge
Coordinating 50+ pilots across time zones for 24-hour endurance races in iRacing. Tracking registrations, verifying iRating limits, collecting Garage61 telemetry, and broadcasting schedule updates — all scattered across disconnected tools and manual spreadsheets.
Three separate OAuth providers with completely different auth flows. An external Discord bot that needed to stay perfectly synchronized with the web state. API rate limits from iRacing that could brick the entire sync pipeline.
The Solution
A centralized orchestration nucleus. The Next.js platform acts as the single source of truth, with Turso handling persistent state and Redis providing a 95% API-call-saving cache layer against rate-limited external services.
The Python bot operates as a stateful node — not a passive notification sink. Users execute management tasks from whichever interface they prefer. Data is instantly verified, cached, and synced globally through the WebSocket bridge.