Case Study
BetPlatform
Enterprise betting platform backend demonstrating production-grade patterns: edge security, real-time data, and auth infrastructure.
In ProgressOverview
Full-stack betting platform built to demonstrate enterprise-grade backend patterns including authentication flows, real-time communication, edge-based geoblocking, and scalable data access. Designed as a reference architecture for high-traffic transactional systems.
Architecture
Monorepo managed with pnpm workspaces, separating concerns cleanly across three packages:
- apps/apiFastify + TypeScript + Prisma — core business logic, auth, WebSocket server
- apps/webNext.js frontend — server-rendered UI consuming the API
- cloudflare/geo-workerCloudflare Worker — edge geoblocking before requests reach origin
Technical Decisions
Fastify over Express
Schema-based validation, faster JSON serialization, and built-in TypeScript support reduce boilerplate and improve throughput under load.
JWT refresh token rotation
Short-lived access tokens with single-use refresh tokens minimize exposure window on token theft. Revocation tracked in Redis.
Geoblocking at the edge
Cloudflare Worker intercepts requests before they reach origin, enforcing jurisdictional restrictions with zero latency penalty on allowed traffic.
Redis for session cache
Offloads active session lookups from PostgreSQL, keeping auth middleware latency under 5ms at scale.
WebSockets for real-time odds
Persistent connections push odds updates server-to-client, eliminating polling overhead and keeping UI state consistent.
Responsible gambling features
Session timeout enforcement terminates idle sessions after a configurable inactivity window. Self-exclusion endpoint allows users to lock their account for a defined period, enforced at the middleware layer. Deposit limit logic caps daily/weekly spend at the API level, with limits stored per-user and evaluated before any transaction is processed.
Status
In ProgressBackend architecture complete. Currently implementing WebSocket real-time feed and Cloudflare Worker geoblocking.
Stack