An autonomous, AI-powered railway safety inspector that continuously monitors track telemetry, JIT-calculates geometries, forecasts failures, auto-dispatches repair tickets, and verifies repairs.
π https://railguard-sooty.vercel.app/
RailGuard is designed to solve a critical safety and operational problem in heavy railway systems (such as Indian Railways P.Way divisions) β lack of real-time monitoring and administrative paperwork delays.
Instead of waiting for scheduled trolley inspection runs, operators and engineers can:
- Monitor 100 track segments in real-time on a 10x10 glassmorphic grid.
- Track physical route locations and curve hazards on Leaflet GIS maps.
- Forecast structural breaches using proactive linear regression models.
- Auto-dispatch tickets with dynamic SLA timers.
- Verify field repairs using Gemini AI validation loops.
- The system continuously scans track data in the background (like train vibrations and track cracks).
- It automatically calculates a simple "Risk Score" based on how bad the vibrations are, how long it's been since the last inspection, and if the track is on a sharp curve.
RailGuard handles emergencies automatically so humans don't have to:
- Critical Emergencies: When a track becomes highly dangerous, the system instantly creates a repair ticket and assigns it to the nearest field worker with a strict 4-hour deadline. No human manager is needed to trigger this.
- Early Warnings: When a track is slightly degraded but not yet dangerous, the system alerts the depot manager (SSE). The manager can review the data and proactively send a team to fix it before it becomes an emergency.
- When field workers finish a repair, they type a simple report explaining what they did (e.g., "tightened loose bolts").
- Google Gemini AI reads this report and compares it to the original problem.
- If the AI confirms the repair makes sense, it automatically clears the emergency and turns the track "green" again, saving managers hours of paperwork and manual review.
- The system looks at recent vibration patterns to predict the future.
- If a track is getting worse over time, it warns operators with badges like "critical in ~2 days", giving them a head start to fix the issue.
- The platform features tailored views for Field Workers (JE), Depot Managers (SSE), and HQ Division Chiefs (DEN).
- SLA Freeze: If field workers get stuck (e.g., a train is blocking the track), they can request help. This instantly "freezes" their 4-hour countdown clock so they aren't unfairly penalized for delays outside their control.
- Displays the entire railway network on an interactive map.
- The system automatically detects sharp curves in the track and assigns them a higher risk penalty, since trains are more likely to derail on curves.
- Mute Nominal: With one click, managers can hide all "healthy" tracks from their screen. This leaves a clean, distraction-free dashboard showing only the tracks that need immediate attention.
- React.js (v18)
- Tailwind CSS
- Framer Motion (UI animations)
- Recharts (telemetry graphs)
- Leaflet (GIS mapping)
- Context API (state management)
- Node.js
- Express
- MongoDB / Mongoose
- Google Gemini API
- Model used:
gemini-2.0-flash - Used for:
- Defect parameters extraction
- Repair verification validation
- Risk explanation generation
- Vercel (Frontend)
- Render (Backend)
RailGuard/
βββ backend/
β βββ config/
β β βββ db.js # MongoDB connection
β βββ data/
β β βββ raw-tracks-db.json # Geographic OpenStreetMap data
β β βββ segments.js # Live segment telemetry store
β βββ middleware/
β β βββ auth.js # Route JWT validation
β β βββ errorHandler.js # Global error handler
β βββ routes/
β β βββ activityLogRoutes.js
β β βββ aiRoutes.js # Gemini extraction & verifications
β β βββ authRoutes.js # JWT auth logins
β β βββ segmentRoutes.js # Track queries & JIT route processor
β β βββ statsRoutes.js # Global counters & resets
β β βββ workOrderRoutes.js # SLA ticketing & JEs rosters
β βββ services/
β β βββ activityLogger.js
β β βββ geminiExtractor.js # AI extraction & risk explanations
β β βββ geminiVerifier.js # AI repair verifier
β β βββ riskEngine.js # Math risk scoring & regression
β β βββ routeProcessor.js # Curve geometry calculations
β βββ server.js # Express entry point
β βββ .env.example
β
βββ frontend/
βββ src/
β βββ components/ # Reusable UI panels & components
β β βββ CellGrid.jsx # 10x10 color-coded schematic matrix
β β βββ FocusPanel.jsx # Telemetry detail workspace & AI forms
β β βββ LiveMap.jsx # Leaflet coordinate map
β β βββ LoginPage.jsx
β β βββ SituationBar.jsx # Metric cards and status totals
β β βββ WorkOrderPipeline.jsx # Columns of active tickets
β βββ context/
β β βββ AuthContext.jsx # User login & logout handling
β βββ hooks/
β β βββ useSegments.js # Segment data polling hook
β β βββ useSelectedSegment.js # Segment selection & caching logic
β β βββ useStats.js
β βββ services/
β β βββ api.js # Axios client setup
β βββ App.jsx # Navigation & console layouts
β βββ main.jsx
βββ index.html
-
Work by Exception Focus
- "Mute Nominal" header filter collapses the grid to hide healthy green cells, focusing operators purely on warnings and critical alerts.
-
Ticket-Validated Caching
- Selected segment details are cached in
localStoragekeyed bysegmentId+activeWorkOrderId. - Cache is invalidated automatically if the globally polled ticket ID changes, ensuring zero stale views.
- Selected segment details are cached in
-
SLA Clock Adjustments
- Real-world roadblocks shouldn't penalize field crew. On task resumption, the deadline is recalculated:
$$\text{New Deadline} = \text{Original Deadline} + (T_{\text{resume}} - T_{\text{freeze}})$$
- Real-world roadblocks shouldn't penalize field crew. On task resumption, the deadline is recalculated:
- In-Memory Cache resets: telemetries reset to defaults on server restart (intentional for demonstration).
- LLM Semantic Sensitivity: Gemini verifications can fail on ambiguous repair descriptions.
- Speech API Support: Voice dictation requires Google Chrome or compatible web speech browsers.
- Round 2: MQTT edge node integration for real accelerometers, plus RTK GPS geofencing checks.
- Round 3: PostGIS spatial database re-architecting for multi-corridor depot orchestration.
- Round 4: Autonomous drone camera patrols parsing rail cracks via YOLOv8 object models.
git clone https://github.com/SAI-0360/railguard.git
cd railguardNavigate to the backend/ directory:
cd backend
npm installCreate a .env file inside backend/ with:
PORT=3001
GEMINI_API_KEY=your_gemini_api_key_here
MONGODB_URI=mongodb://127.0.0.1:27017/railguard
JWT_SECRET=your_long_random_jwt_secret_key
JWT_EXPIRES_IN=24hStart the backend:
npm startOpen a new terminal window, navigate to the frontend/ directory:
cd frontend
npm installCreate a .env file inside frontend/ with:
VITE_API_URL=http://localhost:3001Start the frontend:
npm run devYou can log in to the dashboard using these seeded user accounts:
- District Engineer (DEN):
den@railguard.in/ password:password123 - Senior Section Engineer (SSE):
sse@railguard.in/ password:password123 - Junior Engineer (JE):
je1@railguard.in/ password:password123