# harman7-hash/sih_2025 architecture

> Architecture diagram of the GitHub repository harman7-hash/sih_2025, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-08-21). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/harman7-hash/sih_2025
- Repository: https://github.com/harman7-hash/sih_2025

## Overview

#### Purpose and entry points
This repository implements a bus-transit application centered on live bus tracking, route discovery, trip planning, schedules, delay estimation, and recommendations. It has separate frontend and backend applications plus legacy/server-rendered EJS views.

Primary entry points:
- Frontend SPA bootstrap: `Frontend/src/main.jsx`
- Frontend application shell: `Frontend/src/Layout.jsx`
- Backend HTTP server: `Backend/server.js`
- Server-rendered landing page assets: `views/landingpage.ejs`, `views/partials/nav.ejs`

#### Frontend application shell and navigation
The frontend is a Vite-based React application. `Frontend/src/main.jsx` mounts the client application, while `Frontend/src/Layout.jsx` likely defines persistent page structure around header, footer, and routed content.

The UI is organized as feature pages rather than a generic component library:
- Home and general information: `Frontend/src/components/Home/Home.jsx`, `Frontend/src/components/About/About.jsx`
- Global navigation and branding: `Frontend/src/components/Header/Header.jsx`, `Frontend/src/components/Footer/Footer.jsx`
- Shared application state boundary: `Frontend/src/context/AppContext.jsx`

Styling is split between global CSS and application/page styles: `Frontend/src/index.css`, `Frontend/src/App.css`.

#### Bus tracking and map experience
Live-tracking functionality is concentrated in the bus tracker feature:
- Tracker UI/controller: `Frontend/src/components/Bustracker/Bustracker.jsx`
- Map-facing screen: `Frontend/src/components/Bustracker/MapPage.jsx`
- Bus-specific UI/type component: `Frontend/src/components/Bustracker/bus.tsx`

The frontend also includes map animation support in `Frontend/src/utils/map-animation.ts`, suggesting position updates are rendered or interpolated client-side. A standalone public tracker page exists at `Frontend/public/tracker.html`, potentially serving an embeddable or separately launched tracker experience.

#### Route planning and rider-facing features
Trip planning and route lookup are distinct frontend capabilities:
- Trip-planning page: `Frontend/src/components/Planyourtrip/Planyoutrip.jsx`
- Route finder: `Frontend/src/components/RouteFinder.jsx`
- Schedule display: `Frontend/src/components/Schedule/Schedule.jsx`

Supporting rider-facing workflows include feedback and FAQ pages:
- `Frontend/src/components/Feedback/Feedback.jsx`
- `Frontend/src/components/FAQs/faqs.jsx`

These features form the primary user flow: select or search transit options, inspect routes/schedules, then follow a bus on the tracking map.

#### Backend transit-data pipeline
The Node backend contains focused modules for acquiring, transforming, persisting, and serving transit data:
- Data retrieval/import: `Backend/fetchData.js`, `Backend/directImport.js`
- Route extraction/assembly: `Backend/gettingRoutes.js`
- Static/local bus data: `Backend/buses.json`
- Persistence writing: `Backend/writeData.js`

This establishes a data boundary between external or imported transit feeds and frontend-consumable route/bus records. `Backend/server.js` is the likely integration point that exposes these capabilities over HTTP.

#### Location, prediction, and persistence services
Bus state and prediction logic are separated into backend modules:
- GPS/location handling: `Backend/GPS.js`
- Bus movement/state updates: `Backend/moveBus.js`
- Delay calculation: `Backend/calcDelay.js`
- Rider or route recommendations: `Backend/recommendation.js`

Persistence infrastructure is indicated by:
- Database connection abstraction: `Backend/connectDB.js`
- Firebase integration: `Backend/firebase.js`

