# rajesh-22114/accident-detection architecture

> Architecture diagram of the GitHub repository rajesh-22114/accident-detection, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/rajesh-22114/accident-detection
- Repository: https://github.com/rajesh-22114/accident-detection

## Overview

This is a Flask image-classification application for detecting traffic accidents. The main workflow is: a user submits an image URL, the app preprocesses the downloaded image, runs TensorFlow Lite inference, and returns an accident/non-accident label. The README also documents Xception transfer learning and local training; the notebook is present, but its contents were not sampled, so its internal steps and wiring are not represented.

Main entry points: [`app.py`](https://github.com/rajesh-22114/accident-detection/blob/main/app.py) (Flask app), [`accident_model.tflite`](https://github.com/rajesh-22114/accident-detection/blob/main/accident_model.tflite) (TFLite model), [`capstone.ipynb`](https://github.com/rajesh-22114/accident-detection/blob/main/capstone.ipynb) (Xception training), [`templates/index.html`](https://github.com/rajesh-22114/accident-detection/blob/main/templates/index.html) (Prediction page)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web application"]
  node_app["Flask app<br/>[app.py]"]
  node_page["Prediction page<br/>[index.html]"]
end

subgraph group_inference["Image inference"]
  node_preprocess["Image preprocessing<br/>[app.py]"]
  node_interpreter["TFLite interpreter<br/>[app.py]"]
  node_model["TFLite model"]
  node_prediction["Class prediction<br/>[app.py]"]
end

subgraph group_modeling["Model development"]
  node_training["Xception training<br/>[capstone.ipynb]"]
end

node_user(("User"))

node_user -->|"submits image URL"| node_app
node_app -->|"renders page"| node_page
node_app -->|"preprocesses URL"| node_preprocess
node_app -->|"invokes inference"| node_interpreter
node_interpreter -->|"loads model"| node_model
node_app -->|"selects class"| node_prediction
node_app -->|"returns prediction"| node_user
node_training -->|"exports model"| node_model

click node_app "https://github.com/rajesh-22114/accident-detection/blob/main/app.py"
click node_page "https://github.com/rajesh-22114/accident-detection/blob/main/templates/index.html"
click node_preprocess "https://github.com/rajesh-22114/accident-detection/blob/main/app.py"
click node_interpreter "https://github.com/rajesh-22114/accident-detection/blob/main/app.py"
click node_model "https://github.com/rajesh-22114/accident-detection/blob/main/accident_model.tflite"
click node_prediction "https://github.com/rajesh-22114/accident-detection/blob/main/app.py"
click node_training "https://github.com/rajesh-22114/accident-detection/blob/main/capstone.ipynb"

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_page,node_user toneBlue
class node_preprocess,node_interpreter,node_model,node_prediction toneAmber
class node_training toneMint
```

## Components

### Web application

- [Flask app](https://github.com/rajesh-22114/accident-detection/blob/main/app.py): `app.py`
- [Prediction page](https://github.com/rajesh-22114/accident-detection/blob/main/templates/index.html): `templates/index.html`

### Image inference

- [Image preprocessing](https://github.com/rajesh-22114/accident-detection/blob/main/app.py): `app.py`
- [TFLite interpreter](https://github.com/rajesh-22114/accident-detection/blob/main/app.py): `app.py`
- [TFLite model](https://github.com/rajesh-22114/accident-detection/blob/main/accident_model.tflite): `accident_model.tflite`
- [Class prediction](https://github.com/rajesh-22114/accident-detection/blob/main/app.py): `app.py`

### Model development

- [Xception training](https://github.com/rajesh-22114/accident-detection/blob/main/capstone.ipynb): `capstone.ipynb`

### Other components

- **User**

## Connections

- User → Flask app: submits image URL
- Flask app → Prediction page: renders page
- Flask app → Image preprocessing: preprocesses URL
- Flask app → TFLite interpreter: invokes inference
- TFLite interpreter → TFLite model: loads model
- Flask app → Class prediction: selects class
- Flask app → User: returns prediction
- Xception training → TFLite model: exports model
