From a48a62c687a235943cd528c43672e76d85addd30 Mon Sep 17 00:00:00 2001 From: Rairo Mukamuri Date: Fri, 8 Aug 2025 16:22:19 +0200 Subject: [PATCH 1/2] Create 4point-Hoops.mdx 4point Hoops perplexity showcase. --- docs/showcase/4point-Hoops.mdx | 78 ++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 docs/showcase/4point-Hoops.mdx diff --git a/docs/showcase/4point-Hoops.mdx b/docs/showcase/4point-Hoops.mdx new file mode 100644 index 0000000..30459a8 --- /dev/null +++ b/docs/showcase/4point-Hoops.mdx @@ -0,0 +1,78 @@ +--- +title: 4Point Hoops | AI Basketball Analytics & Insights +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. +sidebar_position: 2 +keywords: [nba, basketball, analytics, ai, perplexity, sonar, sports-data, comparisons] +--- + +# 4Point Hoops – AI-Powered NBA Analytics + +![4Point Hoops Dashboard](https://d112y698adiu2z.cloudfront.net/photos/production/software_photos/003/442/047/datas/original.png) + +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*. + +[![Demo Video](https://img.youtube.com/vi/lThCWq0ij7k/hqdefault.jpg)](https://youtu.be/lThCWq0ij7k) + +## What 4Point Hoops Does + +- **Player analytics** – season & playoff splits, shot-type breakdowns and performance radar for any NBA player +- **Cross-era comparisons** – e.g. *Michael Jordan ’97 vs. Stephen Curry ’22* side-by-side, stat-for-stat +- **Team dashboards** – standings, playoff-probability Sankey flows and KPI tiles that auto-refresh daily +- **AI Explain & Similar Players** – one-click Sonar explanations of a stat line or AI-picked comparable athletes +- **Basketball AI Chat** – ask an expert LLM anything about NBA history, rosters or projections +- **Credit-based SaaS plumbing** – Firebase Auth + Realtime DB manage sign-up, Google login, credit wallets, admin tooling and feedback inbox + +![AI Explain Modal](https://d112y698adiu2z.cloudfront.net/photos/production/software_photos/003/442/042/datas/original.png) + +## How It Uses Perplexity Sonar + +```python +# Inline “AI Explain” for a selected player/season +payload = { + "model": "sonar-pro", + "messages": [ + { + "role": "user", + "content": ( + "Explain Giannis Antetokounmpo's 2021 playoff stats in plain English. " + "Highlight shooting efficiency and defensive impact." + ) + } + ], + "response_format": {"type": "text"} +} +explanation = client.chat.completions.create(**payload) + +# Free-form chat endpoint +chat = client.chat.completions.create( + model="sonar-pro", + messages=[ + {"role": "system", "content": "You are an NBA analytics expert."}, + {"role": "user", "content": "Who were the top 5 players in PER last season and why?"} + ] +) +``` + +- **Context packing** – the backend injects cleaned, season-filtered DataFrames into the prompt so Sonar reasons over *actual* numbers. +- **Credit guard** – every AI call passes through `credit_required()` middleware that checks Firebase balance before deducting a point and logging the query. + +## Tech Stack + +| Layer | Tech | +|------------------|----------------------------------------------| +| Frontend | React + shadcn/ui, Recharts (Netlify deploy) | +| Backend/API | Python Flask (Hugging Face Spaces) | +| Data Pipeline | BRScraper → cleanse → Firebase cache | +| Auth & Storage | Firebase Auth + Realtime Database | +| AI Integration | Perplexity Sonar-Pro, Pollinations TTS | +| DevOps | Docker, GitHub Actions | + +## Links + +- **Frontend Repo** – +- **Backend Repo** – +- **Live Demo** – +- **Devpost Story** – +- **Video Walk-through** – + +*Built with ❤️ by Rairo Mukamuri.* From eb5be67beb9e102357d3f06a1c5be87dd827a5d9 Mon Sep 17 00:00:00 2001 From: Kesku Date: Sat, 16 Aug 2025 19:11:35 +0100 Subject: [PATCH 2/2] Unify 4Point Hoops showcase page structure to match standard format --- docs/showcase/4point-Hoops.mdx | 148 ++++++++++++++++++--------------- 1 file changed, 82 insertions(+), 66 deletions(-) diff --git a/docs/showcase/4point-Hoops.mdx b/docs/showcase/4point-Hoops.mdx index 30459a8..f17bf9b 100644 --- a/docs/showcase/4point-Hoops.mdx +++ b/docs/showcase/4point-Hoops.mdx @@ -1,78 +1,94 @@ --- -title: 4Point Hoops | AI Basketball Analytics & Insights -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. -sidebar_position: 2 -keywords: [nba, basketball, analytics, ai, perplexity, sonar, sports-data, comparisons] +title: 4Point Hoops | AI Basketball Analytics Platform +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 +sidebar_position: 14 +keywords: [4point hoops, nba, basketball, analytics, ai, perplexity, sonar, sports-data, comparisons] --- -# 4Point Hoops – AI-Powered NBA Analytics - ![4Point Hoops Dashboard](https://d112y698adiu2z.cloudfront.net/photos/production/software_photos/003/442/047/datas/original.png) -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*. - -[![Demo Video](https://img.youtube.com/vi/lThCWq0ij7k/hqdefault.jpg)](https://youtu.be/lThCWq0ij7k) - -## What 4Point Hoops Does - -- **Player analytics** – season & playoff splits, shot-type breakdowns and performance radar for any NBA player -- **Cross-era comparisons** – e.g. *Michael Jordan ’97 vs. Stephen Curry ’22* side-by-side, stat-for-stat -- **Team dashboards** – standings, playoff-probability Sankey flows and KPI tiles that auto-refresh daily -- **AI Explain & Similar Players** – one-click Sonar explanations of a stat line or AI-picked comparable athletes -- **Basketball AI Chat** – ask an expert LLM anything about NBA history, rosters or projections -- **Credit-based SaaS plumbing** – Firebase Auth + Realtime DB manage sign-up, Google login, credit wallets, admin tooling and feedback inbox - -![AI Explain Modal](https://d112y698adiu2z.cloudfront.net/photos/production/software_photos/003/442/042/datas/original.png) - -## How It Uses Perplexity Sonar - -```python -# Inline “AI Explain” for a selected player/season -payload = { - "model": "sonar-pro", - "messages": [ - { - "role": "user", - "content": ( - "Explain Giannis Antetokounmpo's 2021 playoff stats in plain English. " - "Highlight shooting efficiency and defensive impact." - ) - } - ], - "response_format": {"type": "text"} -} -explanation = client.chat.completions.create(**payload) - -# Free-form chat endpoint -chat = client.chat.completions.create( - model="sonar-pro", - messages=[ - {"role": "system", "content": "You are an NBA analytics expert."}, - {"role": "user", "content": "Who were the top 5 players in PER last season and why?"} - ] -) +**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. + + + +## Features + +* **Player Analytics** with season & playoff splits, shot-type breakdowns, and performance radar for any NBA player +* **Cross-Era Comparisons** enabling side-by-side stat comparisons (e.g., Michael Jordan '97 vs. Stephen Curry '22) +* **Team Dashboards** with standings, playoff-probability Sankey flows, and auto-refreshing KPI tiles +* **AI Explain & Similar Players** providing one-click Sonar explanations of stat lines and AI-picked comparable athletes +* **Basketball AI Chat** allowing users to ask an expert LLM about NBA history, rosters, or projections +* **Credit-Based SaaS System** with Firebase Auth, Google login, credit wallets, and admin tooling + +## Prerequisites + +* Node.js 16+ and npm +* Python 3.8+ and pip +* Firebase project setup +* Perplexity API key (Sonar Pro) +* Basketball-Reference access + +## Installation + +```bash +# Clone the frontend repository +git clone https://github.com/rapha18th/hoop-ai-frontend-44.git +cd hoop-ai-frontend-44 +npm install + +# Clone the backend repository +git clone https://github.com/rapha18th/4Point-Hoops-Server.git +cd 4Point-Hoops-Server +pip install -r requirements.txt ``` -- **Context packing** – the backend injects cleaned, season-filtered DataFrames into the prompt so Sonar reasons over *actual* numbers. -- **Credit guard** – every AI call passes through `credit_required()` middleware that checks Firebase balance before deducting a point and logging the query. +## Configuration -## Tech Stack +Create `.env` file in the backend directory: +```ini +PERPLEXITY_API_KEY=your_sonar_pro_api_key +FIREBASE_PROJECT_ID=your_firebase_project_id +FIREBASE_PRIVATE_KEY=your_firebase_private_key +FIREBASE_CLIENT_EMAIL=your_firebase_client_email +``` -| Layer | Tech | -|------------------|----------------------------------------------| -| Frontend | React + shadcn/ui, Recharts (Netlify deploy) | -| Backend/API | Python Flask (Hugging Face Spaces) | -| Data Pipeline | BRScraper → cleanse → Firebase cache | -| Auth & Storage | Firebase Auth + Realtime Database | -| AI Integration | Perplexity Sonar-Pro, Pollinations TTS | -| DevOps | Docker, GitHub Actions | +## Usage -## Links +1. **Start Backend**: + ```bash + cd 4Point-Hoops-Server + python app.py + ``` + +2. **Start Frontend**: + ```bash + cd hoop-ai-frontend-44 + npm run dev + ``` + +3. **Access Application**: Open the frontend URL and explore NBA analytics with AI-powered insights -- **Frontend Repo** – -- **Backend Repo** – -- **Live Demo** – -- **Devpost Story** – -- **Video Walk-through** – +4. **Use AI Features**: Click "AI Explain" on any player or stat to get intelligent analysis powered by Perplexity Sonar + +## Code Explanation + +* **Frontend**: React with shadcn/ui components and Recharts for data visualization +* **Backend**: Python Flask API serving Basketball-Reference data and managing Perplexity API calls +* **Data Pipeline**: BRScraper for real-time data collection with Firebase caching +* **AI Integration**: Perplexity Sonar Pro for intelligent basketball analysis and explanations +* **Authentication**: Firebase Auth with Google login and credit-based access control +* **Deployment**: Frontend on Netlify, backend on Hugging Face Spaces with Docker + +## Links -*Built with ❤️ by Rairo Mukamuri.* +- [Frontend Repository](https://github.com/rapha18th/hoop-ai-frontend-44) +- [Backend Repository](https://github.com/rapha18th/4Point-Hoops-Server) +- [Live Demo](https://4pointhoops.netlify.app/) +- [Devpost Submission](https://devpost.com/software/4point-hoops)