You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# KavachBridge v2
> **"Bridging the gap between Kavach-protected and manual railway zones — preventing the next Kanchanjunga."**
## What is KavachBridge?
KavachBridge is a real-time railway safety simulation that demonstrates how digital tokens can bridge the critical gap between automated Kavach zones and older manual sections of Indian Railways. It shows how cryptographic token systems can prevent train collisions in non-electrified, manually-operated corridors.
## The Real Problem — Kanchanjunga Reference
On June 17, 2024, the Kanchanjunga Express collided with a goods train near New Jalpaiguri in West Bengal, killing 8 people and injuring 41. The cause: the goods train entered a manual block section without a proper token authority, and the Kavach system was not installed on that stretch.
**KavachBridge v2 simulates this exact scenario** — automatically — and shows how a digital token system could have prevented it.
---
## Features
| Feature | Description |
|---|---|
| 🗺 **Real NE India Map** | 3 tracks following the actual Siliguri→Patna, NJP→Guwahati, and Hill Branch corridors |
| 🎨 **Live Zone Coloring** | Green=Kavach, Yellow=Transition, Red=Manual — randomized each loop |
| 🚂 **3 Directional Trains** | SVG train icons that follow curved track paths in real-time |
| 🎫 **Automatic Tokens** | Digital tokens auto-generate when trains enter yellow zones, fly to train as animation |
| 🚨 **3-Level Conflict System** | Warning → Critical → Kanchanjunga Scenario with full overlay |
| 🔄 **Infinite Loop** | Tracks regenerate zones on each loop, trains never stop |
| 🔒 **Network Cut Simulation** | Safe mode kills token issuance, trains crawl in manual zones |
| 📱 **Responsive** | Desktop sidebar, tablet stacked, mobile drawer |
---
## Setup
```bash
# Install dependencies
cd client && npm install
cd ../server && npm install
# Start server
cd server && npm start
# Start client (in another terminal)
cd client && npm run dev
```
Open [http://localhost:5173](http://localhost:5173)
> **MongoDB is optional** — server falls back to in-memory mode automatically.
---
## How the Demo Works
1. **Open the app** → You see the splash screen
2. **Click "▶ Start Demo"** → Everything begins automatically
3. **Watch** trains move along real curved tracks
4. **Token cards fly** from station icons to trains when entering yellow zones
5. **Conflict alerts** appear when 2 trains share a manual zone
6. **Kanchanjunga overlay** fires when distance < 1km (resolves in 5s)
7. **Infinite loop** — after all trains complete their routes, zones regenerate with new random segments
8. Click **"🔒 Simulate Network Cut"** to see safe mode
---
## Tech Stack
- **React 19** — UI framework
- **Leaflet.js** — Map engine with custom SVG overlays
- **GSAP** — Token card flight animations
- **Socket.io** — Real-time state sync
- **Node.js + Express** — Backend simulation engine
- **MongoDB (optional)** — State persistence, falls back to in-memory
- **Vite** — Build tool
---
## Folder Structure
```
kavachbridge-v2/
├── client/src/
│ ├── components/
│ │ ├── MapView.jsx ← Leaflet + SVG tracks + directional trains
│ │ ├── Dashboard.jsx ← Right sidebar (stats, tokens, alerts)
│ │ ├── SplashScreen.jsx ← One-click start screen
│ │ └── KanchanjungaOverlay.jsx ← Level 3 scenario overlay
│ ├── hooks/
│ │ └── useTrainSimulation.js ← Core simulation engine (200ms ticks)
│ └── utils/
│ ├── trackData.js ← 3 real NE India railway track coordinates
│ ├── trackInterpolation.js ← Haversine-based path following
│ ├── zoneGenerator.js ← Random zone segment generation
│ └── conflictDetector.js ← Proximity-based conflict detection
└── server/
├── sockets/trainSocket.js ← Socket.io handler
├── engine/conflictDetector.js
└── index.js
```
---
## Team
**Built for FAR AWAY Hackathon 2026 — Railways Theme**
---
## Screenshots
Click "▶ Start Demo" to see:
- Live train movement along curved NE India tracks
- Green/Yellow/Red zone segments updating in real-time
- Token cards flying from station icons to trains
- Conflict alerts cascading through levels
- The Kanchanjunga scenario overlay with KavachBridge resolution
# kavachBridge