|
| 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] |
| 6 | +--- |
| 7 | + |
| 8 | +# 4Point Hoops – AI-Powered NBA Analytics |
| 9 | + |
| 10 | + |
| 11 | + |
| 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 | +) |
| 54 | +``` |
| 55 | + |
| 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. |
| 58 | + |
| 59 | +## Tech Stack |
| 60 | + |
| 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 | |
| 69 | + |
| 70 | +## Links |
| 71 | + |
| 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> |
| 77 | + |
| 78 | +*Built with ❤️ by Rairo Mukamuri.* |
0 commit comments