# mosadnabil011/industrial-product-inspection-system architecture

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

- Interactive diagram: https://gitdiagram.com/mosadnabil011/industrial-product-inspection-system
- Repository: https://github.com/mosadnabil011/industrial-product-inspection-system

## Overview

FORCE inspects conveyor products with a camera and YOLO tracking, identifies color and quality at a trigger line, records detections, and actuates reject hardware for defects. Operators use a Flask dashboard for live video, motor controls, production statistics, and PDF reports. The graph reflects the sampled wiring and README-described capabilities; several route, template, and hardware details are documented but not sampled, so those links are documented rather than inferred from naming alone.

Main entry points: [`app.py`](https://github.com/mosadnabil011/industrial-product-inspection-system/blob/master/app.py) (Flask application), [`vision/detector.py`](https://github.com/mosadnabil011/industrial-product-inspection-system/blob/master/vision/detector.py) (Vision system), [`database/db.py`](https://github.com/mosadnabil011/industrial-product-inspection-system/blob/master/database/db.py) (SQLite access), [`gpio/controller.py`](https://github.com/mosadnabil011/industrial-product-inspection-system/blob/master/gpio/controller.py) (Motor controller)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_inspection["Inspection"]
  node_camera["Pi camera"]
  node_vision["Vision system<br/>[detector.py]"]
  node_yolo["YOLO tracking<br/>[detector.py]"]
  node_color["HSV color detection<br/>[detector.py]"]
end

subgraph group_actuation["Line actuation"]
  node_controller["Motor controller<br/>[controller.py]"]
  node_gpio["GPIO relays and buttons"]
end

subgraph group_monitoring["Monitoring"]
  node_control_api["Motor control API<br/>[control.py]"]
  node_stats_api["Statistics API<br/>[stats.py]"]
  node_report_api["PDF report API<br/>[report.py]"]
  node_stream["MJPEG stream<br/>[stream.py]"]
  node_web_app["Flask application<br/>[app.py]"]
  node_dashboard["Dashboard<br/>[dashboard.html]"]
  node_login["Login page<br/>[login.html]"]
  node_dashboard_js["Dashboard interactions<br/>[main.js]"]
  node_auth_js["Login interactions<br/>[auth.js]"]
end

subgraph group_persistence["Production data"]
  node_db_access["SQLite access<br/>[db.py]"]
  node_schema["Products schema<br/>[models.py]"]
  node_sqlite[("SQLite database<br/>[Production_DB.db]")]
end

node_operator(("Operator"))

node_web_app -->|"initializes"| node_db_access
node_web_app -->|"creates"| node_controller
node_web_app -->|"starts"| node_vision
node_web_app -->|"registers"| node_control_api
node_web_app -->|"registers"| node_stats_api
node_web_app -->|"registers"| node_report_api
node_web_app -->|"streams via"| node_stream
node_camera -->|"supplies frames"| node_vision
node_vision -->|"tracks products"| node_yolo
node_vision -->|"classifies color"| node_color
node_vision -->|"records detections"| node_db_access
node_vision -->|"fires pusher"| node_controller
node_controller -->|"drives relays"| node_gpio
node_gpio -->|"signals buttons"| node_controller
node_db_access -->|"creates tables"| node_schema
node_db_access -->|"connects"| node_sqlite
node_stats_api -->|"queries counts"| node_db_access
node_report_api -->|"queries report data"| node_db_access
node_operator -->|"opens"| node_login
node_web_app -->|"serves"| node_dashboard
node_web_app -->|"serves"| node_login
node_dashboard_js -->|"requests controls"| node_control_api
node_dashboard_js -->|"fetches statistics"| node_stats_api
node_dashboard_js -->|"opens report"| node_report_api
node_dashboard -.->|"embeds live video"| node_stream
node_auth_js -.->|"handles login"| node_login

click node_vision "https://github.com/mosadnabil011/industrial-product-inspection-system/blob/master/vision/detector.py"
click node_yolo "https://github.com/mosadnabil011/industrial-product-inspection-system/blob/master/vision/detector.py"
click node_color "https://github.com/mosadnabil011/industrial-product-inspection-system/blob/master/vision/detector.py"
click node_controller "https://github.com/mosadnabil011/industrial-product-inspection-system/blob/master/gpio/controller.py"
click node_control_api "https://github.com/mosadnabil011/industrial-product-inspection-system/blob/master/routes/control.py"
click node_stats_api "https://github.com/mosadnabil011/industrial-product-inspection-system/blob/master/routes/stats.py"
click node_report_api "https://github.com/mosadnabil011/industrial-product-inspection-system/blob/master/routes/report.py"
click node_stream "https://github.com/mosadnabil011/industrial-product-inspection-system/blob/master/vision/stream.py"
click node_web_app "https://github.com/mosadnabil011/industrial-product-inspection-system/blob/master/app.py"
click node_dashboard "https://github.com/mosadnabil011/industrial-product-inspection-system/blob/master/templates/dashboard.html"
click node_login "https://github.com/mosadnabil011/industrial-product-inspection-system/blob/master/templates/login.html"
click node_dashboard_js "https://github.com/mosadnabil011/industrial-product-inspection-system/blob/master/static/js/main.js"
click node_auth_js "https://github.com/mosadnabil011/industrial-product-inspection-system/blob/master/static/js/auth.js"
click node_db_access "https://github.com/mosadnabil011/industrial-product-inspection-system/blob/master/database/db.py"
click node_schema "https://github.com/mosadnabil011/industrial-product-inspection-system/blob/master/database/models.py"
click node_sqlite "https://github.com/mosadnabil011/industrial-product-inspection-system/blob/master/database/Production_DB.db"

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_camera,node_vision,node_yolo,node_color toneBlue
class node_controller,node_gpio toneAmber
class node_control_api,node_stats_api,node_report_api,node_stream,node_web_app,node_dashboard,node_login,node_dashboard_js,node_auth_js toneMint
class node_db_access,node_schema,node_sqlite toneRose
class node_operator toneIndigo
```

## Components

### Inspection

- **Pi camera**
- [Vision system](https://github.com/mosadnabil011/industrial-product-inspection-system/blob/master/vision/detector.py): `vision/detector.py`
- [YOLO tracking](https://github.com/mosadnabil011/industrial-product-inspection-system/blob/master/vision/detector.py): `vision/detector.py`
- [HSV color detection](https://github.com/mosadnabil011/industrial-product-inspection-system/blob/master/vision/detector.py): `vision/detector.py`

### Line actuation

- [Motor controller](https://github.com/mosadnabil011/industrial-product-inspection-system/blob/master/gpio/controller.py): `gpio/controller.py`
- **GPIO relays and buttons**

### Monitoring

- [Motor control API](https://github.com/mosadnabil011/industrial-product-inspection-system/blob/master/routes/control.py): `routes/control.py`
- [Statistics API](https://github.com/mosadnabil011/industrial-product-inspection-system/blob/master/routes/stats.py): `routes/stats.py`
- [PDF report API](https://github.com/mosadnabil011/industrial-product-inspection-system/blob/master/routes/report.py): `routes/report.py`
- [MJPEG stream](https://github.com/mosadnabil011/industrial-product-inspection-system/blob/master/vision/stream.py): `vision/stream.py`
- [Flask application](https://github.com/mosadnabil011/industrial-product-inspection-system/blob/master/app.py): `app.py`
- [Dashboard](https://github.com/mosadnabil011/industrial-product-inspection-system/blob/master/templates/dashboard.html): `templates/dashboard.html`
- [Login page](https://github.com/mosadnabil011/industrial-product-inspection-system/blob/master/templates/login.html): `templates/login.html`
- [Dashboard interactions](https://github.com/mosadnabil011/industrial-product-inspection-system/blob/master/static/js/main.js): `static/js/main.js`
- [Login interactions](https://github.com/mosadnabil011/industrial-product-inspection-system/blob/master/static/js/auth.js): `static/js/auth.js`

### Production data

- [SQLite access](https://github.com/mosadnabil011/industrial-product-inspection-system/blob/master/database/db.py): `database/db.py`
- [Products schema](https://github.com/mosadnabil011/industrial-product-inspection-system/blob/master/database/models.py): `database/models.py`
- [SQLite database](https://github.com/mosadnabil011/industrial-product-inspection-system/blob/master/database/Production_DB.db): `database/Production_DB.db`

### Other components

- **Operator**

## Connections

- Flask application → SQLite access: initializes (evidence: `app.py`)
- Flask application → Motor controller: creates (evidence: `app.py`)
- Flask application → Vision system: starts (evidence: `app.py`)
- Flask application → Motor control API: registers (evidence: `app.py`)
- Flask application → Statistics API: registers (evidence: `app.py`)
- Flask application → PDF report API: registers (evidence: `app.py`)
- Flask application → MJPEG stream: streams via (evidence: `app.py`)
- Pi camera → Vision system: supplies frames (evidence: `README.md`)
- Vision system → YOLO tracking: tracks products (evidence: `README.md`)
- Vision system → HSV color detection: classifies color (evidence: `README.md`)
- Vision system → SQLite access: records detections (evidence: `vision/detector.py`)
- Vision system → Motor controller: fires pusher (evidence: `vision/detector.py`)
- Motor controller → GPIO relays and buttons: drives relays (evidence: `gpio/controller.py`)
- GPIO relays and buttons → Motor controller: signals buttons (evidence: `gpio/controller.py`)
- SQLite access → Products schema: creates tables (evidence: `database/db.py`)
- SQLite access → SQLite database: connects (evidence: `database/db.py`)
- Statistics API → SQLite access: queries counts (evidence: `routes/stats.py`)
- PDF report API → SQLite access: queries report data (evidence: `routes/report.py`)
- Operator → Login page: opens
- Flask application → Dashboard: serves (evidence: `app.py`)
- Flask application → Login page: serves (evidence: `app.py`)
- Dashboard interactions → Motor control API: requests controls (evidence: `static/js/main.js`)
- Dashboard interactions → Statistics API: fetches statistics (evidence: `static/js/main.js`)
- Dashboard interactions → PDF report API: opens report (evidence: `static/js/main.js`)
- Dashboard → MJPEG stream: embeds live video (evidence: `README.md`)
- Login interactions → Login page: handles login
