Skip to content

About

AI-powered smart stadium experience platform

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

Β 

History

18 Commits

Folders and files

Repository files navigation

🏟️ CrowdControl

AI-Powered Smart Stadium Experience Platform

Python Next.js FastAPI GCP Firebase Gemini Built with


πŸ“– What is CrowdControl?

CrowdControl is a real-time AI-powered stadium management and fan experience platform built for large-scale sporting venues. It combines live crowd intelligence, Gemini-powered navigation, predictive queue modelling, and personalised fan recommendations, all accessible from a single mobile-first web app.

The Problem: Attending a major sporting event often means navigating packed corridors, waiting in long queues, missing out on deals, and struggling to find your way around an unfamiliar venue.

The Solution: CrowdControl gives every fan a real-time AI co-pilot and gives venue staff a live operational command centre, turning chaos into a seamlessly guided experience.


✨ Features

πŸ”΄ CrowdLens β€” Spatial Intelligence

  • Interactive SVG stadium heatmap with 12 live zones (Sections A–L)
  • Real-time colour-coded density: Optimal (green) β†’ Active (yellow) β†’ High (orange) β†’ Critical (red)
  • WebSocket-powered updates every 3 seconds with zero page refresh
  • Pulsing zone animations for rapidly filling sections
  • Hover tooltips: zone name, current headcount, capacity, and density trend
  • One-click spatial report generation for venue operations staff

🧭 PathFinder β€” AI Navigation

  • Gemini 3-powered turn-by-turn routing across the entire venue
  • Ingests live crowd density data to recommend the least congested path
  • Destinations: Gates, Food Courts, Restrooms, Medical Bay, Merchandise, Exits
  • Congestion warning badges when a route passes through high-density zones
  • "Avoid Crowds" toggle that triggers an alternate AI-generated route
  • Estimated walk time per route

⏱️ QueueSense β€” Predictive Queue Intelligence

  • Tracks 8 service points: 3 food courts, 2 merchandise stores, 2 restroom clusters, 1 medical bay
  • Wait time prediction powered by the M/M/1 queuing theory model (operations research)
  • Real-time sparkline charts showing 10-minute wait history per service point
  • "Best Choice" badge highlighting the shortest queue per category
  • Filterable tabs: All | Food | Merch | Restrooms
  • WebSocket live updates every 5 seconds

⚑ FanPulse β€” Personalised AI Recommendations

  • 3-question onboarding: dietary needs, interests, time available
  • Gemini 3 generates 5 hyper-personalised recommendations per fan
  • Context-aware: accounts for live queue times, crowd density, active offers, and event stage
  • Urgency labels: "Act Now", "Good Time", "Anytime"
  • Swipeable recommendation cards with Framer Motion animations
  • "Pulse It Again" for refreshed suggestions as the event evolves

πŸ›‘οΈ Admin Portal β€” Staff Command Centre

  • Live zone density data table across all 12 sections
  • Queue length overview for all 8 service points
  • Automated alert feed: zones exceeding 85% capacity trigger deployment recommendations
  • Manual zone override: staff can mark zones as "Closed" to reroute navigation AI

🌐 Live Demo

https://crowd-frontend-987426744408.us-central1.run.app

https://www.loom.com/share/9e90eba7bc3d43e999925f2919f6aa39

Module URL
🏠 Home /
πŸ”΄ CrowdLens /map
⏱️ QueueSense /queue
⚑ FanPulse /recommendations
πŸ›‘οΈ Admin Portal /admin

πŸ—οΈ Architecture

CrowdControl
β”œβ”€β”€ Frontend (Next.js 14 + TypeScript + Tailwind CSS)
β”‚   β”œβ”€β”€ /app/page.tsx              β†’ Fan Home + Venue Status Banner
β”‚   β”œβ”€β”€ /app/map/page.tsx          β†’ CrowdLens Heatmap
β”‚   β”œβ”€β”€ /app/queue/page.tsx        β†’ QueueSense Dashboard
β”‚   β”œβ”€β”€ /app/recommendations/      β†’ FanPulse AI Cards
β”‚   β”œβ”€β”€ /app/admin/page.tsx        β†’ Staff Portal
β”‚   └── /components/NavigationPanel.tsx β†’ PathFinder Panel
β”‚
β”œβ”€β”€ Backend (Python FastAPI)
β”‚   β”œβ”€β”€ /api/routes/crowd.py       β†’ Crowd density REST + WebSocket
β”‚   β”œβ”€β”€ /api/routes/navigation.py  β†’ AI navigation routes
β”‚   β”œβ”€β”€ /api/routes/queue.py       β†’ Queue prediction REST + WebSocket
β”‚   β”œβ”€β”€ /api/routes/recommendations.py β†’ FanPulse AI endpoint
β”‚   β”œβ”€β”€ /services/gemini_service.py    β†’ Gemini 3 integration
β”‚   β”œβ”€β”€ /services/crowd_service.py     β†’ Real-time zone simulation
β”‚   β”œβ”€β”€ /services/queue_service.py     β†’ M/M/1 queue model
β”‚   └── /services/recommendation_service.py β†’ AI context builder
β”‚
└── Infrastructure (Google Cloud Platform)
    β”œβ”€β”€ Cloud Run         β†’ Frontend + Backend containers
    β”œβ”€β”€ Artifact Registry β†’ Docker image storage
    β”œβ”€β”€ Cloud Build       β†’ CI/CD pipeline
    β”œβ”€β”€ Firestore         β†’ Fan profiles + recommendation history
    β”œβ”€β”€ Firebase RTDB     β†’ Real-time event streaming
    β”œβ”€β”€ Pub/Sub           β†’ Crowd event messaging
    └── Secret Manager    β†’ API key management

