# akl04/pcb-inspection-edge-ai architecture

> Architecture diagram of the GitHub repository akl04/pcb-inspection-edge-ai, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-12-01). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/akl04/pcb-inspection-edge-ai
- Repository: https://github.com/akl04/pcb-inspection-edge-ai

## Overview

This is an offline Raspberry Pi PCB inspection and advisory application. The main workflow watches uploaded images, runs YOLO localization, writes inspection records, obtains a knowledge-grounded corrective-action selection from the local ExecuTorch service, adds measurements, and presents reports and history in a dashboard. The README documents the product capabilities and several cross-service links; sampled source confirms watcher output, advisory serving, and measurement logic. Dashboard internals and some monitoring connections were not sampled, so those links rely on documented architecture or are omitted.

Main entry points: [`vision/watch_input.py`](https://github.com/akl04/pcb-inspection-edge-ai/blob/main/vision/watch_input.py) (Inspection records), [`advisory/executorch_server.py`](https://github.com/akl04/pcb-inspection-edge-ai/blob/main/advisory/executorch_server.py) (ExecuTorch server), [`hardware_monitoring/inspection_measurements.py`](https://github.com/akl04/pcb-inspection-edge-ai/blob/main/hardware_monitoring/inspection_measurements.py) (Inspection measurements), [`integration/llama_bridge.py`](https://github.com/akl04/pcb-inspection-edge-ai/blob/main/integration/llama_bridge.py) (Integration bridge)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_vision["Vision inspection"]
  node_watcher["Image watcher<br/>[watch_input.py]"]
  node_yolo["YOLO inference<br/>[watch_input.py]"]
  node_inspection_record["Inspection records<br/>[watch_input.py]"]
  node_class_mapping["Defect class mapping"]
end

subgraph group_advisory["Advisory processing"]
  node_bridge["Integration bridge<br/>[llama_bridge.py]"]
  node_advisory_server["ExecuTorch server"]
  node_knowledge_base["PCB knowledge base"]
  node_integrated_report["Advisory report<br/>[llama_bridge.py]"]
end

subgraph group_monitoring["Monitoring"]
  node_hardware_reader["Hardware sampling"]
  node_inspection_sampler["Inspection sampler"]
  node_shared_monitor["Shared monitor"]
  node_measurements["Inspection measurements"]
  node_performance["Performance metrics"]
end

subgraph group_application["Application and records"]
  node_dashboard["Inspection dashboard<br/>[app.py]"]
  node_result_archive["Inspection history"]
end

node_operator(("PCB image uploader"))
node_llama_service["Local Llama runtime"]

node_operator -->|"uploads image"| node_watcher
node_watcher -->|"invokes inference"| node_yolo
node_yolo -->|"writes detections"| node_inspection_record
node_yolo -.->|"uses class labels"| node_class_mapping
node_inspection_record -->|"provides inspection"| node_bridge
node_bridge -->|"requests selection"| node_advisory_server
node_advisory_server -->|"reads guidance"| node_knowledge_base
node_advisory_server -->|"runs model"| node_llama_service
node_advisory_server -->|"returns selection"| node_bridge
node_bridge -->|"assembles report"| node_integrated_report
node_inspection_record -.->|"provides timing data"| node_measurements
node_inspection_sampler -->|"samples hardware"| node_hardware_reader
node_inspection_sampler -->|"calculates rates"| node_performance
node_measurements -->|"summarizes window"| node_shared_monitor
node_measurements -->|"calculates performance"| node_performance
node_measurements -->|"adds measurements"| node_integrated_report
node_integrated_report -->|"displays report"| node_dashboard
node_inspection_record -->|"shows annotated image"| node_dashboard
node_dashboard -->|"browses history"| node_result_archive

click node_watcher "https://github.com/akl04/pcb-inspection-edge-ai/blob/main/vision/watch_input.py"
click node_yolo "https://github.com/akl04/pcb-inspection-edge-ai/blob/main/vision/watch_input.py"
click node_inspection_record "https://github.com/akl04/pcb-inspection-edge-ai/blob/main/vision/watch_input.py"
click node_class_mapping "https://github.com/akl04/pcb-inspection-edge-ai/blob/main/config/yolo_class_mapping.json"
click node_bridge "https://github.com/akl04/pcb-inspection-edge-ai/blob/main/integration/llama_bridge.py"
click node_advisory_server "https://github.com/akl04/pcb-inspection-edge-ai/blob/main/advisory/executorch_server.py"
click node_knowledge_base "https://github.com/akl04/pcb-inspection-edge-ai/blob/main/config/pcb_knowledge_base.json"
click node_integrated_report "https://github.com/akl04/pcb-inspection-edge-ai/blob/main/integration/llama_bridge.py"
click node_dashboard "https://github.com/akl04/pcb-inspection-edge-ai/blob/main/dashboard/app.py"
click node_result_archive "https://github.com/akl04/pcb-inspection-edge-ai/tree/main/results"
click node_hardware_reader "https://github.com/akl04/pcb-inspection-edge-ai/blob/main/hardware_monitoring/hardware_monitor.py"
click node_inspection_sampler "https://github.com/akl04/pcb-inspection-edge-ai/blob/main/hardware_monitoring/inspection_sampler.py"
click node_shared_monitor "https://github.com/akl04/pcb-inspection-edge-ai/blob/main/hardware_monitoring/shared_hardware_monitor.py"
click node_measurements "https://github.com/akl04/pcb-inspection-edge-ai/blob/main/hardware_monitoring/inspection_measurements.py"
click node_performance "https://github.com/akl04/pcb-inspection-edge-ai/blob/main/hardware_monitoring/inspection_sampler.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_watcher,node_yolo,node_inspection_record,node_class_mapping toneBlue
class node_bridge,node_advisory_server,node_knowledge_base,node_integrated_report toneAmber
class node_hardware_reader,node_inspection_sampler,node_shared_monitor,node_measurements,node_performance toneMint
class node_dashboard,node_result_archive toneRose
class node_operator,node_llama_service toneIndigo
```

## Components

### Vision inspection

- [Image watcher](https://github.com/akl04/pcb-inspection-edge-ai/blob/main/vision/watch_input.py): `vision/watch_input.py`
- [YOLO inference](https://github.com/akl04/pcb-inspection-edge-ai/blob/main/vision/watch_input.py): `vision/watch_input.py`
- [Inspection records](https://github.com/akl04/pcb-inspection-edge-ai/blob/main/vision/watch_input.py): `vision/watch_input.py`
- [Defect class mapping](https://github.com/akl04/pcb-inspection-edge-ai/blob/main/config/yolo_class_mapping.json): `config/yolo_class_mapping.json`

### Advisory processing

- [Integration bridge](https://github.com/akl04/pcb-inspection-edge-ai/blob/main/integration/llama_bridge.py): `integration/llama_bridge.py`
- [ExecuTorch server](https://github.com/akl04/pcb-inspection-edge-ai/blob/main/advisory/executorch_server.py): `advisory/executorch_server.py`
- [PCB knowledge base](https://github.com/akl04/pcb-inspection-edge-ai/blob/main/config/pcb_knowledge_base.json): `config/pcb_knowledge_base.json`
- [Advisory report](https://github.com/akl04/pcb-inspection-edge-ai/blob/main/integration/llama_bridge.py): `integration/llama_bridge.py`

### Monitoring

- [Hardware sampling](https://github.com/akl04/pcb-inspection-edge-ai/blob/main/hardware_monitoring/hardware_monitor.py): `hardware_monitoring/hardware_monitor.py`
- [Inspection sampler](https://github.com/akl04/pcb-inspection-edge-ai/blob/main/hardware_monitoring/inspection_sampler.py): `hardware_monitoring/inspection_sampler.py`
- [Shared monitor](https://github.com/akl04/pcb-inspection-edge-ai/blob/main/hardware_monitoring/shared_hardware_monitor.py): `hardware_monitoring/shared_hardware_monitor.py`
- [Inspection measurements](https://github.com/akl04/pcb-inspection-edge-ai/blob/main/hardware_monitoring/inspection_measurements.py): `hardware_monitoring/inspection_measurements.py`
- [Performance metrics](https://github.com/akl04/pcb-inspection-edge-ai/blob/main/hardware_monitoring/inspection_sampler.py): `hardware_monitoring/inspection_sampler.py`

### Application and records

- [Inspection dashboard](https://github.com/akl04/pcb-inspection-edge-ai/blob/main/dashboard/app.py): `dashboard/app.py`
- [Inspection history](https://github.com/akl04/pcb-inspection-edge-ai/tree/main/results): `results`

### Other components

- **PCB image uploader**
- **Local Llama runtime**

## Connections

- PCB image uploader → Image watcher: uploads image (evidence: `README.md`)
- Image watcher → YOLO inference: invokes inference (evidence: `vision/watch_input.py`)
- YOLO inference → Inspection records: writes detections (evidence: `vision/watch_input.py`)
- YOLO inference → Defect class mapping: uses class labels
- Inspection records → Integration bridge: provides inspection (evidence: `README.md`)
- Integration bridge → ExecuTorch server: requests selection (evidence: `README.md`)
- ExecuTorch server → PCB knowledge base: reads guidance (evidence: `advisory/executorch_server.py`)
- ExecuTorch server → Local Llama runtime: runs model (evidence: `advisory/executorch_server.py`)
- ExecuTorch server → Integration bridge: returns selection (evidence: `README.md`)
- Integration bridge → Advisory report: assembles report (evidence: `README.md`)
- Inspection records → Inspection measurements: provides timing data
- Inspection sampler → Hardware sampling: samples hardware (evidence: `hardware_monitoring/inspection_sampler.py`)
- Inspection sampler → Performance metrics: calculates rates (evidence: `hardware_monitoring/inspection_sampler.py`)
- Inspection measurements → Shared monitor: summarizes window (evidence: `hardware_monitoring/inspection_measurements.py`)
- Inspection measurements → Performance metrics: calculates performance (evidence: `hardware_monitoring/inspection_measurements.py`)
- Inspection measurements → Advisory report: adds measurements (evidence: `README.md`)
- Advisory report → Inspection dashboard: displays report (evidence: `README.md`)
- Inspection records → Inspection dashboard: shows annotated image (evidence: `README.md`)
- Inspection dashboard → Inspection history: browses history (evidence: `README.md`)
