# ivan-widjanarko/potholes-detection-phd- architecture

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

- Interactive diagram: https://gitdiagram.com/ivan-widjanarko/potholes-detection-phd-
- Repository: https://github.com/ivan-widjanarko/potholes-detection-phd-

## Overview

This repository contains the Raspberry Pi detection runtime and a Flask cloud API backed by Cloud SQL; the Android client described in the README is not present in the tree. The documented journey is to connect the app to the Pi, start and stop a drive, review detections, and submit reports. The Pi polls device status, captures and classifies frames, uploads report images to Cloud Storage, then posts report metadata to the API. Source excerpts show the Pi module calls and API/database operations; Android-side wiring and some deployment integrations are documented but not implemented here.

Main entry points: [`Raspberry App/main.py`](https://github.com/ivan-widjanarko/potholes-detection-phd-/blob/main/Raspberry%20App/main.py) (Drive Runtime), [`main.py`](https://github.com/ivan-widjanarko/potholes-detection-phd-/blob/main/main.py) (Flask API), [`Raspberry App/upload.py`](https://github.com/ivan-widjanarko/potholes-detection-phd-/blob/main/Raspberry%20App/upload.py) (Image Upload), [`Raspberry App/utils.py`](https://github.com/ivan-widjanarko/potholes-detection-phd-/blob/main/Raspberry%20App/utils.py) (Frame Cropping)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_mobile["Mobile App"]
  node_android["Android Client"]
end

subgraph group_raspi["Raspberry Pi"]
  node_pi_runtime["Drive Runtime<br/>[main.py]"]
  node_camera["Pi Camera"]
  node_image_prep["Frame Cropping<br/>[utils.py]"]
  node_detector["TFLite Detector<br/>[detector.py]"]
  node_image_upload["Image Upload<br/>[upload.py]"]
end

subgraph group_cloud["Cloud Backend"]
  node_api["Flask API<br/>[main.py]"]
  node_sql[("Cloud SQL")]
end

subgraph group_storage["Cloud Storage"]
  node_gcs[("Cloud Storage")]
end

node_driver(("Driver"))

node_driver -.->|"controls drive"| node_android
node_android -.->|"starts and stops"| node_pi_runtime
node_driver -.->|"reviews detections"| node_android
node_android -.->|"submits reports"| node_api
node_pi_runtime -.->|"captures frames"| node_camera
node_pi_runtime -->|"preprocesses frames"| node_image_prep
node_pi_runtime -->|"runs inference"| node_detector
node_pi_runtime -->|"polls status"| node_api
node_pi_runtime -->|"uploads report image"| node_image_upload
node_image_upload -->|"stores image"| node_gcs
node_pi_runtime -->|"posts report metadata"| node_api
node_api -->|"reads and writes"| node_sql

click node_pi_runtime "https://github.com/ivan-widjanarko/potholes-detection-phd-/blob/main/Raspberry%20App/main.py"
click node_image_prep "https://github.com/ivan-widjanarko/potholes-detection-phd-/blob/main/Raspberry%20App/utils.py"
click node_detector "https://github.com/ivan-widjanarko/potholes-detection-phd-/blob/main/Raspberry%20App/detector.py"
click node_image_upload "https://github.com/ivan-widjanarko/potholes-detection-phd-/blob/main/Raspberry%20App/upload.py"
click node_api "https://github.com/ivan-widjanarko/potholes-detection-phd-/blob/main/main.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_android toneBlue
class node_pi_runtime,node_camera,node_image_prep,node_detector,node_image_upload toneAmber
class node_api,node_sql toneMint
class node_gcs toneRose
class node_driver toneIndigo
```

## Components

### Mobile App

- **Android Client**

### Raspberry Pi

- [Drive Runtime](https://github.com/ivan-widjanarko/potholes-detection-phd-/blob/main/Raspberry%20App/main.py): `Raspberry App/main.py`
- **Pi Camera**
- [Frame Cropping](https://github.com/ivan-widjanarko/potholes-detection-phd-/blob/main/Raspberry%20App/utils.py): `Raspberry App/utils.py`
- [TFLite Detector](https://github.com/ivan-widjanarko/potholes-detection-phd-/blob/main/Raspberry%20App/detector.py): `Raspberry App/detector.py`
- [Image Upload](https://github.com/ivan-widjanarko/potholes-detection-phd-/blob/main/Raspberry%20App/upload.py): `Raspberry App/upload.py`

### Cloud Backend

- [Flask API](https://github.com/ivan-widjanarko/potholes-detection-phd-/blob/main/main.py): `main.py`
- **Cloud SQL**

### Cloud Storage

- **Cloud Storage**

### Other components

- **Driver**

## Connections

- Driver → Android Client: controls drive (evidence: `README.md`)
- Android Client → Drive Runtime: starts and stops (evidence: `README.md`)
- Driver → Android Client: reviews detections (evidence: `README.md`)
- Android Client → Flask API: submits reports (evidence: `README.md`)
- Drive Runtime → Pi Camera: captures frames
- Drive Runtime → Frame Cropping: preprocesses frames (evidence: `Raspberry App/main.py`)
- Drive Runtime → TFLite Detector: runs inference (evidence: `Raspberry App/main.py`)
- Drive Runtime → Flask API: polls status (evidence: `Raspberry App/main.py`)
- Drive Runtime → Image Upload: uploads report image (evidence: `Raspberry App/main.py`)
- Image Upload → Cloud Storage: stores image (evidence: `Raspberry App/upload.py`)
- Drive Runtime → Flask API: posts report metadata (evidence: `Raspberry App/main.py`)
- Flask API → Cloud SQL: reads and writes (evidence: `main.py`)
