NexGate is an advanced operational intelligence platform designed for large-scale sporting and entertainment venues (e.g., 60,000-seat stadiums). Rather than simply reacting to crowd congestion, NexGate uses predictive AI to forecast bottlenecks before they happen.
By integrating continuous sensor telemetry with Google's latest Gemini 3.1 Flash Lite, NexGate empowers venue staff to make proactive decisions—such as redirecting foot traffic, opening overflow lanes, and managing concession surges—ensuring both operational efficiency and attendee safety.
The backend engine aggregates historical and live sensor data across 8 distinct stadium zones. It queries Gemini every ~60 seconds via a staggered event-loop to predict density and queue lengths 10 to 15 minutes into the future. If Gemini detects an impending bottleneck (e.g., density > 85%), it automatically generates an actionable directive (e.g., "Open two additional overflow lanes at Gate North").
Staff have access to a live chat interface built directly into the dashboard. Instead of a generic LLM, the chatbot is injected with the exact real-time density matrix and timestamped telemetry of the entire stadium. This creates a grounded, hallucination-resistant assistant that can immediately pull up wait times or generate calm emergency instructions.
NexGate uses a reactive message-bus architecture via Firebase Realtime Database. This decouples the physical simulated sensors from the AI reasoning engine, meaning the dashboard UI updates with sub-second latency the moment the engine commits a new prediction.
To optimize cloud costs, the system features an "Active Heartbeat" protocol. If the dashboard is closed or idle for > 15 minutes, the heavy AI Prediction Engine automatically enters a high-efficiency hibernation mode, instantly waking up the moment a staff member reopens the dashboard.
Built for the chaos of live events, NexGate features robust fault tolerance:
- Exponential Backoff: Gracefully handles transient 503 High Demand spikes from the Gemini API.
- Moving Average Fallback: If the AI API goes offline completely, the engine seamlessly degrades to a deterministic moving-average model to keep basic metrics flowing.
- Zero Hardcoded Secrets: Employs a secure
.env→config.jspipeline so no API keys are ever exposed in git.
NexGate is divided into three distinct, decoupled microservices working in concert:
graph TD
classDef python fill:#222,stroke:#3776ab,stroke-width:2px,color:#fff
classDef node fill:#222,stroke:#339933,stroke-width:2px,color:#fff
classDef frontend fill:#222,stroke:#e34f26,stroke-width:2px,color:#fff
classDef google fill:#222,stroke:#4285F4,stroke-width:2px,color:#fff
classDef data fill:#222,stroke:#EA4335,stroke-width:2px,color:#fff
subgraph "1. Sensing (Python)"
Sim["🐍 Sensor Simulator<br/>Generates live telemetry"]:::python
end
subgraph "2. Logic (Node.js)"
Engine["🟢 Prediction Engine<br/>Staggered AI orchestration"]:::node
end
subgraph "3. User Interface (Vanilla JS/CSS)"
Dash["💻 Ops Command Center<br/>Global Zone Monitor"]:::frontend
Chat["💬 AI Ops Assistant<br/>Grounded Chatbot"]:::frontend
end
subgraph "Cloud Infrastructure"
DB[("🔥 Firebase RTDB<br/>Message Bus")]:::data
Gemini["✨ Gemini 3.1 Flash<br/>Predictive Models"]:::google
end
Sim -- "15s Ticks" --> DB
DB -- "Syncs" --> Engine
Engine -- "JSON Prompt" --> Gemini
Gemini -- "10/15m Forecast" --> Engine
Engine -- "Writes Alerts & Risk" --> DB
DB -- "Live DOM Updates" --> Dash
DB -. "Live Telemetry" .-> Chat
Chat -- "Contextual Query" --> Gemini
Gemini -- "Ops Guidance" --> Chat
Running NexGate locally requires launching all three microservices in separate terminal windows.
- Node.js (v18+)
- Python (3.9+)
- A Firebase Realtime Database Instance
- A Google Gemini API Key
- Rename
.env.exampleto.envin the root folder. - Fill in your Gemini and Firebase credentials.
- Run the security bridge to expose safe variables to the vanilla JS frontend:
node setup-config.js
The Python script acts as the stadium's IoT network, simulating the flow of foot traffic around events like Kickoff and Halftime.
cd simulator
pip install -r requirements.txt
python simulator.pyTip: You can set
SIMULATION_SPEED=60in the.envto make 1 minute of simulation happen in 1 second of real-time!
The Node.js backend fetches the sensor data, orchestrates requests to the Gemini model with a 15-second stagger (to respect rate limits), and processes alert logic.
cd engine
npm install
npm startThe frontend uses pure Vanilla Javascript, CSS3 Skeuomorphism, and HTML5 (no React overhead) for maximum raw performance and simplicity.
cd dashboard
npx serve . -l 3456Navigate to http://localhost:3456 in your browser.
NexGate employs a Skeuomorphic Dark Mode aesthetic. In high-stress control rooms, flat design can be ambiguous. NexGate uses inset shadows, glassmorphism, and physical depth cues so that input fields look like inputs, buttons look pressable, and critical "SURGE" badges visually pop off the screen.