Skip to content

aashitanegii/crowdcommand

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

7 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🏟️ CrowdCommand β€” AI-Powered Stadium Operations Assistant

A real-time intelligent dashboard that monitors crowd dynamics, predicts congestion, and enables operators to take immediate action through an AI-driven decision system.


🎯 Overview

CrowdCommand is a smart stadium operations platform designed to manage large-scale crowds efficiently during live events.

It transforms raw real-time data into actionable insights, helping operators:

  • Detect congestion early
  • Predict risk zones
  • Execute corrective actions instantly

πŸ‘‰ Moving from reactive monitoring β†’ predictive control


πŸ—οΈ Architecture

promptwar1/
β”œβ”€β”€ client/                    # React + Vite frontend
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ components/        # UI components (Heatmap, Gates, Queues, Alerts)
β”‚   β”‚   β”œβ”€β”€ hooks/             # Custom hooks (AI Decision Engine logic)
β”‚   β”‚   β”œβ”€β”€ services/          # WebSocket connection manager
β”‚   β”‚   β”œβ”€β”€ utils/             # Helper utilities
β”‚   β”‚   β”œβ”€β”€ App.jsx            # Main orchestrator
β”‚   β”‚   β”œβ”€β”€ main.jsx           # Entry point
β”‚   β”‚   β”œβ”€β”€ index.css          # Design system
β”‚   β”‚   └── intelligence.css   # AI + alert styling
β”‚
β”œβ”€β”€ server/                    # Node.js + Express backend
β”‚   β”œβ”€β”€ models/                # Stadium configuration models
β”‚   β”œβ”€β”€ routes/                # API endpoints (/api/health, /api/snapshot)
β”‚   β”œβ”€β”€ services/              # Simulation + operator logic
β”‚   β”œβ”€β”€ utils/                 # Validation + helpers
β”‚   β”œβ”€β”€ tests/                 # Jest + supertest API tests + validation suite
β”‚   β”œβ”€β”€ config.js              # Environment config
β”‚   └── index.js               # Server entry point
β”‚
β”œβ”€β”€ Dockerfile                 # Multi-stage Docker build for Cloud Run
β”œβ”€β”€ .dockerignore              # Docker build exclusions
└── .gitignore

βš™οΈ Core Features

πŸ—ΊοΈ Live Crowd Heatmap

  • 8-zone real-time density tracking
  • Color-coded (Safe / Busy / Critical)
  • Trend indicators + predictive capacity estimation

πŸšͺ Smart Gate Monitoring

  • 6 gates with wait time + throughput
  • Automatically highlights fastest entry
  • Helps redistribute crowd flow

⏳ Virtual Queue System

  • Dynamic queues for 10 concession stands
  • Real-time join/leave operations
  • Live wait-time estimation

🧠 AI Decision Engine

  • Rule-based intelligent system analyzing live data

  • Generates prioritized recommendations:

  • 🚨 Critical β†’ Open emergency exit, reroute crowd

  • ⚠️ Warning β†’ Redirect to faster gate

  • πŸ“ˆ Info β†’ Add service counter


πŸŽ›οΈ Operator Action System

  • Interactive control panel
  • Execute actions:
    • Redirect crowd
    • Open exits
    • Manage gates

πŸ‘‰ Actions trigger real-time feedback:

  • Congestion reduces
  • System updates instantly

🚨 Alert & Feedback System

  • Auto-triggered alerts on critical thresholds
  • Toast notifications for:
    • system warnings
    • successful actions

⚑ Performance & Real-Time Design

  • WebSocket updates every 2 seconds
  • Optimized React rendering:
    • useMemo β€” memoized computed values
    • useCallback β€” stable event handler references
    • React.memo β€” prevents unnecessary child re-renders
  • gzip compression on all HTTP responses
  • Efficient ring-buffer for action history

πŸ‘‰ Ensures smooth real-time UI even under heavy updates


πŸ§ͺ Testing

Jest API Tests

cd server
npm install
npm test

