Hoop Almanac
Fantasy basketball analytics platform with ML predictions and live multiplayer drafts
Overview
Role
Solo Developer
Team
Solo
Timeline
Ongoing
Stack
16 technologies
Achieved sub-100ms p95 real-time draft synchronization for 150+ concurrent users with zero duplicate picks using WebSocket event-sourcing with optimistic UI and rollback.
The Problem
Situation
Fantasy basketball players rely on gut instinct or basic stats to draft players. I wanted to explore whether machine learning could provide a competitive edge in NBA fantasy—something I am passionate about.
My Goal
Build a fantasy basketball analytics platform with ML-powered predictions and real-time multiplayer draft functionality.
My Approach
Architected ETL pipelines to normalize NBA player data into PostgreSQL
Engineered 50+ features to power custom XGBoost and Scikit-learn predictive models
Built low-latency multiplayer draft rooms using WebSockets
Created complex data visualizations synchronized across concurrent users
Integrated pgvector for similarity search on player stats
The Outcome
Achieved sub-100ms p95 real-time draft synchronization for 150+ concurrent users with zero duplicate picks using WebSocket event-sourcing with optimistic UI and rollback.
Eliminated AI hallucination of player statistics by building a RAG pipeline (pgvector + GPT-4 tool use) across 5 assistants, cutting follow-up latency from 3.5s to under 1.5s via three-layer caching.
Chose gradient boosting over deep learning for 12 prediction models after evaluating the tabular data domain — trained in seconds on CPU, served in milliseconds via FastAPI, with SHAP explainability.
Built an idempotent data pipeline ingesting 40+ NBA API endpoints with retry and upsert conflict resolution; daily sync completes in under 2 minutes.
Project Roadmap
MVP, stretch goals, and future vision
Project Roadmap
Development phases and milestones
Fantasy Analytics Core
ML-powered player predictions and draft tools
Player Prediction Engine
XGBoost models for player performance forecasting
Draft Assistant
Real-time draft recommendations with live updates
Player Comparison Tool
Side-by-side player analysis with visualizations
Advanced Analytics
Trade analysis, lineup optimization, predictions game, and AI features
Trade Analyzer
Evaluate trade proposals using prediction models
Lineup Optimizer
AI-powered optimal lineup suggestions
Predictions & Leaderboard
User predictions game with scoring and rankings
AI Draft Companion
Real-time AI chat during live drafts
Machine Learning Enhancements
Continued development of ML models and prediction accuracy improvements
Model Improvements
Ongoing refinement of prediction models
Interview Questions
Common questions, answered in STAR format
Technical Decisions
Why I chose X over Y
Key Trade-offs
Every decision has costs
Challenges & Solutions
The hardest problems I solved
Code Highlights
Key sections I'd walk through in a code review
WebSocket state reconciliation
src/lib/draft/syncProtocol.tsHandles the bi-directional sync between clients and server. Clients send state hashes, server compares and pushes full state if mismatch. Includes sequence numbers to detect and handle out-of-order messages.
Feature engineering pipeline
ml/features/engineer.pyTakes raw NBA stats and computes 50+ features: rolling averages, opponent adjustments, rest days, home/away splits, usage rate when teammates are out, etc. Each feature is documented with its predictive value.
What I Learned
- →Real-time features need disconnection handling - design for it
- →Server must be source of truth for multi-user state
- →ML models drift - build retraining and monitoring in
- →Test WebSocket features with multiple mock clients
- →Test race conditions explicitly
- →Row Level Security ensures auth at database level
- →Supabase Realtime handles WebSocket complexity
- →Log predictions vs actuals for ML evaluation
Future Plans
- +Add trade analysis - evaluate proposed trades using the same prediction models
- +League history and trophy case for multi-season engagement
- +Auction draft support in addition to snake draft
- +Integration with ESPN/Yahoo for roster sync
- +Mobile app with push notifications for draft turns
Next project
Kevin Lam Portfolio
Want to discuss this project?