Analyze NFL game momentum through play-by-play data visualization.
- Event-based momentum calculation - Touchdowns, turnovers, sacks, and big plays all contribute to momentum shifts
- Interactive charts - Visualize momentum swings throughout the game
- Shareable links - Create links to share momentum graphs with others
- Export options - Download as PNG or SVG
- Backend: Python + FastAPI
- Frontend: SvelteKit + TailwindCSS + Chart.js
- Database: PostgreSQL
- Data Source: nflfastR via nfl_data_py
- Python 3.10+
- Node.js 18+
- PostgreSQL 14+
cd backend
# Create virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install dependencies
pip install -r requirements.txt
# Copy environment file and configure
cp .env.example .env
# Edit .env with your database credentials
# Run the server
uvicorn app.main:app --reloadcd frontend
# Install dependencies
npm install
# Run dev server
npm run devcd backend
# Load a specific season
python -m app.scripts.backfill --seasons 2024
# Or load last 5 years
python -m app.scripts.backfill --all-recentGET /api/games/seasons- Get available seasons and weeksGET /api/games/{season}/{week}- Get games for a weekGET /api/games/game/{game_id}- Get game details
GET /api/momentum/{game_id}- Get momentum dataGET /api/momentum/{game_id}/export/png- Download PNGGET /api/momentum/{game_id}/export/svg- Download SVG
POST /api/share/{game_id}- Create share linkGET /api/share/{share_code}- Get shared graph
The momentum score is calculated based on play-by-play events:
| Event | Points |
|---|---|
| Passing/Rushing TD | +15 |
| Defensive/Return TD | +25 |
| Interception | +12 |
| Fumble Lost | +10 |
| Sack | +5 |
| 4th Down Conversion | +5 |
| 4th Down Stop | +6 |
| Explosive Play (20+ yds) | +6 |
| Safety | +15 |
Decay: Momentum loses ~8% per play to reflect recency Streak Bonus: Consecutive positive events multiply momentum (up to 1.5x)
- Create a new Railway project
- Add PostgreSQL database
- Deploy backend from GitHub
- Set
DATABASE_URLfrom Railway's PostgreSQL
- Import repository to Vercel
- Set root directory to
frontend - Add environment variable
VITE_API_URLpointing to Railway backend
MIT