second_innings_ai
AI cricket companion with live match predictions and gamified fan engagement built for Google Cloud APL.
Technology Stack
Second Innings AI 🏏⚡
A highly-polished, production-ready AI cricket companion built for the Google Cloud Hackathon.
Second Innings AI transforms passive cricket viewership into an interactive, gamified experience. By blending real-time match data with a futuristic "Spotify + F1" aesthetic, it offers fans a dynamic dashboard powered by AI insights, live predictions, and global leaderboards.
✨ Key Features & The "Wow Factor"
- Dynamic Ball Tracking Engine: An intelligent proxy layer that infers ball-by-ball events (runs, wickets) directly from score deltas in standard live APIs, providing a seamless "last 6 balls" visualization without expensive premium API tier access.
- AI Momentum Engine: Real-time match momentum analysis generated by GROQ (Llama 3), analyzing the live match context to determine which team has the upper hand and why.
- Gamified Fan Predictions: Users can "Lock In" live predictions (e.g., "Next Wicket Method") to earn XP and build streaks.
- Global Leaderboards: Firebase Firestore powered leaderboards tracking the top fans globally based on XP.
- Futuristic UI/UX: A judge-ready aesthetic utilizing dark mode, neon accents, glassmorphism, and Framer Motion micro-animations.
🛠️ Tech Stack
- Frontend: Next.js 14, Tailwind CSS, Framer Motion, Lucide Icons.
- Backend / APIs: Next.js Serverless API routes, ESPN Live Scoreboard mapping.
- Database: Firebase Firestore (for XP, Streaks, Leaderboard data).
- AI: GROQ API (Llama3-70b-8192) for high-speed momentum generation.
- Cloud Infrastructure: Fully Dockerized for serverless deployment on Google Cloud Run, built via Cloud Build.
🚀 Getting Started Locally
-
Clone the repository
git clone <repo-url> cd second-innings-ai -
Environment Configuration Copy the example environment file and fill in your credentials:
cp .env.example .env.localRequired Keys:
GROQ_API_KEY: Get this from the Groq Cloud Console.NEXT_PUBLIC_FIREBASE_*: Your Firebase project configuration.
-
Install Dependencies
npm install -
Run the Development Server
npm run devNavigate to
http://localhost:3000to view the dashboard.
☁️ Deployment (Google Cloud Run)
This project is optimized for a serverless, scale-to-zero architecture to keep hackathon budgets low.
-
Authenticate with Google Cloud
gcloud auth login gcloud config set project YOUR_PROJECT_ID -
Enable Required APIs
gcloud services enable cloudbuild.googleapis.com run.googleapis.com -
Deploy via Cloud Build
gcloud builds submit --config cloudbuild.yaml .
Note for Local Docker Builds: If you are building the Docker image locally (especially on an Apple Silicon M-series Mac) to push to the artifact registry manually, the
Dockerfileis already configured withFROM --platform=linux/amd64to ensure compatibility with Google Cloud Run.
💰 Architecture & Cost Optimization
- Google Cloud Run: Scales to zero when no fans are active, ensuring minimal baseline costs.
- GROQ AI: Chosen for its ultra-low latency and extreme cost-effectiveness compared to traditional LLMs, perfect for high-frequency live match updates.
- Firebase Firestore: Real-time listeners and efficient read/writes for the gamification layer.