Skip to content

Repository files navigation

🚇 Travel Metro

Graph-based metro route optimization and transit simulation system


Travel Metro Banner




Overview

Travel Metro is a Spring Boot based metro route optimization system that models realistic Delhi Metro traversal using graph-based routing and dynamic transit simulation.

The project allows users to:

  • Select source and destination stations
  • Compute optimized metro routes
  • Simulate realistic traversal conditions
  • Visualize routes using interactive Leaflet maps

Unlike traditional shortest-path implementations, the routing engine incorporates dynamic runtime edge weighting based on waiting time, traffic behavior, rush-hour congestion and interchange overhead.


Overview Screenshot

System Architecture

The backend architecture is centered around a dynamically constructed weighted graph representation of the metro network.

  • Stations are modeled as graph nodes
  • Metro connections are modeled as weighted edges
  • Graph topology is loaded from MongoDB
  • Graphs are cached in memory for fast traversal

Architecture Diagram

Component Responsibility
MongoDB Station topology storage
GraphService Graph construction
TransitWeightService Dynamic edge weighting
TraversalTimeManager Runtime time simulation
Dijkstra Engine Route optimization
Leaflet.js Route visualization

Routing Engine

The routing engine uses Dijkstra’s algorithm to compute optimized traversal paths across metro stations.

Instead of using only geographical distance, traversal weights are dynamically calculated using contextual transit behavior.

Runtime Weight Components

Weight Component Purpose
Base Travel Time Core station traversal
Waiting Time Platform delay simulation
Peak Hour Penalty Office rush-hour impact
Weekday Traffic Factor Realistic weekday behavior
Interchange Penalty Platform transfer overhead

Routing Flowchart

Temporal Transit Simulation

The project introduces runtime traversal simulation using the TraversalTimeManager.

As traversal progresses through the graph, accumulated travel time is tracked continuously. This enables contextual edge weighting based on the estimated arrival time at each station.

The system therefore simulates:

  • Office rush-hour congestion
  • Weekday traffic behavior
  • Dynamic waiting penalties
  • Realistic transit conditions

Time Simulation

Interchange-Aware Routing

Interchange penalties are applied only when traversal switches metro lines.

This prevents unrealistic traversal inflation while accurately modeling platform transfer delays inside major interchange stations such as:

  • Rajiv Chowk
  • Kashmere Gate

Traversal Behavior Penalty Applied
Same-Line Continuation No
Metro Line Switch Yes

Branch-Aware Blue Line Modeling

The Blue Line contains multiple branches.

The graph initialization layer models branch topology independently to prevent invalid cross-branch traversal and preserve realistic metro connectivity constraints.


Branch Routing

Frontend Visualization

The frontend layer uses Thymeleaf together with Leaflet.js for interactive metro visualization.

Features

  • Interactive metro rendering
  • Dynamic route highlighting
  • Station marker visualization
  • Autocomplete station selection
  • Compact route summaries

Frontend UI

Core Engineering Concepts

Concept Usage
Adjacency List Graph Metro topology modeling
Dijkstra Traversal Route optimization
Dynamic Edge Weighting Transit simulation
Haversine Formula Distance calculation
In-Memory Graph Cache Traversal optimization
Runtime Time Simulation Context-aware routing

Project Structure

travel-metro/
│
├── backend/
│   ├── services/
│   ├── controllers/
│   ├── graph/
│   └── traversal/
│
├── frontend/
│   ├── templates/
│   ├── static/
│   └── leaflet/
│
├── assets/
│
└── README.md

Future Improvements

  • Full Delhi Metro network support
  • Fare estimation system
  • Live metro timing integration
  • Predictive crowd analytics
  • Multi-objective route optimization
  • Distributed graph caching

Running The Project

Clone Repository

git clone https://github.com/YOUR_USERNAME/travel-metro.git

Navigate To Project

cd travel-metro

Run Spring Boot Application

./gradlew bootRun

Open Browser

https://metro-router-production.up.railway.app/

Author

Ifrah Rauf

Systems engineering • Backend development • Product building

```

About

Metro Router is a graph-based route planning web app which models metro network as a weighted graph, supporting efficient route, distance, and interchange calculations to compute the optimal path between metro stations using Dijkstra's shortest path. It follows a modular architecture and simulate real-world metro navigation.

Topics

Resources

Stars

Watchers

Forks

Contributors

Languages