Runs 34+ Jest tests across 4 test files with supertest covering:

  • API Endpoints (app.test.js): Health (200, status, service, uptime, timestamp), Snapshot (zones, gates, queues, occupancy), 404 handling
  • Validation (app.test.js): Queue actions (valid, missing, string, negative, null), Operator actions (valid, invalid targetType, empty, missing actionType)
  • Simulation (app.test.js): Zone count, occupancy ranges, status values, gate count, fastest gate marking, queue lengths
  • Actions Service (actions.test.js): Zone, gate, and queue actions including edge cases (unknown IDs, unknown action types, boundary clamping)
  • Clamp Utility (clamp.test.js): Boundary, within-range, equal-min/max, negative ranges, and decimal values

Lightweight Validation Suite

cd server
npm run validate

Covers 24 assertions across:

  • Clamp utility
  • Input validation
  • Queue logic
  • Simulation data shapes
  • Operator actions

πŸ” Security

  • Helmet β€” HTTP security headers (X-Frame-Options, X-Content-Type-Options, etc.)
  • express-rate-limit β€” 100 requests per 15 minutes per IP on API routes
  • Input validation β€” inline + utility-based on all WebSocket events
  • CORS β€” configurable origin policy via environment variable
  • Socket rate limiting β€” throttle on queue and operator actions
  • Try/catch error handling β€” all socket handlers wrapped
  • Global error handler β€” catches unhandled Express errors
  • No hardcoded secrets β€” environment-based configuration (.env)
  • Non-root Docker user β€” production container runs as appuser

Google Services Used

  • Google Cloud Run (deployment)
  • Gemini API (AI advisory generation)
  • Antigravity (AI-assisted development)
  • Google Stitch (UI generation)

☁️ Google Cloud Integration

Designed for deployment on Google Cloud Run:

  • Uses process.env.PORT (defaults to 8080)
  • Multi-stage Dockerfile with health check
  • Stateless backend (cloud-native)
  • /api/health endpoint for monitoring and readiness checks
  • gzip compression for optimized bandwidth
  • Scalable real-time WebSocket architecture

β™Ώ Accessibility

  • Semantic HTML5 elements (<header>, <main>, <section>, <aside>, <nav>)
  • ARIA roles: banner, main, tablist, tab, dialog, alert, status, progressbar, list, listitem, region, log, application
  • aria-label on all interactive elements (buttons, cards, panels)
  • aria-live="polite" for dynamic content updates
  • aria-hidden="true" on decorative icons
  • Keyboard navigation: tabIndex, onKeyDown handlers
  • Proper heading hierarchy (<h1>, <h2>)

πŸš€ Getting Started

Prerequisites

  • Node.js 18+
  • npm 9+

Backend

cd server
npm install
npm run dev

Frontend

cd client
npm install
npm run dev

Running Tests

cd server
npm test

πŸš€ Deployment

Google Cloud Run

Option 1: Direct deploy

gcloud run deploy crowdcommand \
  --source . \
  --region asia-south1 \
  --allow-unauthenticated

Option 2: Docker build

docker build -t crowdcommand .
docker run -p 8080:8080 crowdcommand

Environment Variables

Variable Default Description
PORT 8080 Server port (Cloud Run injects this)
NODE_ENV development Environment mode
CORS_ORIGIN * Allowed CORS origins
BROADCAST_INTERVAL_MS 2000 WebSocket update frequency

πŸ“Š Impact

  • Reduces waiting time
  • Improves crowd flow
  • Enhances operational safety
  • Enables real-time decision making

πŸ€– AI Usage

This project was built using AI-assisted development with Google tools:

  • Gemini (code refinement & logic design)
  • Antigravity (agent-based development workflow)
  • Google Stitch (UI generation)
  • Google Cloud (deployment-ready architecture)

Structured prompting was used to simulate a multi-agent development process across frontend, backend, and system design.


🏁 Conclusion

CrowdCommand demonstrates how AI and real-time systems can transform stadium operations into intelligent, responsive environments.


πŸ“Œ Submission Links

About

Smart stadium control system that predicts crowd congestion and enables real-time operational decisions. Turning stadium chaos into intelligent control with real-time AI-driven crowd management.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors