# dhivyabala726/good_weld architecture

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

- Interactive diagram: https://gitdiagram.com/dhivyabala726/good_weld
- Repository: https://github.com/dhivyabala726/good_weld

## Overview

LaserWeld AI Inspector is a Flask web app for inspecting weld-surface images with an ONNX YOLO model. Users choose an image or capture one with a camera, submit it for inference, then review a weld verdict, confidence and annotated image; they can also browse or clear session history and download results. The backend decodes and scales images, runs detection and saves annotations. Note: the README describes persisted history, but the sampled implementation keeps history in memory. The source excerpt does not show a health endpoint or persistent history store.

Main entry points: [`app.py`](https://github.com/dhivyabala726/good_weld/blob/main/app.py) (Flask Routes), [`static/js/app.js`](https://github.com/dhivyabala726/good_weld/blob/main/static/js/app.js) (Dashboard Interaction), [`static/results`](https://github.com/dhivyabala726/good_weld/tree/main/static/results) (Annotated Results), [`templates/index.html`](https://github.com/dhivyabala726/good_weld/blob/main/templates/index.html) (Dashboard Page)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_intake["Image Intake"]
  node_routes["Flask Routes<br/>[app.py]"]
  node_decode["Image Decoding<br/>[app.py]"]
  node_uploads["Image Selection<br/>[app.js]"]
end

subgraph group_inspection["Inspection Engine"]
  node_preprocess["Image Preprocessing<br/>[app.py]"]
  node_model["ONNX Model<br/>[best.onnx]"]
  node_inference["YOLO Inference<br/>[app.py]"]
  node_postprocess["Detection Processing<br/>[app.py]"]
  node_verdict["Weld Verdict<br/>[app.py]"]
end

subgraph group_results["Results and History"]
  node_annotation["Image Annotation<br/>[app.py]"]
  node_result_store[("Annotated Results")]
  node_history[("Session History<br/>[app.py]")]
end

subgraph group_web["Web Experience"]
  node_frontend["Dashboard Interaction<br/>[app.js]"]
  node_dashboard["Dashboard Page<br/>[index.html]"]
  node_history_view["History Display<br/>[app.js]"]
  node_result_view["Inspection Results UI<br/>[app.js]"]
end

node_user(("Inspector"))
node_browser_camera(("Browser Camera"))

node_user -->|"uses"| node_frontend
node_frontend -.->|"renders"| node_dashboard
node_routes -->|"renders"| node_dashboard
node_user -->|"selects image"| node_uploads
node_browser_camera -->|"provides capture"| node_frontend
node_frontend -->|"posts image"| node_routes
node_routes -->|"decodes image"| node_decode
node_decode -->|"passes image"| node_preprocess
node_preprocess -->|"supplies tensor"| node_inference
node_inference -->|"runs model"| node_model
node_inference -->|"processes output"| node_postprocess
node_postprocess -->|"supplies detections"| node_verdict
node_verdict -->|"annotates image"| node_annotation
node_annotation -->|"writes image"| node_result_store
node_verdict -->|"records summary"| node_history
node_routes -->|"serves history"| node_history
node_routes -->|"serves download"| node_result_store
node_frontend -->|"renders response"| node_result_view
node_result_view -.->|"shows image"| node_result_store
node_frontend -->|"loads history"| node_history_view
node_history_view -->|"requests history"| node_routes

click node_frontend "https://github.com/dhivyabala726/good_weld/blob/main/static/js/app.js"
click node_dashboard "https://github.com/dhivyabala726/good_weld/blob/main/templates/index.html"
click node_routes "https://github.com/dhivyabala726/good_weld/blob/main/app.py"
click node_decode "https://github.com/dhivyabala726/good_weld/blob/main/app.py"
click node_preprocess "https://github.com/dhivyabala726/good_weld/blob/main/app.py"
click node_model "https://github.com/dhivyabala726/good_weld/blob/main/best.onnx"
click node_inference "https://github.com/dhivyabala726/good_weld/blob/main/app.py"
click node_postprocess "https://github.com/dhivyabala726/good_weld/blob/main/app.py"
click node_verdict "https://github.com/dhivyabala726/good_weld/blob/main/app.py"
click node_annotation "https://github.com/dhivyabala726/good_weld/blob/main/app.py"
click node_result_store "https://github.com/dhivyabala726/good_weld/tree/main/static/results"
click node_history "https://github.com/dhivyabala726/good_weld/blob/main/app.py"
click node_history_view "https://github.com/dhivyabala726/good_weld/blob/main/static/js/app.js"
click node_result_view "https://github.com/dhivyabala726/good_weld/blob/main/static/js/app.js"
click node_uploads "https://github.com/dhivyabala726/good_weld/blob/main/static/js/app.js"

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_routes,node_decode,node_uploads,node_browser_camera toneBlue
class node_preprocess,node_model,node_inference,node_postprocess,node_verdict toneAmber
class node_annotation,node_result_store,node_history toneMint
class node_frontend,node_dashboard,node_history_view,node_result_view toneRose
class node_user toneIndigo
```

## Components

### Image Intake

- [Flask Routes](https://github.com/dhivyabala726/good_weld/blob/main/app.py): `app.py`
- [Image Decoding](https://github.com/dhivyabala726/good_weld/blob/main/app.py): `app.py`
- [Image Selection](https://github.com/dhivyabala726/good_weld/blob/main/static/js/app.js): `static/js/app.js`

### Inspection Engine

- [Image Preprocessing](https://github.com/dhivyabala726/good_weld/blob/main/app.py): `app.py`
- [ONNX Model](https://github.com/dhivyabala726/good_weld/blob/main/best.onnx): `best.onnx`
- [YOLO Inference](https://github.com/dhivyabala726/good_weld/blob/main/app.py): `app.py`
- [Detection Processing](https://github.com/dhivyabala726/good_weld/blob/main/app.py): `app.py`
- [Weld Verdict](https://github.com/dhivyabala726/good_weld/blob/main/app.py): `app.py`

### Results and History

- [Image Annotation](https://github.com/dhivyabala726/good_weld/blob/main/app.py): `app.py`
- [Annotated Results](https://github.com/dhivyabala726/good_weld/tree/main/static/results): `static/results`
- [Session History](https://github.com/dhivyabala726/good_weld/blob/main/app.py): `app.py`

### Web Experience

- [Dashboard Interaction](https://github.com/dhivyabala726/good_weld/blob/main/static/js/app.js): `static/js/app.js`
- [Dashboard Page](https://github.com/dhivyabala726/good_weld/blob/main/templates/index.html): `templates/index.html`
- [History Display](https://github.com/dhivyabala726/good_weld/blob/main/static/js/app.js): `static/js/app.js`
- [Inspection Results UI](https://github.com/dhivyabala726/good_weld/blob/main/static/js/app.js): `static/js/app.js`

### Other components

- **Inspector**
- **Browser Camera**

## Connections

- Inspector → Dashboard Interaction: uses (evidence: `README.md`)
- Dashboard Interaction → Dashboard Page: renders
- Flask Routes → Dashboard Page: renders (evidence: `app.py`)
- Inspector → Image Selection: selects image (evidence: `README.md`)
- Browser Camera → Dashboard Interaction: provides capture (evidence: `README.md`)
- Dashboard Interaction → Flask Routes: posts image (evidence: `static/js/app.js`)
- Flask Routes → Image Decoding: decodes image (evidence: `app.py`)
- Image Decoding → Image Preprocessing: passes image (evidence: `app.py`)
- Image Preprocessing → YOLO Inference: supplies tensor (evidence: `app.py`)
- YOLO Inference → ONNX Model: runs model (evidence: `app.py`)
- YOLO Inference → Detection Processing: processes output (evidence: `app.py`)
- Detection Processing → Weld Verdict: supplies detections (evidence: `app.py`)
- Weld Verdict → Image Annotation: annotates image (evidence: `app.py`)
- Image Annotation → Annotated Results: writes image (evidence: `app.py`)
- Weld Verdict → Session History: records summary (evidence: `app.py`)
- Flask Routes → Session History: serves history (evidence: `app.py`)
- Flask Routes → Annotated Results: serves download (evidence: `app.py`)
- Dashboard Interaction → Inspection Results UI: renders response (evidence: `static/js/app.js`)
- Inspection Results UI → Annotated Results: shows image
- Dashboard Interaction → History Display: loads history (evidence: `static/js/app.js`)
- History Display → Flask Routes: requests history (evidence: `static/js/app.js`)