The exact database engine and external transit/feed provider are not identifiable from the provided tree, but Firebase and at least one additional database connection layer are material service boundaries. Backend dependencies and runtime configuration are defined by `Backend/package.json`; the frontend build/runtime dependencies are in `Frontend/package.json`.

Main entry points: [`Backend/server.js`](https://github.com/harman7-hash/sih_2025/blob/main/Backend/server.js) (HTTP server), [`Frontend/src/Layout.jsx`](https://github.com/harman7-hash/sih_2025/blob/main/Frontend/src/Layout.jsx) (App shell), [`Frontend/src/components/Bustracker/Bustracker.jsx`](https://github.com/harman7-hash/sih_2025/blob/main/Frontend/src/components/Bustracker/Bustracker.jsx) (Bus tracker), [`Backend/gettingRoutes.js`](https://github.com/harman7-hash/sih_2025/blob/main/Backend/gettingRoutes.js) (Route assembly)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["React frontend"]
  node_spa_bootstrap["SPA bootstrap<br/>React entry<br/>[main.jsx]"]
  node_app_shell["App shell<br/>layout and routing<br/>[Layout.jsx]"]
  node_app_context["App context<br/>shared state<br/>[AppContext.jsx]"]
  node_navigation["Header and footer<br/>navigation UI<br/>[Header.jsx]"]
  node_home_info["Home and about<br/>information pages<br/>[Home.jsx]"]
  node_tracker["Bus tracker<br/>tracking controller<br/>[Bustracker.jsx]"]
  node_tracking_map["Tracking map<br/>map screen<br/>[MapPage.jsx]"]
  node_map_animation["Map animation<br/>position interpolation<br/>[map-animation.ts]"]
  node_trip_planning["Trip planning<br/>rider workflow<br/>[Planyoutrip.jsx]"]
  node_route_schedule["Route and schedule<br/>transit lookup UI<br/>[RouteFinder.jsx]"]
  node_rider_support["Feedback and FAQs<br/>support pages<br/>[Feedback.jsx]"]
end

subgraph group_backend["Transit backend"]
  node_http_server{{"HTTP server<br/>Node API<br/>[server.js]"}}
  node_transit_import["Transit import<br/>feed acquisition<br/>[fetchData.js]"]
  node_route_assembly["Route assembly<br/>data transformation<br/>[gettingRoutes.js]"]
  node_bus_state["Bus state updates<br/>GPS movement<br/>[moveBus.js]"]
  node_delay_recommendations["Delay and recommendations<br/>prediction service<br/>[calcDelay.js]"]
end

subgraph group_data["Data services"]
  node_transit_records[("Transit records<br/>persisted bus data<br/>[buses.json]")]
  node_database[("Database connection<br/>persistence adapter<br/>[connectDB.js]")]
  node_firebase[("Firebase<br/>cloud integration<br/>[firebase.js]")]
end

node_legacy_landing["Legacy landing page<br/>server-rendered EJS<br/>[landingpage.ejs]"]

node_spa_bootstrap -->|"mounts"| node_app_shell
node_app_shell -->|"uses"| node_app_context
node_app_shell -->|"renders"| node_navigation
node_app_shell -->|"routes to"| node_home_info
node_app_shell -->|"routes to"| node_tracker
node_app_shell -->|"routes to"| node_trip_planning
node_app_shell -->|"routes to"| node_route_schedule
node_tracker -->|"renders"| node_tracking_map
node_tracking_map -->|"animates positions"| node_map_animation
node_tracker -->|"live transit requests"| node_http_server
node_trip_planning -->|"plans via"| node_http_server
node_route_schedule -->|"queries"| node_http_server
node_http_server -->|"serves routes"| node_route_assembly
node_http_server -->|"serves live state"| node_bus_state
node_http_server -->|"serves predictions"| node_delay_recommendations
node_transit_import -->|"supplies feed data"| node_route_assembly
node_route_assembly -->|"writes records"| node_transit_records
node_bus_state -->|"updates positions"| node_transit_records
node_delay_recommendations -->|"uses movement state"| node_bus_state
node_http_server -->|"persists through"| node_database
node_http_server -->|"integrates with"| node_firebase
node_legacy_landing -.->|"served by"| node_http_server

click node_spa_bootstrap "https://github.com/harman7-hash/sih_2025/blob/main/Frontend/src/main.jsx"
click node_app_shell "https://github.com/harman7-hash/sih_2025/blob/main/Frontend/src/Layout.jsx"
click node_app_context "https://github.com/harman7-hash/sih_2025/blob/main/Frontend/src/context/AppContext.jsx"
click node_navigation "https://github.com/harman7-hash/sih_2025/blob/main/Frontend/src/components/Header/Header.jsx"
click node_home_info "https://github.com/harman7-hash/sih_2025/blob/main/Frontend/src/components/Home/Home.jsx"
click node_tracker "https://github.com/harman7-hash/sih_2025/blob/main/Frontend/src/components/Bustracker/Bustracker.jsx"
click node_tracking_map "https://github.com/harman7-hash/sih_2025/blob/main/Frontend/src/components/Bustracker/MapPage.jsx"
click node_map_animation "https://github.com/harman7-hash/sih_2025/blob/main/Frontend/src/utils/map-animation.ts"
click node_trip_planning "https://github.com/harman7-hash/sih_2025/blob/main/Frontend/src/components/Planyourtrip/Planyoutrip.jsx"
click node_route_schedule "https://github.com/harman7-hash/sih_2025/blob/main/Frontend/src/components/RouteFinder.jsx"
click node_rider_support "https://github.com/harman7-hash/sih_2025/blob/main/Frontend/src/components/Feedback/Feedback.jsx"
click node_http_server "https://github.com/harman7-hash/sih_2025/blob/main/Backend/server.js"
click node_transit_import "https://github.com/harman7-hash/sih_2025/blob/main/Backend/fetchData.js"
click node_route_assembly "https://github.com/harman7-hash/sih_2025/blob/main/Backend/gettingRoutes.js"
click node_bus_state "https://github.com/harman7-hash/sih_2025/blob/main/Backend/moveBus.js"
click node_delay_recommendations "https://github.com/harman7-hash/sih_2025/blob/main/Backend/calcDelay.js"
click node_transit_records "https://github.com/harman7-hash/sih_2025/blob/main/Backend/buses.json"
click node_database "https://github.com/harman7-hash/sih_2025/blob/main/Backend/connectDB.js"
click node_firebase "https://github.com/harman7-hash/sih_2025/blob/main/Backend/firebase.js"
click node_legacy_landing "https://github.com/harman7-hash/sih_2025/blob/main/views/landingpage.ejs"

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_spa_bootstrap,node_app_shell,node_app_context,node_navigation,node_home_info,node_tracker,node_tracking_map,node_map_animation,node_trip_planning,node_route_schedule,node_rider_support toneBlue
class node_http_server,node_transit_import,node_route_assembly,node_bus_state,node_delay_recommendations toneAmber
class node_transit_records,node_database,node_firebase toneMint
class node_legacy_landing toneNeutral
```

## Components

### React frontend

- [SPA bootstrap](https://github.com/harman7-hash/sih_2025/blob/main/Frontend/src/main.jsx): React entry · `Frontend/src/main.jsx`
- [App shell](https://github.com/harman7-hash/sih_2025/blob/main/Frontend/src/Layout.jsx): layout and routing · `Frontend/src/Layout.jsx`
- [App context](https://github.com/harman7-hash/sih_2025/blob/main/Frontend/src/context/AppContext.jsx): shared state · `Frontend/src/context/AppContext.jsx`
- [Header and footer](https://github.com/harman7-hash/sih_2025/blob/main/Frontend/src/components/Header/Header.jsx): navigation UI · `Frontend/src/components/Header/Header.jsx`
- [Home and about](https://github.com/harman7-hash/sih_2025/blob/main/Frontend/src/components/Home/Home.jsx): information pages · `Frontend/src/components/Home/Home.jsx`
- [Bus tracker](https://github.com/harman7-hash/sih_2025/blob/main/Frontend/src/components/Bustracker/Bustracker.jsx): tracking controller · `Frontend/src/components/Bustracker/Bustracker.jsx`
- [Tracking map](https://github.com/harman7-hash/sih_2025/blob/main/Frontend/src/components/Bustracker/MapPage.jsx): map screen · `Frontend/src/components/Bustracker/MapPage.jsx`
- [Map animation](https://github.com/harman7-hash/sih_2025/blob/main/Frontend/src/utils/map-animation.ts): position interpolation · `Frontend/src/utils/map-animation.ts`
- [Trip planning](https://github.com/harman7-hash/sih_2025/blob/main/Frontend/src/components/Planyourtrip/Planyoutrip.jsx): rider workflow · `Frontend/src/components/Planyourtrip/Planyoutrip.jsx`
- [Route and schedule](https://github.com/harman7-hash/sih_2025/blob/main/Frontend/src/components/RouteFinder.jsx): transit lookup UI · `Frontend/src/components/RouteFinder.jsx`
- [Feedback and FAQs](https://github.com/harman7-hash/sih_2025/blob/main/Frontend/src/components/Feedback/Feedback.jsx): support pages · `Frontend/src/components/Feedback/Feedback.jsx`

### Transit backend

- [HTTP server](https://github.com/harman7-hash/sih_2025/blob/main/Backend/server.js): Node API · Exposes transit data and application services. · `Backend/server.js`
- [Transit import](https://github.com/harman7-hash/sih_2025/blob/main/Backend/fetchData.js): feed acquisition · `Backend/fetchData.js`
- [Route assembly](https://github.com/harman7-hash/sih_2025/blob/main/Backend/gettingRoutes.js): data transformation · `Backend/gettingRoutes.js`
- [Bus state updates](https://github.com/harman7-hash/sih_2025/blob/main/Backend/moveBus.js): GPS movement · `Backend/moveBus.js`
- [Delay and recommendations](https://github.com/harman7-hash/sih_2025/blob/main/Backend/calcDelay.js): prediction service · `Backend/calcDelay.js`

### Data services

- [Transit records](https://github.com/harman7-hash/sih_2025/blob/main/Backend/buses.json): persisted bus data · `Backend/buses.json`
- [Database connection](https://github.com/harman7-hash/sih_2025/blob/main/Backend/connectDB.js): persistence adapter · `Backend/connectDB.js`
- [Firebase](https://github.com/harman7-hash/sih_2025/blob/main/Backend/firebase.js): cloud integration · `Backend/firebase.js`

### Other components

- [Legacy landing page](https://github.com/harman7-hash/sih_2025/blob/main/views/landingpage.ejs): server-rendered EJS · `views/landingpage.ejs`

## Connections

- SPA bootstrap → App shell: mounts
- App shell → App context: uses
- App shell → Header and footer: renders
- App shell → Home and about: routes to
- App shell → Bus tracker: routes to
- App shell → Trip planning: routes to
- App shell → Route and schedule: routes to
- Bus tracker → Tracking map: renders
- Tracking map → Map animation: animates positions
- Bus tracker → HTTP server: live transit requests
- Trip planning → HTTP server: plans via
- Route and schedule → HTTP server: queries
- HTTP server → Route assembly: serves routes
- HTTP server → Bus state updates: serves live state
- HTTP server → Delay and recommendations: serves predictions
- Transit import → Route assembly: supplies feed data
- Route assembly → Transit records: writes records
- Bus state updates → Transit records: updates positions
- Delay and recommendations → Bus state updates: uses movement state
- HTTP server → Database connection: persists through
- HTTP server → Firebase: integrates with
- Legacy landing page → HTTP server: served by
