Skip to content
ย 
ย 

Latest commit

ย 

History

23 Commits

Folders and files

NameName
Last commit message
Last commit date
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿ”๏ธ HaulSight

Smart Mine Vehicle Safety & Collision Risk Monitoring System

Smart India Hackathon 2026

Python FastAPI React Tailwind License


๐ŸŽฏ Problem

In open-cast iron ore mines, dense fog severely limits visibility on haul roads. Drivers cannot see approaching vehicles, blind corners, or stopped hazards early enough. This leads to collisions, injuries, and operational downtime.

HaulSight provides an additional safety layer by tracking equipped vehicles, modelling the mine's haul-road network, calculating collision risk in real time, and generating targeted warnings โ€” even when GPS or network connectivity fails.


๐Ÿ—๏ธ Architecture

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                     HaulSight Architecture                       โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚                                                                  โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”‚
โ”‚  โ”‚   Vehicle    โ”‚โ”€โ”€โ”€โ–ถโ”‚   Roadside   โ”‚โ”€โ”€โ”€โ–ถโ”‚   Control Room      โ”‚ โ”‚
โ”‚  โ”‚   Unit       โ”‚LoRaโ”‚   Gateway    โ”‚API โ”‚   Backend           โ”‚ โ”‚
โ”‚  โ”‚  (GPS+IMU)   โ”‚    โ”‚  (ESP32)     โ”‚    โ”‚  (FastAPI+SQLite)   โ”‚ โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚
โ”‚                                                    โ”‚             โ”‚
โ”‚                                      โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚
โ”‚                                      โ”‚  WebSocket  โ”‚ REST API  โ”‚ โ”‚
โ”‚                                      โ–ผ             โ–ผ           โ”‚ โ”‚
โ”‚                              โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”   โ”‚ โ”‚
โ”‚                              โ”‚      Control Room           โ”‚   โ”‚ โ”‚
โ”‚                              โ”‚      Dashboard              โ”‚   โ”‚ โ”‚
โ”‚                              โ”‚  (React + Leaflet + Tailwindโ”‚   โ”‚ โ”‚
โ”‚                              โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜   โ”‚ โ”‚
โ”‚                                                                  โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”‚
โ”‚  โ”‚          Independent Radar Fallback (LoRa-free)          โ”‚    โ”‚
โ”‚  โ”‚    Blind Corner Beacons โ†’ Local Visual + Audible Alert   โ”‚    โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

โœจ Features

Feature Description
๐Ÿ—บ๏ธ Live Mine Map Interactive Leaflet map showing haul roads, blind corners, and vehicle positions
๐Ÿš› Vehicle Tracking Real-time position, speed, heading, and status for all equipped vehicles
โš ๏ธ Collision Risk Engine Deterministic pairwise evaluation using TTC (time-to-conflict) and closing distance
๐Ÿ”” Targeted Alerts Alerts identify specific vehicle pairs and explain WHY a risk was generated
๐Ÿ“ก Radar Fallback Independent radar beacons at blind corners detect non-equipped vehicles
๐Ÿ“‰ State Machine Vehicles transition through LIVE โ†’ STALE โ†’ OFFLINE with configurable thresholds
๐Ÿ”„ Anti-Oscillation Hysteresis and debouncing prevent rapid SAFEโ†”WARNING flickering
๐ŸŽฎ Demo Scenarios 3 scripted scenarios for live demonstration
โš™๏ธ Configurable All thresholds tunable via YAML config file

๐Ÿš€ Quick Start

Prerequisites

  • Python 3.11+
  • Node.js 18+
  • pip
  • npm

1. Clone the repository

git clone https://github.com/your-team/haulshight.git
cd haulshight

2. Start the Backend

cd backend
python -m venv venv
source venv/bin/activate   # On Windows: venv\Scripts\activate
pip install -r requirements.txt
python run.py

Backend runs at http://localhost:8000

3. Start the Frontend

cd frontend
npm install
npm run dev

Dashboard runs at http://localhost:5173

The frontend proxies API and WebSocket requests to the backend automatically.


๐ŸŽฎ Demo Scenarios

Once both servers are running, open the dashboard and use the scenario buttons in the header:

Button Scenario What Happens
Scenario 1 Normal Operation Two vehicles approach a blind corner, risk escalates SAFE โ†’ CAUTION โ†’ WARNING โ†’ CRITICAL
Scenario 2 Network Failure Gateway connectivity drops, dashboard shows degraded state, radar continues working
Scenario 3 Non-Equipped Vehicle Radar detects an unknown vehicle at a blind corner, generates local warning
Reset Restore Normal All systems return to normal operation

๐Ÿ“ Project Structure

haulshight/
โ”œโ”€โ”€ backend/
โ”‚   โ”œโ”€โ”€ app/
โ”‚   โ”‚   โ”œโ”€โ”€ main.py              # FastAPI app entry point
โ”‚   โ”‚   โ”œโ”€โ”€ config.py            # Configuration loader
โ”‚   โ”‚   โ”œโ”€โ”€ database.py          # SQLite connection + schema
โ”‚   โ”‚   โ”œโ”€โ”€ models.py            # Pydantic data models
โ”‚   โ”‚   โ”œโ”€โ”€ state.py             # In-memory vehicle state store
โ”‚   โ”‚   โ”œโ”€โ”€ api/
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ vehicles.py      # Vehicle endpoints
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ roads.py         # Road graph endpoints
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ alerts.py        # Alert endpoints
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ radar.py         # Radar endpoints
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ websocket.py     # WebSocket broadcaster
โ”‚   โ”‚   โ”œโ”€โ”€ services/
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ telemetry.py     # Telemetry ingestion + validation
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ vehicle_state.py # State machine transitions
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ risk_engine.py   # Pairwise collision risk
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ alert_manager.py # Alert lifecycle + debounce
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ radar_service.py # Radar beacon management
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ stale_detector.py# Background stale/offline check
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ road_graph.py    # Road graph in-memory model
โ”‚   โ”‚   โ””โ”€โ”€ simulator/
โ”‚   โ”‚       โ”œโ”€โ”€ vehicle_sim.py   # Vehicle telemetry simulator
โ”‚   โ”‚       โ”œโ”€โ”€ radar_sim.py     # Radar detection simulator
โ”‚   โ”‚       โ””โ”€โ”€ scenarios.py     # Demo scenario scripts
โ”‚   โ”œโ”€โ”€ data/
โ”‚   โ”‚   โ”œโ”€โ”€ mine_graph.json      # Road network definition
โ”‚   โ”‚   โ””โ”€โ”€ default_config.yaml  # Configurable thresholds
โ”‚   โ”œโ”€โ”€ requirements.txt
โ”‚   โ””โ”€โ”€ run.py                   # Entry point
โ”œโ”€โ”€ frontend/
โ”‚   โ”œโ”€โ”€ src/
โ”‚   โ”‚   โ”œโ”€โ”€ App.jsx              # Root component + WS setup
โ”‚   โ”‚   โ”œโ”€โ”€ api/
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ client.js        # REST API helpers
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ websocket.js     # WebSocket manager
โ”‚   โ”‚   โ”œโ”€โ”€ stores/              # Zustand state stores
โ”‚   โ”‚   โ”œโ”€โ”€ components/
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ layout/          # Header, MainLayout
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ map/             # MineMap, VehicleMarker, RadarBeaconMarker
โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ panels/          # VehicleList, AlertPanel, SystemHealth
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ ui/              # StatusBadge, RiskBadge
โ”‚   โ”‚   โ””โ”€โ”€ styles/theme.js     # Color palette
โ”‚   โ”œโ”€โ”€ vite.config.js
โ”‚   โ””โ”€โ”€ package.json
โ””โ”€โ”€ README.md

โš™๏ธ Configuration

All thresholds are in backend/data/default_config.yaml:

# Vehicle state detection
stale_threshold_seconds: 10      # No telemetry for this โ†’ STALE
offline_threshold_seconds: 30    # No telemetry for this โ†’ OFFLINE

# Risk engine thresholds
ttc_critical_seconds: 5.0        # Time-to-conflict for CRITICAL
ttc_warning_seconds: 10.0        # Time-to-conflict for WARNING
ttc_caution_seconds: 15.0        # Time-to-conflict for CAUTION
dist_critical_meters: 20.0       # Distance for CRITICAL
dist_warning_meters: 50.0        # Distance for WARNING
dist_caution_meters: 100.0       # Distance for CAUTION

# Alert debouncing
risk_debounce_ticks: 3           # Ticks before alert fires
risk_downgrade_ticks: 6          # Ticks before alert resolves
blind_corner_threshold_multiplier: 0.7  # Tighter thresholds at blind corners

๐Ÿง  Risk Engine Logic

HaulSight does not use ML for collision detection. It uses deterministic, explainable rule-based logic:

For each vehicle pair (A, B):
  1. Are they on the same or connected road segments?
  2. Are they heading toward each other? (closing speed > 0)
  3. Calculate time-to-conflict (TTC) = distance / closing_speed
  4. Compare TTC against thresholds:
       TTC < 5s  โ†’ CRITICAL
       TTC < 10s โ†’ WARNING
       TTC < 15s โ†’ CAUTION
  5. Apply blind-corner multiplier (30% tighter)
  6. Apply hysteresis (immediate upgrade, gradual downgrade)

Every alert includes a human-readable reason explaining the risk.


๐Ÿ”Œ API Endpoints

Method Endpoint Description
POST /api/v1/telemetry Ingest vehicle telemetry
GET /api/v1/vehicles List all vehicles with live state
GET /api/v1/roads Full road graph
GET /api/v1/alerts Active alerts
GET /api/v1/alerts/history Alert history
GET /api/v1/radar/beacons Radar beacon status
POST /api/v1/radar/detections Report radar detection
POST /api/v1/scenario/{name} Trigger demo scenario
GET /api/v1/health System health
WS /ws Real-time updates

๐ŸŽจ Design System

Color Hex Usage
Primary Blue #2FA4D7 Actions, normal states, SAFE risk
Warm Cream #F5E9D8 Backgrounds, surfaces
Dark Brown #3E2C23 Text, structural elements
Orange #E76F2E Warnings, CAUTION risk
Red #DC2626 CRITICAL risk

Risk badges maintain semantic meaning regardless of theme.


๐Ÿ”ง Tech Stack

Layer Technology
Frontend React 19, Vite 8, Tailwind CSS 4, Zustand
Map React-Leaflet + OpenStreetMap
Backend Python 3.11+, FastAPI, aiosqlite
Database SQLite
Real-time WebSocket (FastAPI native)
Communication REST + WebSocket
Hardware Interface Modular telemetry API (LoRa/ESP32 ready)

๐Ÿ“ Edge Cases Handled

  • GPS Jumps โ€” Rejects impossible position changes
  • Duplicate Packets โ€” Deduplication via message ID
  • Out-of-Order Packets โ€” Sequence number validation
  • Missing Telemetry โ€” LIVE โ†’ STALE โ†’ OFFLINE state machine
  • Stopped Vehicles โ€” Treated as static hazards, not ignored
  • Non-Equipped Vehicles โ€” Radar-only detection at blind corners
  • Alert Oscillation โ€” Hysteresis prevents rapid flickering
  • GPS Degradation โ€” Marked as DEGRADED, conservative thresholds
  • Malformed Packets โ€” Rejected safely, logged
  • Road Changes โ€” Graph is JSON-configurable

๐Ÿงช Testing the Backend

# Test health endpoint
curl http://localhost:8000/api/v1/health

# List tracked vehicles
curl http://localhost:8000/api/v1/vehicles

# Get road graph
curl http://localhost:8000/api/v1/roads

# Trigger scenario
curl -X POST http://localhost:8000/api/v1/scenario/1

๐Ÿ‘ฅ Team

Built for Smart India Hackathon 2026

Name Role Department
Priyansha Gour (Captain) Electronics and Telecommunication Engineering (E&TC)
Dhakshayini Usha R Electronics and Telecommunication Engineering (E&TC)
Mishree Kalaria Electronics and Telecommunication Engineering (E&TC)
Yash Rastogi Electronics and Telecommunication Engineering (E&TC)
Yash Pratap Singh Electronics and Telecommunication Engineering (E&TC)
Harman Computer Science Engineering Student (CSE)

๐Ÿ“„ License

MIT License


HaulSight โ€” Because every miner deserves to go home safe.

About

Real-time mining haul-road safety platform for vehicle tracking, collision risk detection, radar monitoring, and AI-powered hazard analysis.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages