James Chang / Work / The Fantastic Leagues / Under the hood

Static snapshot of the in-app /tech page (admin-only inside the app) as of April 2026. Public marketing site is at thefantasticleagues.com.

Fantastic Leagues · Tech / Under the hood · Last Updated

How the whole thing is built.

Six months, 62 development sessions, 730 passing tests. The Fantastic Leagues is a fantasy baseball platform with live auction WebSockets, 8 AI features, and 15 years of historical league data imported from Excel.

By the numbers

84,400+total lines of code
26feature modules
49database models
228API route handlers
730tests passing
470+git commits
62build sessions
8AI-powered features

Splits: 44,500 lines client-side (React + Vite), 39,900 server-side (Express + Prisma), 1,370 MCP server. Test coverage: 12,900+ lines of tests (473 server + 187 client + 50 MCP = 730 passing). Database schema: 1,131 lines across 15 migrations.

Architecture

Browser (React + Vite) ──REST /api/*──▶ Express API (:4010) ──ws://auction─▶ WebSocket ──Session tokens─▶ Supabase Auth API ──Prisma ORM──▶ PostgreSQL (Supabase) API ──JWT verify──▶ Supabase Auth API ──Player data──▶ MLB Stats API API ──Shared cache──▶ MCP MLB Proxy (SQLite) API ──AI analysis──▶ Google Gemini 2.5 Flash API ──AI fallback──▶ Anthropic Claude Sonnet 4 API ──Invite emails──▶ Resend MCP ──Cached requests──▶ MLB Stats API WS ──Auction state──▶ API

Tech stack

Frontend

React 18, TypeScript, Vite, Tailwind CSS, React Router v6, Lucide React, Radix UI, Headless UI, dnd-kit, PostHog

Backend

Node.js + Express, TypeScript (ESM), Prisma ORM, Zod, Helmet, express-rate-limit, Multer, node-cron, WebSocket (ws), web-push

Database & Auth

PostgreSQL (Supabase), Supabase Auth, Supabase JS Client, bcryptjs, jsonwebtoken

Data & Integrations

MLB Stats API, MCP MLB Data Proxy, Google Gemini 2.5 Flash, Anthropic Claude Sonnet 4, Resend, xlsx, csv-parse, better-sqlite3

Testing & Quality

Vitest, React Testing Library, Supertest, ESLint — 730 tests (473 server + 187 client + 50 MCP), 0 failures

Infrastructure

Railway (API + MCP), GitHub Pages (marketing), Cloudflare (DNS + CDN), Supabase (DB + auth), PostHog Cloud

26 feature modules

Each module follows an identical pattern: actions/, components/, types/, schemas/, store/, index.ts barrel. Both client and server mirror the same 26-module split.

auth — login, signup, password reset, Google OAuth

leagues — league CRUD, rules configuration

teams — management, roster views

players — search, stats, 1,652 players synced daily

roster — grid, controls, bulk import

standings — live category tracking

trades — proposal flow with voting

waivers — FAAB bidding, priority order

transactions — full history with audit

auction — live WebSocket draft, 50+ concurrent

keeper-prep — selection + AI recommendations

commissioner — league admin tools

seasons — lifecycle management

admin — system-level operations

archive — 17 years of historical data

periods — stat periods, season views

franchises — ownership history

mlb-feed — live stats integration

board — league message board

community — cross-league feed

chat — real-time auction chat

notifications — push + email

draft — full draft lifecycle

matchups — H2H scoring engine

profiles — user accounts

+ mcp-proxy — shared cache server

Build journal

Six months, 62 sessions. Grouped here into themes.

Nov 2025 · S1–2
Scaffolding — Vite + Express + Prisma, Supabase auth, 10 initial models
Dec 2025 · S3–6
Core features — teams, rosters, player search, standings engine
Jan 2026 · S7–10
The hard stuff — live auction WebSocket, trade proposals, FAAB waivers, commissioner tools
Feb 2026 · S11–14
Archive & design — 17 years of Excel parsing, design system overhaul, file-naming cleanup
Mar 2026 · S15–20
Hardening — season lifecycle, franchise refactor, +116 new tests, service extraction
Mar 2026 · S21–23
Polish & auth — 6-agent code review, password reset, Google OAuth, Resend SMTP, MCP proxy (644 tests)
Mar 2026 · S24–25
Live data & auction prep — live standings, all-team MLB sync, 4 test leagues prepped (670 tests)
Mar 2026 · S26–27
Stats & code review — 2025 player stats, auction bid tracking, 6-agent review (660 tests)
Mar 2026 · S28–33
Meta pages, analytics, production — /changelog /status /analytics, tech-debt cleanup, production deployment (710 tests)

Live screenshots

The Fantastic Leagues marketing site home page

The public marketing site at thefantasticleagues.com.

Home dashboard with live standings and team overview

Home dashboard — live standings, team roster preview, recent activity feed.

Live auction draft in dark mode showing nomination and bidding

Live auction draft — WebSocket-driven, supports 50+ concurrent bidders.

Player stats table with search and filtering

Player stats — MLB Stats API feed, MCP proxy with SQLite cache.

Team page with AI-generated insights

Team page with AI insights — Google Gemini primary, Claude Sonnet fallback.

← Aleph changelog