Skip to content
SAI-0360Public

About

RailGuard is an autonomous railway safety and orchestration platform designed to eliminate administrative inspection delays. It continuously analyzes track telemetry to forecast failures, automatically dispatches repair crews during critical emergencies, and leverages Google Gemini AI to verify field repair reports before closing tickets.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

Β 

History

90 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸš† RailGuard

Autonomous AI-Powered Railway Safety Inspector & Orchestration Platform

React Node MongoDB Gemini

An autonomous, AI-powered railway safety inspector that continuously monitors track telemetry, JIT-calculates geometries, forecasts failures, auto-dispatches repair tickets, and verifies repairs.


🌐 Live Demo

πŸ”— https://railguard-sooty.vercel.app/


πŸ“Œ Overview

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.

✨ Features

πŸ” 24/7 Track Monitoring

  • 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.

🚨 Smart Auto-Dispatch

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.

🧠 AI Repair Verification

  • 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.

πŸ“‰ Early Trend Forecasting

  • 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.

⏱️ Fair Deadlines & Escalation

  • 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.

πŸ—ΊοΈ Live Maps & Curve Detection

  • 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.

⚑ Clutter-Free Design

  • 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.

πŸ—οΈ Tech Stack

Frontend

  • React.js (v18)
  • Tailwind CSS
  • Framer Motion (UI animations)
  • Recharts (telemetry graphs)
  • Leaflet (GIS mapping)
  • Context API (state management)

Backend / Services

  • Node.js
  • Express
  • MongoDB / Mongoose

AI Integration

  • Google Gemini API
  • Model used: gemini-2.0-flash
  • Used for:
    • Defect parameters extraction
    • Repair verification validation
    • Risk explanation generation

Deployment

  • Vercel (Frontend)
  • Render (Backend)

πŸ“‚ Project Structure

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

🧠 Key Design Decisions

  • 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 localStorage keyed by segmentId + activeWorkOrderId.
    • Cache is invalidated automatically if the globally polled ticket ID changes, ensuring zero stale views.
  • 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}})$$

⚠️ Limitations

  • 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.

πŸš€ Future Improvements

  • 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.

βš™οΈ Setup Instructions

1. Clone the repository

git clone https://github.com/SAI-0360/railguard.git
cd railguard

2. Configure Backend (.env)

Navigate to the backend/ directory:

cd backend
npm install

Create 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=24h

Start the backend:

npm start

3. Configure Frontend (.env)

Open a new terminal window, navigate to the frontend/ directory:

cd frontend
npm install

Create a .env file inside frontend/ with:

VITE_API_URL=http://localhost:3001

Start the frontend:

npm run dev

4. Login Credentials

You 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

About

RailGuard is an autonomous railway safety and orchestration platform designed to eliminate administrative inspection delays. It continuously analyzes track telemetry to forecast failures, automatically dispatches repair crews during critical emergencies, and leverages Google Gemini AI to verify field repair reports before closing tickets.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Contributors

Languages