# manaswini-m24/sureroute architecture

> Architecture diagram of the GitHub repository manaswini-m24/sureroute, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-12-04). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/manaswini-m24/sureroute
- Repository: https://github.com/manaswini-m24/sureroute

## Overview

SureRoute serves passenger and driver portals for bus routes, live stop reports, and predicted arrival times. The main workflow is passenger route/stop lookup through the API and Firestore, followed by upcoming-trip ETA calculation; drivers submit status updates through the same API. The map is an additional passenger capability, and scheduled status reset is an internal maintenance behavior. ETA logic is visible in main.py, but the excerpts do not establish how the saved model artifact is loaded, so that link is left unasserted.

Main entry points: [`main.py`](https://github.com/manaswini-m24/sureroute/blob/main/main.py) (Upcoming trips and ETA), [`backend/routes_api.py`](https://github.com/manaswini-m24/sureroute/blob/main/backend/routes_api.py) (Route and status API), [`static/script.js`](https://github.com/manaswini-m24/sureroute/blob/main/static/script.js) (Portal interactions), [`templates`](https://github.com/manaswini-m24/sureroute/tree/main/templates) (Passenger and driver portals)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web portals"]
  node_portals["Passenger and driver portals"]
  node_browser["Portal interactions<br/>[script.js]"]
  node_map["Stops and location map<br/>[map.js]"]
  node_web_firebase["Browser Firebase auth<br/>[firebase.js]"]
end

subgraph group_service["Application services"]
  node_app["Web app and pages<br/>[main.py]"]
  node_api["Route and status API<br/>[routes_api.py]"]
  node_schedule["Daily status reset<br/>[main.py]"]
end

subgraph group_data["Route and live data"]
  node_firestore_init["Firestore access<br/>[firebase_init.py]"]
  node_firestore[("Firestore")]
  node_route_import["Route data import<br/>[routesdata.py]"]
end

subgraph group_prediction["ETA prediction"]
  node_eta["Upcoming trips and ETA<br/>[main.py]"]
  node_model_artifact["Trained ETA model"]
end

node_passengers(("Passengers"))
node_drivers(("Drivers"))

node_passengers -->|"use"| node_portals
node_drivers -->|"use"| node_portals
node_portals -->|"request pages"| node_app
node_app -->|"mounts routes"| node_api
node_portals -.->|"runs scripts"| node_browser
node_browser -->|"fetches routes and stops"| node_api
node_browser -->|"posts stop status"| node_api
node_browser -.->|"uses auth"| node_web_firebase
node_map -->|"fetches stops"| node_api
node_api -->|"reads and updates"| node_firestore_init
node_firestore_init -->|"reads route data"| node_firestore
node_route_import -->|"writes routes"| node_firestore
node_passengers -->|"request arrivals"| node_eta
node_app -->|"handles trip requests"| node_eta
node_eta -->|"reads stop status"| node_firestore_init
node_eta -->|"returns predicted ETAs"| node_passengers
node_schedule -->|"resets statuses"| node_firestore_init
node_eta -.->|"loads model"| node_model_artifact

click node_portals "https://github.com/manaswini-m24/sureroute/tree/main/templates"
click node_browser "https://github.com/manaswini-m24/sureroute/blob/main/static/script.js"
click node_map "https://github.com/manaswini-m24/sureroute/blob/main/static/map.js"
click node_web_firebase "https://github.com/manaswini-m24/sureroute/blob/main/static/firebase.js"
click node_app "https://github.com/manaswini-m24/sureroute/blob/main/main.py"
click node_api "https://github.com/manaswini-m24/sureroute/blob/main/backend/routes_api.py"
click node_eta "https://github.com/manaswini-m24/sureroute/blob/main/main.py"
click node_schedule "https://github.com/manaswini-m24/sureroute/blob/main/main.py"
click node_firestore_init "https://github.com/manaswini-m24/sureroute/blob/main/backend/firebase_init.py"
click node_route_import "https://github.com/manaswini-m24/sureroute/blob/main/routesdata.py"
click node_model_artifact "https://github.com/manaswini-m24/sureroute/blob/main/ai_services/ml_training/models/xgboost_eta_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_portals,node_browser,node_map,node_web_firebase toneBlue
class node_app,node_api,node_schedule toneAmber
class node_firestore_init,node_firestore,node_route_import toneMint
class node_eta,node_model_artifact toneRose
class node_passengers,node_drivers toneIndigo
```

## Components

### Web portals

- [Passenger and driver portals](https://github.com/manaswini-m24/sureroute/tree/main/templates): `templates`
- [Portal interactions](https://github.com/manaswini-m24/sureroute/blob/main/static/script.js): `static/script.js`
- [Stops and location map](https://github.com/manaswini-m24/sureroute/blob/main/static/map.js): `static/map.js`
- [Browser Firebase auth](https://github.com/manaswini-m24/sureroute/blob/main/static/firebase.js): `static/firebase.js`

### Application services

- [Web app and pages](https://github.com/manaswini-m24/sureroute/blob/main/main.py): `main.py`
- [Route and status API](https://github.com/manaswini-m24/sureroute/blob/main/backend/routes_api.py): `backend/routes_api.py`
- [Daily status reset](https://github.com/manaswini-m24/sureroute/blob/main/main.py): `main.py`

### Route and live data

- [Firestore access](https://github.com/manaswini-m24/sureroute/blob/main/backend/firebase_init.py): `backend/firebase_init.py`
- **Firestore**
- [Route data import](https://github.com/manaswini-m24/sureroute/blob/main/routesdata.py): `routesdata.py`

### ETA prediction

- [Upcoming trips and ETA](https://github.com/manaswini-m24/sureroute/blob/main/main.py): `main.py`
- [Trained ETA model](https://github.com/manaswini-m24/sureroute/blob/main/ai_services/ml_training/models/xgboost_eta_model.pkl): `ai_services/ml_training/models/xgboost_eta_model.pkl`

### Other components

- **Passengers**
- **Drivers**

## Connections

- Passengers → Passenger and driver portals: use (evidence: `README.md`)
- Drivers → Passenger and driver portals: use (evidence: `README.md`)
- Passenger and driver portals → Web app and pages: request pages (evidence: `main.py`)
- Web app and pages → Route and status API: mounts routes (evidence: `main.py`)
- Passenger and driver portals → Portal interactions: runs scripts
- Portal interactions → Route and status API: fetches routes and stops (evidence: `static/script.js`)
- Portal interactions → Route and status API: posts stop status (evidence: `static/script.js`)
- Portal interactions → Browser Firebase auth: uses auth
- Stops and location map → Route and status API: fetches stops (evidence: `static/map.js`)
- Route and status API → Firestore access: reads and updates (evidence: `backend/routes_api.py`)
- Firestore access → Firestore: reads route data (evidence: `backend/firebase_init.py`)
- Route data import → Firestore: writes routes (evidence: `routesdata.py`)
- Passengers → Upcoming trips and ETA: request arrivals (evidence: `README.md`)
- Web app and pages → Upcoming trips and ETA: handles trip requests (evidence: `main.py`)
- Upcoming trips and ETA → Firestore access: reads stop status (evidence: `main.py`)
- Upcoming trips and ETA → Passengers: returns predicted ETAs (evidence: `README.md`)
- Daily status reset → Firestore access: resets statuses (evidence: `main.py`)
- Upcoming trips and ETA → Trained ETA model: loads model
