Sanket Frontend Cockpit
Modern operations cockpit engineered for Indian Railways section controllers, station masters, and maintenance engineers with Next.js 16, React 19, Leaflet GIS, and TanStack Query.

System Overview & Cockpit Architecture
Sanket is a mission-critical operations cockpit engineered for Indian Railways. Operating dense corridors requires balancing fast-moving high-priority passenger expresses (such as Vande Bharat, Rajdhani, and Shatabdi) with essential civil, electrical (OHE), and signaling maintenance closures.
The frontend bridges real-time timetable operations, infrastructure condition monitoring, and intelligent corridor block allocation to minimize train delays while ensuring timely, safe maintenance.
Mission-Critical UI
High-contrast status pills, dark cockpit theme option, and zero clutter for 24/7 operations control centers.
Optimistic Updates
TanStack Query v5 ensures instant UI feedback on asset edits, defect reporting, and slot reservations.
Zero ML Latency
Communicates directly with the unified Django backend at /railways/ without extra ports.
Technology Stack
Project Directory Structure
Organized by domain concern under the src/ folder:
1. 🗺️ Corridor GIS & Real-Time Railway Map
The centerpiece of the homepage (src/app/page.tsx) is the interactive geospatial map powered by Leaflet and React-Leaflet:
Corridor & Section Dynamic Selector
Section controllers can switch dynamically between divisions (Northern Railway, North Central, West Central, Western Railway) and filter tracks by station pairs (e.g. New Delhi – Mathura, Mathura – Agra, Surat – Mumbai Central).
Visual Corridor Track Occupancy
Renders color-coded polylines representing tracks: Green for Clear / Unoccupied, Amber for Active Maintenance Window, and Red for Train Occupied. Train markers update dynamically as actual movement entry/exit timestamps sync from the backend.
Dark Mode CartoDB Tile Layer
Default tile provider is configured to CartoDB Dark Matter for crisp readability in dim control room environments:
2. 🚆 Train Operations & Traffic Management (/trains)
The /trains route handles fleet-wide timetable schedules, running days bitmasks, and real-time movement monitoring:
Multi-Category Fleet Support
Every train category carries an inherent priority level (1–10) utilized by both the UI sorting and the CP-SAT optimizer:
Live Movement Tracking & Delays
Cross-references scheduled entry/exit against actual movements synced by RailKit. Computes positive delay minutes and automatically flags ripple delay threats to maintenance controllers.
3. 🏗️ Infrastructure Asset Management (/assets)
The /assets cockpit provides comprehensive inspection and lifecycle tracking across Indian Railways' three primary infrastructure departments:
Rails, sleepers, ballast compaction, expansion joints, switches, and bridge structures. Requires heavy mechanized tamper blocks (3–6 hours).
Track circuits, point machines, signal units, axle counters, and electronic interlocking systems. Typically scheduled for 45–90 minute windows.
Overhead catenary wires, tension masts, power isolators, and traction substations. Requires track power shutdowns (1–3 hours).
4. 🛠️ Intelligent Maintenance & Block Planning (/maintenance)
The /maintenance view provides section controllers with an AI-guided block allocation workflow:
AI Recommendation Banner & 1-Click Auto-Apply
When reviewing pending defects or conflicting windows, an intelligent banner displays the CP-SAT recommended collision-free window. Controllers can click "Accept Recommendation" to execute the mutation in a single request:
Maintenance Plan Status Lifecycle
7-Day Running Days Bitmask Formulation
Indian Railways train timetables are encoded using a 7-character binary mask representing Monday through Sunday:
"1111111": Daily (Mon–Sun)DAILY"1111100": Weekdays (Mon–Fri)WEEKDAY"0000011": Weekends (Sat–Sun)WEEKEND"1000000": Mondays onlyMON_ONLYHydration Safety & Mobile Overlay Isolation
Leaflet relies on browser APIs (window, document) that are unavailable during Next.js server-side rendering (SSR). To eliminate hydration errors:
Backdrop-Filter Stacking Context Fix
On mobile devices, backdrop blur on route selectors could bleed through the navigation drawer. This is solved in globals.css using CSS isolation:
Installation & Environment Configuration
Configure .env.local in the frontend root: