A natural language to SQL web app for exploring historical NBA statistics. Type plain-English questions like "Who averaged the most points in 2022-23?" and get real data back — with charts.
- You type a question in natural language
- The AI (Llama 3.3 70B via Groq) translates it into a SQL query
- The query runs against a local SQLite database of NBA stats
- Results are displayed as a table and auto-generated chart
| Layer | Technology |
|---|---|
| Frontend | React, Vite, Tailwind CSS, Recharts |
| Backend | FastAPI (Python) |
| Database | SQLite |
| Data Source | nba_api (NBA.com) |
| AI | Llama 3.3 70B via Groq API |
- Seasons: 2015-16 through 2023-24
- Players: ~1,350 with per-game season averages (points, assists, rebounds, shooting splits, etc.)
- Teams: All 30 NBA teams with season records, ratings, and pace
- Records: ~4,800 player-season stats, ~270 team-season stats
- Python 3.10+
- Node.js 20+
- Free Groq API key
cd backend
pip install -r requirements.txt
# Fetch NBA data (~5 min, only needed once)
python seed/fetch_data.py
# Seed the SQLite database
python seed/seed_db.py
# Start the API server
uvicorn main:app --reloadcd frontend
npm install
npm run devCopy .env.example to .env and add your Groq API key:
GROQ_API_KEY=gsk_your_key_here
LeBron James stats by season — multi-season breakdown with chart and full stat table:
Compare Jokic and Embiid — side-by-side player comparison:
- "Who averaged the most points per game in 2022-23?"
- "Show me LeBron's scoring average by season"
- "Which team had the best net rating in 2017-18?"
- "Best 3PT shooters with 60+ games in 2023-24"
- "Warriors win/loss record from 2015 to 2019"
- "Compare Jokic and Embiid last season"
├── backend/
│ ├── main.py # FastAPI app with /query endpoint
│ ├── ai.py # Groq API integration (NL → SQL)
│ ├── database.py # SQLite query executor
│ ├── schema.sql # Database schema (injected into AI prompt)
│ └── seed/ # Data pipeline (fetch + seed scripts)
├── frontend/
│ └── src/
│ ├── App.jsx # Main layout and state management
│ ├── api.js # Backend API client
│ └── components/
│ ├── QueryInput.jsx # Search bar with typewriter effect
│ ├── ResultsTable.jsx # Dynamic data table
│ ├── ResultsChart.jsx # Auto-generated bar charts
│ ├── QueryHistory.jsx # Collapsible sidebar history
│ ├── EmptyState.jsx # Landing page with example queries
│ ├── ErrorState.jsx # Error display
│ └── LoadingSkeleton.jsx
└── nba.db # SQLite database (generated, gitignored)
- Only
SELECTqueries are allowed —INSERT,DROP,ATTACH, etc. are blocked - Server-side row limit (100 max) regardless of AI output
- User input truncated to 500 characters
- SQL injection patterns detected and rejected
MIT


