DEV Community

SREEJITH.K.K
SREEJITH.K.K

Posted on • Edited on

I Built A " CrowdSense AI " : A Scalable, Context-Aware Platform for Smart Stadiums

CrowdSense AI: A Scalable, Context-Aware Platform for Smart Stadiums

  • Modern sporting venues face a classic "High-Density" problem: how do you manage 60,000+ people in a dynamic, high-stakes environment where every second counts?

  • For the PromptWarsVirtual hackathon, I developed "CrowdSense AI" — a production-ready smart stadium management system designed to optimize the attendee journey through real-time crowd analytics and localized AI coordination using Antigravity.

The Technical Vision:

When designing CrowdSense AI, the goal was to build a system that was Stateless, Scalable, and Sub-second. In a stadium with weak network coverage, latency is the enemy. I chose a stack that prioritizes performance:

  • Backend: Python-based FastAPI for its asynchronous I/O capabilities and rapid JSON serialization.
  • Frontend: A high-performance, mobile-first approach using Vanilla JS and Modern CSS (Glassmorphism). By avoiding heavyweight frameworks, I achieved near-instant load times on mobile devices.
  • Infrastructure: Containerized using Docker and orchestrated on Google Cloud Run to ensure elastic scalability during peak event hours.

Core Engineering Pillars:

1. Optimal Pathfinding via Dijkstra’s Algorithm

Static navigation is insufficient for dynamic crowds. I implemented a custom routing engine based on Dijkstra's Algorithm that weights "movement cost" based on real-time zone density.
The system doesn't just calculate the shortest distance; it calculates the optimal time-to-destination, automatically routing fans away from 90%+ capacity zones to prevent bottlenecks and ensure safety.

2. Multi-Language Intent Detection & Localization

To support global tournaments, the platform features a rule-based NLP assistant capable of identifying user intent across 5+ languages (including Hindi, Tamil, Spanish, and French).

  • Intent Mapping: Uses optimized regular expressions for sub-millisecond classification of user needs (Food, Medical, Logistics).
  • Global Context: The entire UI dynamically updates its state based on a unified translations.json schema, ensuring a seamless experience for international fans.

3. Frictionless Onboarding (The Ticket Context System)

In a large-scale event, user friction during app setup leads to poor adoption. I architected a URL-Parameter Context System that prepopulates the application state (Stadium, Match, Seat, Zone) via scannable QR codes on physical tickets. This ensures zero-entry onboarding and immediate user value.

Working: The dashboard pulls a live "Snapshot" from the backend every few seconds. The Heatmap is rendered using a Custom HTML5 Canvas engine.

The Logic: It maps current density values (0.0 to 1.0) to specific HSL colors (Green to Red).
The Result: Fans get a visual "weather report" of the stadium crowd, and admins can identify "Hot Zones" immediately.


Working: This is the "brain" of the crowd management. It uses a Dijkstra-based pathfinding algorithm located in routing_service.py.

The Logic: It builds a "Graph" of the stadium's zones. Each zone has a "weight" based on its live crowd density.
The Result: If you want to go from A1 to the Exit, the app doesn't just show the shortest line—it calculates a path that weaves through less crowded zones, even if it's a longer walk, to save you time and avoid bottlenecks.

This is the heart of the "Efficiency" problem.

Wait Time Estimation: The backend queue_service.py calculates estimated wait times in real-time by multiplying the number of people in the queue by the stall's average processing speed.
Order Lifecycle: We implemented a full simulated order lifecycle:
Pending ➔ Preparing ➔ Ready ➔ Collected.
Security & Refunds: If an order is cancelled while it's still "Pending," the system automatically triggers a simulated Instant Refund to the fan's virtual wallet.


Working: The assistant uses a Rule-Based NLP processor.Instead of making expensive calls to an external LLM, it uses a high-performance Regex Intent Detector to identify what the fan needs (navigation, food, help, or emergency).

Result: It provides sub-second responses and works offline/local without any API costs.
Context Aware: It knows your current zone and language, so its "suggestions" are always relevant to where you are standing.


Working: This section uses a Proximity Logic Engine (facilities_service.py).