πŸ› οΈ Tech Stack

Layer Technology
Frontend Next.js 14, TypeScript, Tailwind CSS, Framer Motion, Recharts
Backend Python 3.11, FastAPI, WebSockets, Pydantic
AI / ML Google Gemini 3 Pro (via google-generativeai SDK)
Realtime WebSocket (FastAPI), Firebase Realtime Database
Database Cloud Firestore
Deployment Google Cloud Run
CI/CD Google Cloud Build
Containers Docker, Docker Compose
IDE / Agent Google Antigravity (Gemini 3 agent-first IDE)

πŸš€ Getting Started

Prerequisites

  • Python 3.11+
  • Node.js 18+
  • Google Cloud SDK
  • A Gemini API key from aistudio.google.com
  • A Firebase project

1. Clone the Repository

git clone https://github.com/kavinithi-sera/crowdcontrol.git
cd crowdcontrol

2. Set Up Environment Variables

cp .env.example .env

Edit .env and fill in your values:

GEMINI_API_KEY=your_gemini_api_key
GCP_PROJECT_ID=your_gcp_project_id
FIREBASE_PROJECT_ID=your_firebase_project_id
NEXT_PUBLIC_API_URL=http://localhost:8000
GOOGLE_APPLICATION_CREDENTIALS=service-account-key.json

3. Start the Backend

cd backend
pip install -r requirements.txt
uvicorn app.main:app --reload --port 8000

4. Start the Frontend

cd frontend
npm install
npm run dev

5. Open the App

Visit http://localhost:3000 in your browser.


🐳 Run with Docker Compose

docker-compose up --build

This starts both the frontend (port 3000) and backend (port 8000) together.


☁️ GCP Deployment

Enable Required Services

gcloud services enable run.googleapis.com \
  cloudbuild.googleapis.com \
  artifactregistry.googleapis.com \
  firestore.googleapis.com \
  pubsub.googleapis.com \
  secretmanager.googleapis.com

Build & Deploy

# Backend
gcloud builds submit --tag \
  asia-southeast1-docker.pkg.dev/$PROJECT_ID/crowdcontrol-repo/backend ./backend

gcloud run deploy crowdcontrol-backend \
  --image asia-southeast1-docker.pkg.dev/$PROJECT_ID/crowdcontrol-repo/backend \
  --platform managed --region asia-southeast1 --allow-unauthenticated

# Frontend
gcloud run deploy crowdcontrol-frontend \
  --image asia-southeast1-docker.pkg.dev/$PROJECT_ID/crowdcontrol-repo/frontend \
  --platform managed --region asia-southeast1 --allow-unauthenticated

CI/CD is configured via cloudbuild.yaml β€” every push to main automatically builds and deploys.


πŸ“ Project Structure

crowdcontrol/
β”œβ”€β”€ backend/
β”‚   β”œβ”€β”€ app/
β”‚   β”‚   β”œβ”€β”€ main.py
β”‚   β”‚   β”œβ”€β”€ api/routes/
β”‚   β”‚   β”œβ”€β”€ services/
β”‚   β”‚   β”œβ”€β”€ models/
β”‚   β”‚   └── core/
β”‚   β”œβ”€β”€ requirements.txt
β”‚   └── Dockerfile
β”œβ”€β”€ frontend/
β”‚   β”œβ”€β”€ app/
β”‚   β”œβ”€β”€ components/
β”‚   β”œβ”€β”€ lib/
β”‚   └── Dockerfile
β”œβ”€β”€ .github/workflows/deploy.yml
β”œβ”€β”€ docker-compose.yml
β”œβ”€β”€ cloudbuild.yaml
β”œβ”€β”€ .env.example
└── README.md

🧠 How Gemini Powers CrowdControl

CrowdControl uses Google Gemini 3 Pro in three distinct ways:

  1. PathFinder Navigation β€” Gemini receives a structured prompt containing the fan's current zone, destination, and a full snapshot of live crowd density across all 12 zones. It returns a JSON-structured step-by-step route that actively avoids congested areas.

  2. FanPulse Recommendations β€” Gemini receives the fan's dietary preferences, interests, available time, current event stage (pre-game / halftime / post-game), live queue wait times, and active venue promotions. It generates 5 contextually relevant, urgency-labelled recommendations tailored specifically to that fan at that moment.

  3. Venue Assistant Chatbot β€” A floating AI assistant on the home screen lets fans ask natural language questions. Gemini's system prompt is dynamically injected with live crowd and queue context so answers are always current and venue-aware.


πŸ”¬ The Science Behind QueueSense

QueueSense uses the M/M/1 queuing model from operations research to predict wait times:

Wait Time = Queue Length / (Service Rate - Arrival Rate)

This is the same mathematical model used in telecommunications, hospital management, and airport operations β€” applied here in real time to stadium service points, giving fans accurate, science-backed wait predictions rather than guesswork.


🀝 Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.


πŸ‘₯ Team

Built using Google Antigravity β€” the agent-first IDE developed by Google.

About

AI-powered smart stadium experience platform

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages