# shubhammehra4/smart-metro architecture

> Architecture diagram of the GitHub repository shubhammehra4/smart-metro, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-20). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/shubhammehra4/smart-metro
- Repository: https://github.com/shubhammehra4/smart-metro

## Overview

SMART METRO is a web application for finding Delhi Metro routes and estimating station crowd levels. A user selects stations in the route form; the browser requests a route, the Express server delegates to a Python process, and the browser formats returned routes with station metadata. A separate development form submits time, day, and weather for a crowd estimate. The excerpts establish these request paths and Python model use; they do not establish how the displayed map is populated or validate the route’s “safest” characterization.

Main entry points: [`ml.js`](https://github.com/shubhammehra4/smart-metro/blob/master/ml.js) (Python process adapter), [`index.js`](https://github.com/shubhammehra4/smart-metro/blob/master/index.js) (Express routes), [`public/scripts/submit.js`](https://github.com/shubhammehra4/smart-metro/blob/master/public/scripts/submit.js) (Route display), [`pathFinder/findPath.py`](https://github.com/shubhammehra4/smart-metro/blob/master/pathFinder/findPath.py) (Route engine)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web experience"]
  node_routeform["Route form<br/>[home.ejs]"]
  node_routeclient["Route display<br/>[submit.js]"]
  node_stationmetadata[("Display station data<br/>[stationDetails.js]")]
  node_devform["Crowd form<br/>[homeDev.ejs]"]
  node_crowdclient["Crowd display<br/>[submitDev.js]"]
end

subgraph group_server["HTTP server"]
  node_express["Express routes<br/>[index.js]"]
  node_bridge["Python process adapter<br/>[ml.js]"]
end

subgraph group_routing["Routing and stations"]
  node_stationlist[("Station names<br/>[stationNames.js]")]
  node_network[("Metro network data<br/>[stationJS.json]")]
  node_routeengine["Route engine<br/>[findPath.py]"]
end

subgraph group_prediction["Crowd prediction"]
  node_crowdengine["Crowd estimator<br/>[getCrowd.py]"]
  node_model[("Random forest model<br/>[RFR_Model.pkl]")]
end

node_rider(("Metro rider"))

node_rider -->|"chooses stations"| node_routeform
node_routeform -->|"offers stations"| node_stationlist
node_routeclient -->|"requests route"| node_express
node_express -->|"calls findPath"| node_bridge
node_bridge -->|"spawns Python"| node_routeengine
node_routeengine -->|"loads network"| node_network
node_routeengine -->|"predicts crowd"| node_model
node_bridge -->|"returns routes"| node_routeclient
node_routeclient -->|"formats stations"| node_stationmetadata
node_rider -->|"enters conditions"| node_devform
node_crowdclient -->|"requests estimate"| node_express
node_express -->|"calls getCrowd"| node_bridge
node_bridge -->|"spawns Python"| node_crowdengine
node_crowdengine -->|"predicts crowd"| node_model
node_bridge -->|"returns estimate"| node_crowdclient

click node_routeform "https://github.com/shubhammehra4/smart-metro/blob/master/views/home.ejs"
click node_routeclient "https://github.com/shubhammehra4/smart-metro/blob/master/public/scripts/submit.js"
click node_stationmetadata "https://github.com/shubhammehra4/smart-metro/blob/master/public/scripts/stationDetails.js"
click node_devform "https://github.com/shubhammehra4/smart-metro/blob/master/views/homeDev.ejs"
click node_crowdclient "https://github.com/shubhammehra4/smart-metro/blob/master/public/scripts/submitDev.js"
click node_express "https://github.com/shubhammehra4/smart-metro/blob/master/index.js"
click node_bridge "https://github.com/shubhammehra4/smart-metro/blob/master/ml.js"
click node_stationlist "https://github.com/shubhammehra4/smart-metro/blob/master/stationNames.js"
click node_network "https://github.com/shubhammehra4/smart-metro/blob/master/pathFinder/stationJS.json"
click node_routeengine "https://github.com/shubhammehra4/smart-metro/blob/master/pathFinder/findPath.py"
click node_crowdengine "https://github.com/shubhammehra4/smart-metro/blob/master/pathFinder/getCrowd.py"
click node_model "https://github.com/shubhammehra4/smart-metro/blob/master/pathFinder/RFR_Model.pkl"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_routeform,node_routeclient,node_stationmetadata,node_devform,node_crowdclient toneBlue
class node_express,node_bridge toneAmber
class node_stationlist,node_network,node_routeengine toneMint
class node_crowdengine,node_model toneRose
class node_rider toneIndigo
```

## Components

### Web experience

- [Route form](https://github.com/shubhammehra4/smart-metro/blob/master/views/home.ejs): `views/home.ejs`
- [Route display](https://github.com/shubhammehra4/smart-metro/blob/master/public/scripts/submit.js): `public/scripts/submit.js`
- [Display station data](https://github.com/shubhammehra4/smart-metro/blob/master/public/scripts/stationDetails.js): `public/scripts/stationDetails.js`
- [Crowd form](https://github.com/shubhammehra4/smart-metro/blob/master/views/homeDev.ejs): `views/homeDev.ejs`
- [Crowd display](https://github.com/shubhammehra4/smart-metro/blob/master/public/scripts/submitDev.js): `public/scripts/submitDev.js`

### HTTP server

- [Express routes](https://github.com/shubhammehra4/smart-metro/blob/master/index.js): `index.js`
- [Python process adapter](https://github.com/shubhammehra4/smart-metro/blob/master/ml.js): `ml.js`

### Routing and stations

- [Station names](https://github.com/shubhammehra4/smart-metro/blob/master/stationNames.js): `stationNames.js`
- [Metro network data](https://github.com/shubhammehra4/smart-metro/blob/master/pathFinder/stationJS.json): `pathFinder/stationJS.json`
- [Route engine](https://github.com/shubhammehra4/smart-metro/blob/master/pathFinder/findPath.py): `pathFinder/findPath.py`

### Crowd prediction

- [Crowd estimator](https://github.com/shubhammehra4/smart-metro/blob/master/pathFinder/getCrowd.py): `pathFinder/getCrowd.py`
- [Random forest model](https://github.com/shubhammehra4/smart-metro/blob/master/pathFinder/RFR_Model.pkl): `pathFinder/RFR_Model.pkl`

### Other components

- **Metro rider**

## Connections

- Metro rider → Route form: chooses stations
- Route form → Station names: offers stations
- Route display → Express routes: requests route (evidence: `public/scripts/submit.js`)
- Express routes → Python process adapter: calls findPath (evidence: `index.js`)
- Python process adapter → Route engine: spawns Python (evidence: `ml.js`)
- Route engine → Metro network data: loads network (evidence: `pathFinder/findPath.py`)
- Route engine → Random forest model: predicts crowd (evidence: `pathFinder/findPath.py`)
- Python process adapter → Route display: returns routes (evidence: `ml.js`)
- Route display → Display station data: formats stations (evidence: `public/scripts/submit.js`)
- Metro rider → Crowd form: enters conditions
- Crowd display → Express routes: requests estimate (evidence: `public/scripts/submitDev.js`)
- Express routes → Python process adapter: calls getCrowd (evidence: `index.js`)
- Python process adapter → Crowd estimator: spawns Python (evidence: `ml.js`)
- Crowd estimator → Random forest model: predicts crowd (evidence: `pathFinder/getCrowd.py`)
- Python process adapter → Crowd display: returns estimate (evidence: `ml.js`)