The Logic: It sorts all medical rooms, information desks, and merchandise shops based on their distance from your current zone.
The Result: In an emergency, a fan doesn't have to search a list. The "Medical" button instantly shows the one right next to them and gives them a turn-by-turn route to get there and location of drinking water will be also available with route and nearby stall information too and nearby drinking water location is also be visible in that specific zone.


The app features a dynamic Vendor Engine that categorizes stalls into Food, Merchandise, and Entertainment.

The Localization: Every menu item and price is part of the translation schema. When a fan switches to Spanish, even the "Burger" description and the currency symbol change.
Discovery: Stalls are sorted by their current zone, making it easy to find what is closest to your seat and only logged in users place order and non logged users can view stalls menu etc.,

  • 100% support for Hindi, Tamil, Spanish, French, and Malayalam.

  • Even the database content (like Stall names and Help descriptions) is translated on-the-fly using a lookup helper.

  • through login button we can login with mobile/email and new users can also register


CrowdSense AI isn't built for just one stadium; it’s a global platform.

The Logic: I implemented a Multi-Venue Dataset (Chepauk, Wankhede, Narendra Modi).
Dynamic Loading: When a stadium is selected, the app fetches a completely different set of routes, stalls, and match schedules MOCK SCHEDULE to personalize the experience.

  • I built a 3-tier system to ensure every fan gets into the app as fast as possible:

QR/Link (Priority 1): The app parses URL parameters. Scanning a ticket QR code instantly sets the entire app state.
Local Storage (Priority 2): If you close the app and reopen it, it "remembers" your last stadium and language so you don't have to pick them again.
Manual (Priority 3): If no data is found, a premium Stadium Selection overlay guides you to pick your venue.

  • Location awareness is built into every screen.

The Logic: Based on the userZone, the app provides Zone Hints translated into the local language (e.g., "📍 Near North Gate Entry").
The Result: This reduces "Navigation Anxiety" by constantly giving the user small, helpful landmarks relative to their current seat.


When a ticket is purchased, the ticketing platform generates a unique URL for that specific fan: https://crowdsense-ai-955338303650.us-central1.run.app/?stadium=Chepauk&seat=A12

Direct Navigation: When the fan clicks the link in their SMS or Email, the app loads instantly with their specific match day context.
Pre-Arrival Preparation: Even before they reach the stadium, the fan can see the "Live Heatmap" of the gates and find the "Quietest Entrance" for their specific zone.
One-Click Support: Because the link includes their seat and zone, the fan can click "Help" the moment they arrive, and the AI Assistant will already know exactly where they are supposed to be.
Match: Lookups the live match schedule automatically based on the stadium.

Through QR code we can only set the stadium ,the app is smart enough to automatically find the current match for you.

Stadium Detection:
The app sees the stadium ID (e.g., Wankhede).

Schedule Lookup:
It looks at the MOCK SCHEDULE (which is like a live database of matches).

Automatic Match Setting:
It sees that Wankhede is currently hosting "IND vs NZ" and sets that as the active match instantly.

Static QR Codes:
The stadium can print permanent QR codes on the walls or at the gates

Dynamic Updates:
Even if the match changes every day (Monday: Match A, Tuesday: Match B), the same QR code will always work because the app checks the "Live Schedule" to see what's happening right now.

After scan this is how it Opens:

By utilizing a Mock Firestore singleton, I maintained a serverless, zero-cost environment for the prototype while ensuring the codebase remains "Swappable" for production-grade Google Cloud Firestore integration.

CrowdSense AI demonstrates how cloud-native technologies can solve the logistical complexities of physical events, making stadiums safer and more enjoyable for everyone and Production-architected,Low-latency design prototype,Currently uses mock crowd data; real deployment would integrate IoT sensors or ticketing APIs and Improves crowd flow efficiency and reduces queue congestion in high-density venues.

Inspired by the AI-driven crowd management at the Chinnaswamy Stadium and the massive logistics at the Narendra Modi Stadium, I built CrowdSense AI to bring this world-class technology into a single, easy-to-use mobile platform for every fan.

Thankyou for reading And this is done by me with the use of AI.
*changes may occur in the project*

Top comments (0)