How mritunjay2007/hack4delhi works
What this project is (type + purpose)
RailGuard Command Center is a full-stack IoT + AI real-time monitoring system for railway sabotage/tamper detection.
From the README + tree, it’s a linear data pipeline spanning:
• Edge hardware: ESP32 collecting multi-sensor telemetry (vibration/magnetic/sound).
• Messaging layer: MQTT broker (HiveMQ per README).
• Backend “bridge”: Node.js/Express service subscribing to MQTT, calling AI inference, and pushing updates to UI.
• AI service: Python FastAPI service running Isolation Forest + rules + (likely) sensor fusion + optional vision/VLM hooks.
• Operator UI: React (Vite) dashboard with maps/telemetry.
Hardware / Edge
• Software/esp32/src/main/main.ino
• Sensors → ESP32 sampling → preprocessing/packaging → MQTT publish.
Backend (Node.js) – bridge/orchestrator
• Software/backend/node-server/index.js (service entrypoint)
• mqtt/mqttClient.js (MQTT subscribe)
• socket/socket.js (Socket.io real-time push)
• controllers/dataController.js (HTTP API endpoints)
• services/alertService.js (alert logic/formatting)
• ai/aiService.js (HTTP client to Python AI service)
• data/alerts.json (prototype persistence / store)
This suggests a small layered structure: transport (MQTT, Socket) + API/controllers + services + storage (JSON).
AI service (Python / FastAPI)
• ai-service/main.py (FastAPI app entrypoint per README uvicorn main:app)
• model.py, prepare_data.py, scaler.pkl, isolation_forest.pkl (ML pipeline artifacts)
• fusion.py (multi-sensor fusion logic)
• dataExtract.py (feature extraction)
• simulate_event.py (test/sim mode)
• camera.py, vlm_model.py, captures/ and captured_images/ (camera ingestion + vision-language model integration hooks)
Frontend (React/Vite)
• Software/frontend/src/components/Dashboard.jsx (main UI)
• App.jsx, plus Tailwind config, etc.
It as a web client subscribing via Socket.io and optionally calling REST endpoints for initial state/history.
Goal: show boundaries and external dependencies.
Include:
• Operator / Control Room user
• RailGuard System
• External MQTT broker (HiveMQ)
• Optional: “Railway Ops Systems / Incident Management” as future integration (even if not implemented)
• Physical environment (trackside sensors)
Node.js Backend (Express + MQTT + Socket.io) (index.js)
• Sub-components called out: MQTT Client, REST API, AI Client, Socket Gateway, Alert Service, Alerts Store (alerts.json)
Python AI Service (FastAPI) (ai-service/main.py)
• Sub-components: Feature Extract, Sensor Fusion, Isolation Forest inference, Rules Engine, (Optional) Vision/VLM module, Model artifacts (*.pkl)
React Dashboard (Vite) (Dashboard.jsx)
• Sub-components: Map/Telemetry UI, alert stream, test/sim mode toggle
• ESP32 → MQTT Broker (MQTT publish)
• Node Backend ← MQTT Broker (MQTT subscribe)
• Node Backend → AI Service (HTTP POST /predict or similar)
• AI Service → Node Backend (prediction response)
• Node Backend → React Dashboard (Socket.io events)
• React Dashboard → Node Backend (optional REST fetch / mode change / ack)
This repo explicitly supports simulation (“TEST (SIM) mode”). Show two sequences:
• LIVE: ESP32 publishes → backend subscribes → AI inference → socket emit
• SIM: dashboard/backend triggers simulation (simulate_event.py or backend-generated) → AI inference → socket emit
This clarifies operational reality, not just static containers.
• MQTT link: from Software/backend/node-server/mqtt/mqttClient.js
• AI call: from Software/backend/node-server/ai/aiService.js
• Websocket: from Software/backend/node-server/socket/socket.js
• REST: from controllers/dataController.js
where state lives:
• Model persistence: *.pkl inside AI service
Edge-to-Cloud streaming pipeline
Sensors → broker → backend → AI → real-time UI. Emphasize low-latency path.
Bridge/Orchestrator Backend
Node.js is not just an API; it’s the protocol bridge (MQTT ↔ HTTP ↔ Socket.io).
AI service separation
Python service is independently deployable/scalable. Show it as its own container/process.
Event-driven alerting
Alerts are derived events (anomaly score / rule triggers) pushed to UI.
Simulation mode as a first-class runtime path
• Sensors (ADXL345, QMC5883L, INMP441)
• ESP32 Firmware (main.ino)
• Output: JSON payload
MQTT Broker
• HiveMQ (external)
• MQTT Subscriber (mqttClient.js)
• REST API (dataController.js)
• AI Client (aiService.js)
• Alert Service (alertService.js)
• Socket.io Server (socket.js)
• Alerts Store (alerts.json)
• FastAPI app (main.py)
• Feature extraction (dataExtract.py)
• Fusion (fusion.py)
• Anomaly model (model.py + isolation_forest.pkl + scaler.pkl)
• Optional vision (camera.py, vlm_model.py)
• Sim generator (simulate_event.py)
• Dashboard UI (Dashboard.jsx)
• Live socket subscription
• + charts