|
1 | 1 | ---
|
2 |
| -title: 4Point Hoops | AI Basketball Analytics & Insights |
3 |
| -description: Advanced NBA analytics platform that combines live Basketball-Reference data with Perplexity Sonar to deliver deep-dive player stats, cross-season comparisons and expert-grade AI explanations. |
4 |
| -sidebar_position: 2 |
5 |
| -keywords: [nba, basketball, analytics, ai, perplexity, sonar, sports-data, comparisons] |
| 2 | +title: 4Point Hoops | AI Basketball Analytics Platform |
| 3 | +description: Advanced NBA analytics platform that combines live Basketball-Reference data with Perplexity Sonar to deliver deep-dive player stats, cross-season comparisons and expert-grade AI explanations |
| 4 | +sidebar_position: 14 |
| 5 | +keywords: [4point hoops, nba, basketball, analytics, ai, perplexity, sonar, sports-data, comparisons] |
6 | 6 | ---
|
7 | 7 |
|
8 |
| -# 4Point Hoops – AI-Powered NBA Analytics |
9 |
| - |
10 | 8 | 
|
11 | 9 |
|
12 |
| -4Point Hoops turns raw NBA statistics into **actionable, narrative-driven insights**. By scraping Basketball-Reference in real time, cleansing the data and routing context-rich prompts to Perplexity’s *sonar-pro* model, it lets fans, analysts and fantasy players *understand the “why” and “what’s next” – not just the numbers*. |
13 |
| - |
14 |
| -[](https://youtu.be/lThCWq0ij7k) |
15 |
| - |
16 |
| -## What 4Point Hoops Does |
17 |
| - |
18 |
| -- **Player analytics** – season & playoff splits, shot-type breakdowns and performance radar for any NBA player |
19 |
| -- **Cross-era comparisons** – e.g. *Michael Jordan ’97 vs. Stephen Curry ’22* side-by-side, stat-for-stat |
20 |
| -- **Team dashboards** – standings, playoff-probability Sankey flows and KPI tiles that auto-refresh daily |
21 |
| -- **AI Explain & Similar Players** – one-click Sonar explanations of a stat line or AI-picked comparable athletes |
22 |
| -- **Basketball AI Chat** – ask an expert LLM anything about NBA history, rosters or projections |
23 |
| -- **Credit-based SaaS plumbing** – Firebase Auth + Realtime DB manage sign-up, Google login, credit wallets, admin tooling and feedback inbox |
24 |
| - |
25 |
| - |
26 |
| - |
27 |
| -## How It Uses Perplexity Sonar |
28 |
| - |
29 |
| -```python |
30 |
| -# Inline “AI Explain” for a selected player/season |
31 |
| -payload = { |
32 |
| - "model": "sonar-pro", |
33 |
| - "messages": [ |
34 |
| - { |
35 |
| - "role": "user", |
36 |
| - "content": ( |
37 |
| - "Explain Giannis Antetokounmpo's 2021 playoff stats in plain English. " |
38 |
| - "Highlight shooting efficiency and defensive impact." |
39 |
| - ) |
40 |
| - } |
41 |
| - ], |
42 |
| - "response_format": {"type": "text"} |
43 |
| -} |
44 |
| -explanation = client.chat.completions.create(**payload) |
45 |
| - |
46 |
| -# Free-form chat endpoint |
47 |
| -chat = client.chat.completions.create( |
48 |
| - model="sonar-pro", |
49 |
| - messages=[ |
50 |
| - {"role": "system", "content": "You are an NBA analytics expert."}, |
51 |
| - {"role": "user", "content": "Who were the top 5 players in PER last season and why?"} |
52 |
| - ] |
53 |
| -) |
| 10 | +**4Point Hoops** is an advanced NBA analytics platform that turns raw basketball statistics into actionable, narrative-driven insights. By scraping Basketball-Reference in real time and routing context-rich prompts to Perplexity's Sonar Pro model, it helps fans, analysts, and fantasy players understand the "why" and "what's next" – not just the numbers. |
| 11 | + |
| 12 | +<iframe |
| 13 | + className="w-full aspect-video rounded-xl" |
| 14 | + src="https://www.youtube.com/embed/lThCWq0ij7k" |
| 15 | + title="YouTube video player" |
| 16 | + frameBorder="0" |
| 17 | + allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" |
| 18 | + allowFullScreen |
| 19 | +></iframe> |
| 20 | + |
| 21 | +## Features |
| 22 | + |
| 23 | +* **Player Analytics** with season & playoff splits, shot-type breakdowns, and performance radar for any NBA player |
| 24 | +* **Cross-Era Comparisons** enabling side-by-side stat comparisons (e.g., Michael Jordan '97 vs. Stephen Curry '22) |
| 25 | +* **Team Dashboards** with standings, playoff-probability Sankey flows, and auto-refreshing KPI tiles |
| 26 | +* **AI Explain & Similar Players** providing one-click Sonar explanations of stat lines and AI-picked comparable athletes |
| 27 | +* **Basketball AI Chat** allowing users to ask an expert LLM about NBA history, rosters, or projections |
| 28 | +* **Credit-Based SaaS System** with Firebase Auth, Google login, credit wallets, and admin tooling |
| 29 | + |
| 30 | +## Prerequisites |
| 31 | + |
| 32 | +* Node.js 16+ and npm |
| 33 | +* Python 3.8+ and pip |
| 34 | +* Firebase project setup |
| 35 | +* Perplexity API key (Sonar Pro) |
| 36 | +* Basketball-Reference access |
| 37 | + |
| 38 | +## Installation |
| 39 | + |
| 40 | +```bash |
| 41 | +# Clone the frontend repository |
| 42 | +git clone https://github.com/rapha18th/hoop-ai-frontend-44.git |
| 43 | +cd hoop-ai-frontend-44 |
| 44 | +npm install |
| 45 | + |
| 46 | +# Clone the backend repository |
| 47 | +git clone https://github.com/rapha18th/4Point-Hoops-Server.git |
| 48 | +cd 4Point-Hoops-Server |
| 49 | +pip install -r requirements.txt |
54 | 50 | ```
|
55 | 51 |
|
56 |
| -- **Context packing** – the backend injects cleaned, season-filtered DataFrames into the prompt so Sonar reasons over *actual* numbers. |
57 |
| -- **Credit guard** – every AI call passes through `credit_required()` middleware that checks Firebase balance before deducting a point and logging the query. |
| 52 | +## Configuration |
58 | 53 |
|
59 |
| -## Tech Stack |
| 54 | +Create `.env` file in the backend directory: |
| 55 | +```ini |
| 56 | +PERPLEXITY_API_KEY=your_sonar_pro_api_key |
| 57 | +FIREBASE_PROJECT_ID=your_firebase_project_id |
| 58 | +FIREBASE_PRIVATE_KEY=your_firebase_private_key |
| 59 | +FIREBASE_CLIENT_EMAIL=your_firebase_client_email |
| 60 | +``` |
60 | 61 |
|
61 |
| -| Layer | Tech | |
62 |
| -|------------------|----------------------------------------------| |
63 |
| -| Frontend | React + shadcn/ui, Recharts (Netlify deploy) | |
64 |
| -| Backend/API | Python Flask (Hugging Face Spaces) | |
65 |
| -| Data Pipeline | BRScraper → cleanse → Firebase cache | |
66 |
| -| Auth & Storage | Firebase Auth + Realtime Database | |
67 |
| -| AI Integration | Perplexity Sonar-Pro, Pollinations TTS | |
68 |
| -| DevOps | Docker, GitHub Actions | |
| 62 | +## Usage |
69 | 63 |
|
70 |
| -## Links |
| 64 | +1. **Start Backend**: |
| 65 | + ```bash |
| 66 | + cd 4Point-Hoops-Server |
| 67 | + python app.py |
| 68 | + ``` |
| 69 | + |
| 70 | +2. **Start Frontend**: |
| 71 | + ```bash |
| 72 | + cd hoop-ai-frontend-44 |
| 73 | + npm run dev |
| 74 | + ``` |
| 75 | + |
| 76 | +3. **Access Application**: Open the frontend URL and explore NBA analytics with AI-powered insights |
71 | 77 |
|
72 |
| -- **Frontend Repo** – <https://github.com/rapha18th/hoop-ai-frontend-44> |
73 |
| -- **Backend Repo** – <https://github.com/rapha18th/4Point-Hoops-Server> |
74 |
| -- **Live Demo** – <https://4pointhoops.netlify.app/> |
75 |
| -- **Devpost Story** – <https://devpost.com/software/4point-hoops> |
76 |
| -- **Video Walk-through** – <https://youtu.be/lThCWq0ij7k?si=TcLA6oP7nkhjHmjq> |
| 78 | +4. **Use AI Features**: Click "AI Explain" on any player or stat to get intelligent analysis powered by Perplexity Sonar |
| 79 | + |
| 80 | +## Code Explanation |
| 81 | + |
| 82 | +* **Frontend**: React with shadcn/ui components and Recharts for data visualization |
| 83 | +* **Backend**: Python Flask API serving Basketball-Reference data and managing Perplexity API calls |
| 84 | +* **Data Pipeline**: BRScraper for real-time data collection with Firebase caching |
| 85 | +* **AI Integration**: Perplexity Sonar Pro for intelligent basketball analysis and explanations |
| 86 | +* **Authentication**: Firebase Auth with Google login and credit-based access control |
| 87 | +* **Deployment**: Frontend on Netlify, backend on Hugging Face Spaces with Docker |
| 88 | + |
| 89 | +## Links |
77 | 90 |
|
78 |
| -*Built with ❤️ by Rairo Mukamuri.* |
| 91 | +- [Frontend Repository](https://github.com/rapha18th/hoop-ai-frontend-44) |
| 92 | +- [Backend Repository](https://github.com/rapha18th/4Point-Hoops-Server) |
| 93 | +- [Live Demo](https://4pointhoops.netlify.app/) |
| 94 | +- [Devpost Submission](https://devpost.com/software/4point-hoops) |
0 commit comments