# divyanshichaturvedi/road-accident-severity-prediction architecture

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

- Interactive diagram: https://gitdiagram.com/divyanshichaturvedi/road-accident-severity-prediction
- Repository: https://github.com/divyanshichaturvedi/road-accident-severity-prediction

## Overview

This repository provides a Streamlit road-accident severity dashboard and a training pipeline. Training generates or reads accident records, encodes and scales features, fits and evaluates seven classifiers, and saves models and preprocessing artifacts. In the dashboard, users inspect accident data or enter conditions; the app loads saved artifacts, predicts severity, and presents probabilities and safety advice. The README documents the dashboard capabilities; unsampled app code limits detail about page routing and data visualizations.

Main entry points: [`app.py`](https://github.com/divyanshichaturvedi/road-accident-severity-prediction/blob/main/app.py) (Streamlit dashboard), [`models`](https://github.com/divyanshichaturvedi/road-accident-severity-prediction/tree/main/models) (Models and encoders), [`train_model.py`](https://github.com/divyanshichaturvedi/road-accident-severity-prediction/blob/main/train_model.py) (Encoding and scaling), [`data/RTA Dataset.csv`](https://github.com/divyanshichaturvedi/road-accident-severity-prediction/blob/main/data/RTA%20Dataset.csv) (Accident dataset)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_training["Data and training"]
  node_trainer["Training pipeline<br/>[train_model.py]"]
  node_dataset["Accident dataset<br/>[RTA Dataset.csv]"]
  node_preprocessing["Encoding and scaling<br/>[train_model.py]"]
  node_model_training["Classifier training<br/>[train_model.py]"]
  node_evaluation["Model evaluation<br/>[train_model.py]"]
end

subgraph group_artifacts["Saved artifacts"]
  node_saved_models["Models and encoders"]
end

subgraph group_dashboard["Dashboard and prediction"]
  node_dashboard_app["Streamlit dashboard<br/>[app.py]"]
  node_data_overview["Data overview<br/>[app.py]"]
  node_input_form["Accident inputs<br/>[app.py]"]
  node_prediction["Severity prediction<br/>[app.py]"]
  node_result_view["Results and advice<br/>[app.py]"]
end

node_user(("Dashboard user"))

node_trainer -->|"generates and saves"| node_dataset
node_trainer -->|"prepares features"| node_preprocessing
node_preprocessing -->|"provides scaled data"| node_model_training
node_model_training -->|"predicts test set"| node_evaluation
node_model_training -->|"saves classifiers"| node_saved_models
node_preprocessing -->|"saves encoders and scaler"| node_saved_models
node_evaluation -->|"saves summary"| node_saved_models
node_user -->|"opens dashboard"| node_dashboard_app
node_dashboard_app -->|"loads records"| node_dataset
node_dashboard_app -->|"loads artifacts"| node_saved_models
node_dashboard_app -->|"shows data analysis"| node_data_overview
node_user -->|"enters conditions"| node_input_form
node_input_form -->|"submits features"| node_prediction
node_dashboard_app -->|"predicts severity"| node_prediction
node_prediction -->|"displays prediction"| node_result_view

click node_trainer "https://github.com/divyanshichaturvedi/road-accident-severity-prediction/blob/main/train_model.py"
click node_dataset "https://github.com/divyanshichaturvedi/road-accident-severity-prediction/blob/main/data/RTA%20Dataset.csv"
click node_preprocessing "https://github.com/divyanshichaturvedi/road-accident-severity-prediction/blob/main/train_model.py"
click node_model_training "https://github.com/divyanshichaturvedi/road-accident-severity-prediction/blob/main/train_model.py"
click node_evaluation "https://github.com/divyanshichaturvedi/road-accident-severity-prediction/blob/main/train_model.py"
click node_saved_models "https://github.com/divyanshichaturvedi/road-accident-severity-prediction/tree/main/models"
click node_dashboard_app "https://github.com/divyanshichaturvedi/road-accident-severity-prediction/blob/main/app.py"
click node_data_overview "https://github.com/divyanshichaturvedi/road-accident-severity-prediction/blob/main/app.py"
click node_input_form "https://github.com/divyanshichaturvedi/road-accident-severity-prediction/blob/main/app.py"
click node_prediction "https://github.com/divyanshichaturvedi/road-accident-severity-prediction/blob/main/app.py"
click node_result_view "https://github.com/divyanshichaturvedi/road-accident-severity-prediction/blob/main/app.py"

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_trainer,node_dataset,node_preprocessing,node_model_training,node_evaluation,node_user toneBlue
class node_saved_models toneAmber
class node_dashboard_app,node_data_overview,node_input_form,node_prediction,node_result_view toneMint
```

## Components

### Data and training

- [Training pipeline](https://github.com/divyanshichaturvedi/road-accident-severity-prediction/blob/main/train_model.py): `train_model.py`
- [Accident dataset](https://github.com/divyanshichaturvedi/road-accident-severity-prediction/blob/main/data/RTA%20Dataset.csv): `data/RTA Dataset.csv`
- [Encoding and scaling](https://github.com/divyanshichaturvedi/road-accident-severity-prediction/blob/main/train_model.py): `train_model.py`
- [Classifier training](https://github.com/divyanshichaturvedi/road-accident-severity-prediction/blob/main/train_model.py): `train_model.py`
- [Model evaluation](https://github.com/divyanshichaturvedi/road-accident-severity-prediction/blob/main/train_model.py): `train_model.py`

### Saved artifacts

- [Models and encoders](https://github.com/divyanshichaturvedi/road-accident-severity-prediction/tree/main/models): `models`

### Dashboard and prediction

- [Streamlit dashboard](https://github.com/divyanshichaturvedi/road-accident-severity-prediction/blob/main/app.py): `app.py`
- [Data overview](https://github.com/divyanshichaturvedi/road-accident-severity-prediction/blob/main/app.py): `app.py`
- [Accident inputs](https://github.com/divyanshichaturvedi/road-accident-severity-prediction/blob/main/app.py): `app.py`
- [Severity prediction](https://github.com/divyanshichaturvedi/road-accident-severity-prediction/blob/main/app.py): `app.py`
- [Results and advice](https://github.com/divyanshichaturvedi/road-accident-severity-prediction/blob/main/app.py): `app.py`

### Other components

- **Dashboard user**

## Connections

- Training pipeline → Accident dataset: generates and saves (evidence: `train_model.py`)
- Training pipeline → Encoding and scaling: prepares features (evidence: `train_model.py`)
- Encoding and scaling → Classifier training: provides scaled data (evidence: `train_model.py`)
- Classifier training → Model evaluation: predicts test set (evidence: `train_model.py`)
- Classifier training → Models and encoders: saves classifiers (evidence: `train_model.py`)
- Encoding and scaling → Models and encoders: saves encoders and scaler (evidence: `train_model.py`)
- Model evaluation → Models and encoders: saves summary (evidence: `train_model.py`)
- Dashboard user → Streamlit dashboard: opens dashboard (evidence: `README.md`)
- Streamlit dashboard → Accident dataset: loads records (evidence: `app.py`)
- Streamlit dashboard → Models and encoders: loads artifacts (evidence: `app.py`)
- Streamlit dashboard → Data overview: shows data analysis (evidence: `README.md`)
- Dashboard user → Accident inputs: enters conditions (evidence: `app.py`)
- Accident inputs → Severity prediction: submits features (evidence: `app.py`)
- Streamlit dashboard → Severity prediction: predicts severity (evidence: `app.py`)
- Severity prediction → Results and advice: displays prediction (evidence: `app.py`)
