# vanshmalhotra1301/saferoad-ai architecture

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

- Interactive diagram: https://gitdiagram.com/vanshmalhotra1301/saferoad-ai
- Repository: https://github.com/vanshmalhotra1301/saferoad-ai

## Overview

SafeRoad AI is a road-accident risk and severity decision-support platform. A user enters road, weather, traffic, and time conditions in the dashboard; the frontend API client requests a prediction from the FastAPI backend, which serves risk and severity inference, and the dashboard presents the result and safety advisories. Separate dashboard branches provide incident trends, metro mapping, model performance, and responsible-AI context. Backend source is indexed as read but not excerpted, so backend internals and model-loading links are shown only where README documentation supports them.

Main entry points: [`frontend/src/App.jsx`](https://github.com/vanshmalhotra1301/saferoad-ai/blob/main/frontend/src/App.jsx) (Dashboard shell), [`frontend/src/services/api.js`](https://github.com/vanshmalhotra1301/saferoad-ai/blob/main/frontend/src/services/api.js) (API client), [`backend/main.py`](https://github.com/vanshmalhotra1301/saferoad-ai/blob/main/backend/main.py) (FastAPI inference API), [`frontend/src/components/RoadRiskAnalyzer.jsx`](https://github.com/vanshmalhotra1301/saferoad-ai/blob/main/frontend/src/components/RoadRiskAnalyzer.jsx) (Condition entry)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_dashboard["Dashboard experience"]
  node_app["Dashboard shell<br/>[App.jsx]"]
  node_navigation["Navigation<br/>[Navbar.jsx]"]
  node_hero["Product overview<br/>[Hero.jsx]"]
  node_problem["Problem context<br/>[ProblemSection.jsx]"]
  node_footer["Dataset references<br/>[Footer.jsx]"]
end

subgraph group_prediction["Risk assessment"]
  node_risk_form["Condition entry"]
  node_api_client["API client<br/>[api.js]"]
  node_risk_result["Risk and severity result<br/>[RiskResult.jsx]"]
end

subgraph group_insights["Insights and transparency"]
  node_safety_insights["Incident trend charts"]
  node_metro_map["Metro risk map<br/>[IndiaRiskMap.jsx]"]
  node_model_insights["Model performance analytics"]
  node_responsible_ai["Responsible AI context<br/>[ResponsibleAI.jsx]"]
  node_impact["Safety impact<br/>[WhyThisMatters.jsx]"]
end

subgraph group_backend["Inference service"]
  node_backend_api["FastAPI inference API<br/>[main.py]"]
  node_model_artifacts["Trained model artifacts"]
  node_incident_data["Road accident datasets"]
end

node_user(("Road safety user"))

node_user -->|"enters conditions"| node_risk_form
node_navigation -->|"opens analyzer"| node_app
node_app -->|"renders"| node_navigation
node_app -->|"renders"| node_hero
node_app -->|"renders"| node_problem
node_app -->|"renders"| node_risk_form
node_app -->|"renders"| node_safety_insights
node_app -->|"renders"| node_model_insights
node_app -->|"renders"| node_impact
node_app -->|"renders"| node_footer
node_risk_form -->|"requests prediction"| node_api_client
node_api_client -->|"posts conditions"| node_backend_api
node_backend_api -->|"returns prediction"| node_api_client
node_backend_api -.->|"runs inference"| node_model_artifacts
node_backend_api -.->|"queries geospatial risk"| node_incident_data
node_risk_form -->|"displays result"| node_risk_result
node_safety_insights -->|"renders optional map"| node_metro_map
node_app -->|"loads insights and stats"| node_api_client
node_api_client -.->|"provides insights"| node_safety_insights
node_api_client -.->|"provides model stats"| node_model_insights
node_app -.->|"renders"| node_responsible_ai

click node_app "https://github.com/vanshmalhotra1301/saferoad-ai/blob/main/frontend/src/App.jsx"
click node_navigation "https://github.com/vanshmalhotra1301/saferoad-ai/blob/main/frontend/src/components/Navbar.jsx"
click node_risk_form "https://github.com/vanshmalhotra1301/saferoad-ai/blob/main/frontend/src/components/RoadRiskAnalyzer.jsx"
click node_api_client "https://github.com/vanshmalhotra1301/saferoad-ai/blob/main/frontend/src/services/api.js"
click node_risk_result "https://github.com/vanshmalhotra1301/saferoad-ai/blob/main/frontend/src/components/RiskResult.jsx"
click node_backend_api "https://github.com/vanshmalhotra1301/saferoad-ai/blob/main/backend/main.py"
click node_model_artifacts "https://github.com/vanshmalhotra1301/saferoad-ai/tree/main/backend/models"
click node_incident_data "https://github.com/vanshmalhotra1301/saferoad-ai/tree/main/backend/data"
click node_safety_insights "https://github.com/vanshmalhotra1301/saferoad-ai/blob/main/frontend/src/components/RoadSafetyInsights.jsx"
click node_metro_map "https://github.com/vanshmalhotra1301/saferoad-ai/blob/main/frontend/src/components/IndiaRiskMap.jsx"
click node_model_insights "https://github.com/vanshmalhotra1301/saferoad-ai/blob/main/frontend/src/components/AIModelInsights.jsx"
click node_responsible_ai "https://github.com/vanshmalhotra1301/saferoad-ai/blob/main/frontend/src/components/ResponsibleAI.jsx"
click node_hero "https://github.com/vanshmalhotra1301/saferoad-ai/blob/main/frontend/src/components/Hero.jsx"
click node_problem "https://github.com/vanshmalhotra1301/saferoad-ai/blob/main/frontend/src/components/ProblemSection.jsx"
click node_impact "https://github.com/vanshmalhotra1301/saferoad-ai/blob/main/frontend/src/components/WhyThisMatters.jsx"
click node_footer "https://github.com/vanshmalhotra1301/saferoad-ai/blob/main/frontend/src/components/Footer.jsx"

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_app,node_navigation,node_hero,node_problem,node_footer,node_user toneBlue
class node_risk_form,node_api_client,node_risk_result toneAmber
class node_safety_insights,node_metro_map,node_model_insights,node_responsible_ai,node_impact toneMint
class node_backend_api,node_model_artifacts,node_incident_data toneRose
```

## Components

### Dashboard experience

- [Dashboard shell](https://github.com/vanshmalhotra1301/saferoad-ai/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Navigation](https://github.com/vanshmalhotra1301/saferoad-ai/blob/main/frontend/src/components/Navbar.jsx): `frontend/src/components/Navbar.jsx`
- [Product overview](https://github.com/vanshmalhotra1301/saferoad-ai/blob/main/frontend/src/components/Hero.jsx): `frontend/src/components/Hero.jsx`
- [Problem context](https://github.com/vanshmalhotra1301/saferoad-ai/blob/main/frontend/src/components/ProblemSection.jsx): `frontend/src/components/ProblemSection.jsx`
- [Dataset references](https://github.com/vanshmalhotra1301/saferoad-ai/blob/main/frontend/src/components/Footer.jsx): `frontend/src/components/Footer.jsx`

### Risk assessment

- [Condition entry](https://github.com/vanshmalhotra1301/saferoad-ai/blob/main/frontend/src/components/RoadRiskAnalyzer.jsx): `frontend/src/components/RoadRiskAnalyzer.jsx`
- [API client](https://github.com/vanshmalhotra1301/saferoad-ai/blob/main/frontend/src/services/api.js): `frontend/src/services/api.js`
- [Risk and severity result](https://github.com/vanshmalhotra1301/saferoad-ai/blob/main/frontend/src/components/RiskResult.jsx): `frontend/src/components/RiskResult.jsx`

### Insights and transparency

- [Incident trend charts](https://github.com/vanshmalhotra1301/saferoad-ai/blob/main/frontend/src/components/RoadSafetyInsights.jsx): `frontend/src/components/RoadSafetyInsights.jsx`
- [Metro risk map](https://github.com/vanshmalhotra1301/saferoad-ai/blob/main/frontend/src/components/IndiaRiskMap.jsx): `frontend/src/components/IndiaRiskMap.jsx`
- [Model performance analytics](https://github.com/vanshmalhotra1301/saferoad-ai/blob/main/frontend/src/components/AIModelInsights.jsx): `frontend/src/components/AIModelInsights.jsx`
- [Responsible AI context](https://github.com/vanshmalhotra1301/saferoad-ai/blob/main/frontend/src/components/ResponsibleAI.jsx): `frontend/src/components/ResponsibleAI.jsx`
- [Safety impact](https://github.com/vanshmalhotra1301/saferoad-ai/blob/main/frontend/src/components/WhyThisMatters.jsx): `frontend/src/components/WhyThisMatters.jsx`

### Inference service

- [FastAPI inference API](https://github.com/vanshmalhotra1301/saferoad-ai/blob/main/backend/main.py): `backend/main.py`
- [Trained model artifacts](https://github.com/vanshmalhotra1301/saferoad-ai/tree/main/backend/models): `backend/models`
- [Road accident datasets](https://github.com/vanshmalhotra1301/saferoad-ai/tree/main/backend/data): `backend/data`

### Other components

- **Road safety user**

## Connections

- Road safety user → Condition entry: enters conditions (evidence: `README.md`)
- Navigation → Dashboard shell: opens analyzer (evidence: `frontend/src/App.jsx`)
- Dashboard shell → Navigation: renders (evidence: `frontend/src/App.jsx`)
- Dashboard shell → Product overview: renders (evidence: `frontend/src/App.jsx`)
- Dashboard shell → Problem context: renders (evidence: `frontend/src/App.jsx`)
- Dashboard shell → Condition entry: renders (evidence: `frontend/src/App.jsx`)
- Dashboard shell → Incident trend charts: renders (evidence: `frontend/src/App.jsx`)
- Dashboard shell → Model performance analytics: renders (evidence: `frontend/src/App.jsx`)
- Dashboard shell → Safety impact: renders (evidence: `frontend/src/App.jsx`)
- Dashboard shell → Dataset references: renders (evidence: `frontend/src/App.jsx`)
- Condition entry → API client: requests prediction (evidence: `frontend/src/services/api.js`)
- API client → FastAPI inference API: posts conditions (evidence: `frontend/src/services/api.js`)
- FastAPI inference API → API client: returns prediction (evidence: `README.md`)
- FastAPI inference API → Trained model artifacts: runs inference
- FastAPI inference API → Road accident datasets: queries geospatial risk
- Condition entry → Risk and severity result: displays result (evidence: `frontend/src/components/RoadRiskAnalyzer.jsx`)
- Incident trend charts → Metro risk map: renders optional map (evidence: `frontend/src/components/RoadSafetyInsights.jsx`)
- Dashboard shell → API client: loads insights and stats (evidence: `frontend/src/App.jsx`)
- API client → Incident trend charts: provides insights
- API client → Model performance analytics: provides model stats
- Dashboard shell → Responsible AI context: renders
