# sharath3002/pothole_detection architecture

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

- Interactive diagram: https://gitdiagram.com/sharath3002/pothole_detection
- Repository: https://github.com/sharath3002/pothole_detection

## Overview

This Flask application detects potholes in submitted images, saves annotated detections and their coordinates, and exposes a map view of stored reports. Its main runtime flow is image submission → YOLO inference → annotated-image response, with detected potholes also persisted for later retrieval. The README also shows video-output and performance-log demos, but the sampled source does not establish their implementation; the map page’s client-side behavior is likewise not shown.

Main entry points: [`app.py`](https://github.com/sharath3002/pothole_detection/blob/main/app.py) (Flask routes), [`templates/index.html`](https://github.com/sharath3002/pothole_detection/blob/main/templates/index.html) (Home page), [`templates/map.html`](https://github.com/sharath3002/pothole_detection/blob/main/templates/map.html) (Map page), [`models/best_saved_model/best_float16.tflite`](https://github.com/sharath3002/pothole_detection/blob/main/models/best_saved_model/best_float16.tflite) (YOLO model)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web Interface"]
  node_flask["Flask routes<br/>[app.py]"]
  node_home["Home page<br/>[index.html]"]
  node_map["Map page<br/>[map.html]"]
end

subgraph group_detection["Pothole Detection"]
  node_inference["YOLO inference<br/>[app.py]"]
  node_model["YOLO model"]
  node_image_decode["Image decoding<br/>[app.py]"]
  node_image_annotate["Frame annotation<br/>[app.py]"]
  node_image_encode["Response encoding<br/>[app.py]"]
  node_video_metrics["Video and metrics demos<br/>[README.md]"]
end

subgraph group_reports["Reports and Storage"]
  node_pothole_record["Pothole record<br/>[app.py]"]
  node_postgres[("PostgreSQL<br/>[app.py]")]
  node_image_files["Saved images<br/>[app.py]"]
end

node_user(("User"))

node_user -->|"submits image"| node_flask
node_flask -->|"renders"| node_home
node_flask -->|"renders"| node_map
node_flask -->|"decodes input"| node_image_decode
node_image_decode -->|"passes frame"| node_inference
node_inference -->|"predicts with"| node_model
node_inference -->|"plots detections"| node_image_annotate
node_image_annotate -->|"writes image"| node_image_files
node_image_annotate -->|"sets report image"| node_pothole_record
node_pothole_record -->|"commits report"| node_postgres
node_image_annotate -->|"encodes result"| node_image_encode
node_image_encode -->|"returns response"| node_flask
node_flask -->|"queries reports"| node_postgres
node_flask -->|"returns map data"| node_user

click node_flask "https://github.com/sharath3002/pothole_detection/blob/main/app.py"
click node_home "https://github.com/sharath3002/pothole_detection/blob/main/templates/index.html"
click node_map "https://github.com/sharath3002/pothole_detection/blob/main/templates/map.html"
click node_inference "https://github.com/sharath3002/pothole_detection/blob/main/app.py"
click node_model "https://github.com/sharath3002/pothole_detection/blob/main/models/best_saved_model/best_float16.tflite"
click node_image_decode "https://github.com/sharath3002/pothole_detection/blob/main/app.py"
click node_image_annotate "https://github.com/sharath3002/pothole_detection/blob/main/app.py"
click node_image_encode "https://github.com/sharath3002/pothole_detection/blob/main/app.py"
click node_pothole_record "https://github.com/sharath3002/pothole_detection/blob/main/app.py"
click node_postgres "https://github.com/sharath3002/pothole_detection/blob/main/app.py"
click node_image_files "https://github.com/sharath3002/pothole_detection/blob/main/app.py"
click node_video_metrics "https://github.com/sharath3002/pothole_detection/blob/main/README.md"

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_flask,node_home,node_map,node_user toneBlue
class node_inference,node_model,node_image_decode,node_image_annotate,node_image_encode,node_video_metrics toneAmber
class node_pothole_record,node_postgres,node_image_files toneMint
```

## Components

### Web Interface

- [Flask routes](https://github.com/sharath3002/pothole_detection/blob/main/app.py): `app.py`
- [Home page](https://github.com/sharath3002/pothole_detection/blob/main/templates/index.html): `templates/index.html`
- [Map page](https://github.com/sharath3002/pothole_detection/blob/main/templates/map.html): `templates/map.html`

### Pothole Detection

- [YOLO inference](https://github.com/sharath3002/pothole_detection/blob/main/app.py): `app.py`
- [YOLO model](https://github.com/sharath3002/pothole_detection/blob/main/models/best_saved_model/best_float16.tflite): `models/best_saved_model/best_float16.tflite`
- [Image decoding](https://github.com/sharath3002/pothole_detection/blob/main/app.py): `app.py`
- [Frame annotation](https://github.com/sharath3002/pothole_detection/blob/main/app.py): `app.py`
- [Response encoding](https://github.com/sharath3002/pothole_detection/blob/main/app.py): `app.py`
- [Video and metrics demos](https://github.com/sharath3002/pothole_detection/blob/main/README.md): `README.md`

### Reports and Storage

- [Pothole record](https://github.com/sharath3002/pothole_detection/blob/main/app.py): `app.py`
- [PostgreSQL](https://github.com/sharath3002/pothole_detection/blob/main/app.py): `app.py`
- [Saved images](https://github.com/sharath3002/pothole_detection/blob/main/app.py): `app.py`

### Other components

- **User**

## Connections

- User → Flask routes: submits image (evidence: `app.py`)
- Flask routes → Home page: renders (evidence: `app.py`)
- Flask routes → Map page: renders (evidence: `app.py`)
- Flask routes → Image decoding: decodes input (evidence: `app.py`)
- Image decoding → YOLO inference: passes frame (evidence: `app.py`)
- YOLO inference → YOLO model: predicts with (evidence: `app.py`)
- YOLO inference → Frame annotation: plots detections (evidence: `app.py`)
- Frame annotation → Saved images: writes image (evidence: `app.py`)
- Frame annotation → Pothole record: sets report image (evidence: `app.py`)
- Pothole record → PostgreSQL: commits report (evidence: `app.py`)
- Frame annotation → Response encoding: encodes result (evidence: `app.py`)
- Response encoding → Flask routes: returns response (evidence: `app.py`)
- Flask routes → PostgreSQL: queries reports (evidence: `app.py`)
- Flask routes → User: returns map data (evidence: `app.py`)
