NexAlert is a highly scalable, enterprise-grade Next-Gen Wrong-Way Driver Detection & V2X (Vehicle-to-Everything) Alert System. The core directive of the project is "Zero Hardcoding. Pure Logical Code." It dynamically queries OpenStreetMap (OSM) data, runs real-time map matching, and computes anomalies purely through geospatial logic.
The system bridges a simulated environment (or CSV replay telemetry) with real-world ML-based anomaly detection and physical hardware alerts, creating a comprehensive prototype for Next-Gen V2X Safety Systems..
- 🌍 Zero Hardcoding: Dynamically fetches road networks anywhere in the world via the Overpass API.
- 📍 Real-time Map Matching: High-performance spatial math using Turf.js to snap GPS telemetry to road segments.
- 🧠 ML-Assisted Detection: Incorporates a Kaggle-trained Random Forest classifier for robust anomaly confidence scoring.
- 📡 Swarm Consensus: Vehicles cross-validate anomalies using V2V (Vehicle-to-Vehicle) proximity logic.
⚠️ Hazard Corridors: Dynamically generates "Danger Cones" and warns upstream feeder traffic of incoming threats.- 🎛️ Physical V2X Dashboard: Sub-100ms hardware alerts to an ESP32 OLED display via WebSockets.
- 🏗️ Construction Overrides: Interactive polygon drawing to suppress false positives in active work zones.
The project is structured as a monorepo containing four major pillars:
backend/(Node.js/Express/TypeScript): Orchestrates telemetry ingestion via WebSockets, real-time map matching, anomaly detection, ML inference, and traffic simulation.frontend/(React/Vite): A dark-themed Command Center dashboard leveraging MapLibre GL for live traffic visualization, alert management, and system control.hardware/(ESP32): A physical V2X Edge Node dashboard with an OLED screen and buzzer, receiving driver alerts directly from the backend.- Machine Learning Pipeline: A trained Random Forest model that evaluates vehicle kinematics and GNSS quality features.
git clone https://github.com/your-username/NexAlert.git
cd NexAlertcd backend
npm install
npm run devThe backend server will start on http://localhost:8080 (or as configured in .env).
Open a new terminal window:
cd frontend
npm install
npm run devThe React app will start on http://localhost:5173.
- Open
hardware/V2X_Dashboard/V2X_Dashboard.inoin the Arduino IDE. - Install the required libraries (
Adafruit_SSD1306,WebSocketsClient,ArduinoJson, etc.). - Update the Wi-Fi credentials and WebSocket server IP in the code.
- Flash to your ESP32.
- Ingestion: Telemetry is generated via the built-in simulator or historical CSV replay, feeding into the backend via WebSockets.
- Matching: Incoming coordinates are mapped to the nearest OSM road segment (dynamically fetched & cached).
- Detection: Kinematic rules evaluate bearing deltas against road direction (factoring in
onewaytags). The ML model evaluates the feature vector to generate confidence scores. - Hazard Generation: At critical confidence, the system generates a Turf polygon "Danger Cone" and upgrades the vehicle state to
DANGER. - Broadcasting: The backend broadcasts enriched telemetry and alerts to the React UI and the bound ESP32 Hardware node in real-time.
This project is licensed under the MIT License.