# hyrsta/aiws architecture

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

- Interactive diagram: https://gitdiagram.com/hyrsta/aiws
- Repository: https://github.com/hyrsta/aiws

## Overview

AIWS integrates an online welding-vision pipeline with an offline CAD-reconstruction workflow; the documented current focus is offline reconstruction. In the GUI workflow, an operator submits images and a mask or an existing mesh, starts a reconstruction job, monitors its stages, and inspects downloadable results and metrics. Offline tooling also prepares datasets, reconstructs meshes with SAM3D, adapts mesh outputs for Cadrille PC/IMG inference, and evaluates or refines results. The GUI/backend relationship and broad offline stages are documented, but several script-level handoffs were not excerpted, so those links are omitted or marked unverified.

Main entry points: [`gui/frontend/src/App.tsx`](https://github.com/hyrsta/aiws/blob/main/gui/frontend/src/App.tsx) (Job workspace), [`scripts/sam3d_batch.py`](https://github.com/hyrsta/aiws/blob/main/scripts/sam3d_batch.py) (SAM3D mesh generation), [`scripts/cadrille_batch.py`](https://github.com/hyrsta/aiws/blob/main/scripts/cadrille_batch.py) (Cadrille batch runs), [`scripts/cadrille_infer_wrapper.py`](https://github.com/hyrsta/aiws/blob/main/scripts/cadrille_infer_wrapper.py) (Cadrille inference)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_gui["Job GUI"]
  node_app["Job workspace<br/>[App.tsx]"]
  node_configure["Job setup<br/>[ConfigureView.tsx]"]
  node_api["API client<br/>[client.ts]"]
  node_backend["FastAPI service<br/>[app.py]"]
  node_jobrunner["Reconstruction runner"]
  node_live["Live progress<br/>[LiveView.tsx]"]
  node_results["Result inspection<br/>[ResultView.tsx]"]
end

subgraph group_offline["Offline CAD"]
  node_sam3d["SAM3D mesh generation<br/>[sam3d_batch.py]"]
  node_bridge["Mesh-to-Cadrille prep"]
  node_cadrillebatch["Cadrille batch runs<br/>[cadrille_batch.py]"]
  node_inference["Cadrille inference"]
  node_seeding["Reproducible sampling"]
  node_dataset["Dataset preparation"]
  node_masks["Instance masks"]
end

subgraph group_refinement["CAD Refinement"]
  node_evaluation["Pipeline analysis"]
  node_selection["Candidate selection"]
  node_postscale["Metric postscale"]
  node_cleanup["Body cleanup"]
  node_stage_metrics["Stage metrics"]
end

subgraph group_online["Online Welding"]
  node_online_input["RGB-D observations"]
  node_recognition["Recognition and segmentation"]
  node_pose["Pose estimation and alignment"]
  node_weld["Localization and weld planning"]
  node_cad_database[("CAD model database")]
end

node_operator(("Operator"))

node_operator -->|"uses"| node_app
node_app -->|"shows"| node_configure
node_configure -.->|"submits job"| node_api
node_api -->|"HTTP requests"| node_backend
node_backend -.->|"launches job"| node_jobrunner
node_app -->|"shows progress"| node_live
node_app -->|"shows results"| node_results
node_jobrunner -.->|"runs reconstruction"| node_sam3d
node_sam3d -->|"produces mesh input"| node_bridge
node_bridge -->|"prepares split"| node_cadrillebatch
node_cadrillebatch -->|"launches runner"| node_inference
node_inference -->|"uses seeded data"| node_seeding
node_dataset -.->|"prepares data"| node_masks
node_sam3d -->|"analyzes outputs"| node_evaluation
node_cadrillebatch -->|"analyzes outputs"| node_evaluation
node_inference -.->|"selects candidates"| node_selection
node_selection -.->|"refines scale"| node_postscale
node_postscale -.->|"refines geometry"| node_cleanup
node_cleanup -->|"scores stages"| node_stage_metrics
node_sam3d -->|"builds CAD assets"| node_cad_database
node_cad_database -->|"provides CAD models"| node_pose
node_online_input -->|"observes workpiece"| node_recognition
node_recognition -->|"estimates pose"| node_pose
node_pose -->|"localizes and plans"| node_weld

click node_app "https://github.com/hyrsta/aiws/blob/main/gui/frontend/src/App.tsx"
click node_configure "https://github.com/hyrsta/aiws/blob/main/gui/frontend/src/views/ConfigureView.tsx"
click node_api "https://github.com/hyrsta/aiws/blob/main/gui/frontend/src/api/client.ts"
click node_backend "https://github.com/hyrsta/aiws/blob/main/gui/backend/app.py"
click node_jobrunner "https://github.com/hyrsta/aiws/blob/main/gui/backend/simple_reconstruct_job.py"
click node_live "https://github.com/hyrsta/aiws/blob/main/gui/frontend/src/views/LiveView.tsx"
click node_results "https://github.com/hyrsta/aiws/blob/main/gui/frontend/src/views/ResultView.tsx"
click node_sam3d "https://github.com/hyrsta/aiws/blob/main/scripts/sam3d_batch.py"
click node_bridge "https://github.com/hyrsta/aiws/blob/main/scripts/sam3d_cadrille_bridge.py"
click node_cadrillebatch "https://github.com/hyrsta/aiws/blob/main/scripts/cadrille_batch.py"
click node_inference "https://github.com/hyrsta/aiws/blob/main/scripts/cadrille_infer_wrapper.py"
click node_seeding "https://github.com/hyrsta/aiws/blob/main/scripts/cadrille_seeding.py"
click node_dataset "https://github.com/hyrsta/aiws/blob/main/scripts/dataset_usable_view_build.py"
click node_masks "https://github.com/hyrsta/aiws/blob/main/scripts/dataset_instance_masks_generate.py"
click node_evaluation "https://github.com/hyrsta/aiws/blob/main/scripts/cadrille_run_metrics_analysis.py"
click node_selection "https://github.com/hyrsta/aiws/blob/main/scripts/cadrille_reselect.py"
click node_postscale "https://github.com/hyrsta/aiws/blob/main/scripts/cadrille_metric_postscale.py"
click node_cleanup "https://github.com/hyrsta/aiws/blob/main/scripts/cadrille_body_cleanup.py"
click node_stage_metrics "https://github.com/hyrsta/aiws/blob/main/scripts/cadrille_stage_metrics.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_app,node_configure,node_api,node_backend,node_jobrunner,node_live,node_results toneBlue
class node_sam3d,node_bridge,node_cadrillebatch,node_inference,node_seeding,node_dataset,node_masks toneAmber
class node_evaluation,node_selection,node_postscale,node_cleanup,node_stage_metrics toneMint
class node_online_input,node_recognition,node_pose,node_weld,node_cad_database toneRose
class node_operator toneIndigo
```

## Components

### Job GUI

- [Job workspace](https://github.com/hyrsta/aiws/blob/main/gui/frontend/src/App.tsx): `gui/frontend/src/App.tsx`
- [Job setup](https://github.com/hyrsta/aiws/blob/main/gui/frontend/src/views/ConfigureView.tsx): `gui/frontend/src/views/ConfigureView.tsx`
- [API client](https://github.com/hyrsta/aiws/blob/main/gui/frontend/src/api/client.ts): `gui/frontend/src/api/client.ts`
- [FastAPI service](https://github.com/hyrsta/aiws/blob/main/gui/backend/app.py): `gui/backend/app.py`
- [Reconstruction runner](https://github.com/hyrsta/aiws/blob/main/gui/backend/simple_reconstruct_job.py): `gui/backend/simple_reconstruct_job.py`
- [Live progress](https://github.com/hyrsta/aiws/blob/main/gui/frontend/src/views/LiveView.tsx): `gui/frontend/src/views/LiveView.tsx`
- [Result inspection](https://github.com/hyrsta/aiws/blob/main/gui/frontend/src/views/ResultView.tsx): `gui/frontend/src/views/ResultView.tsx`

### Offline CAD

- [SAM3D mesh generation](https://github.com/hyrsta/aiws/blob/main/scripts/sam3d_batch.py): `scripts/sam3d_batch.py`
- [Mesh-to-Cadrille prep](https://github.com/hyrsta/aiws/blob/main/scripts/sam3d_cadrille_bridge.py): `scripts/sam3d_cadrille_bridge.py`
- [Cadrille batch runs](https://github.com/hyrsta/aiws/blob/main/scripts/cadrille_batch.py): `scripts/cadrille_batch.py`
- [Cadrille inference](https://github.com/hyrsta/aiws/blob/main/scripts/cadrille_infer_wrapper.py): `scripts/cadrille_infer_wrapper.py`
- [Reproducible sampling](https://github.com/hyrsta/aiws/blob/main/scripts/cadrille_seeding.py): `scripts/cadrille_seeding.py`
- [Dataset preparation](https://github.com/hyrsta/aiws/blob/main/scripts/dataset_usable_view_build.py): `scripts/dataset_usable_view_build.py`
- [Instance masks](https://github.com/hyrsta/aiws/blob/main/scripts/dataset_instance_masks_generate.py): `scripts/dataset_instance_masks_generate.py`

### CAD Refinement

- [Pipeline analysis](https://github.com/hyrsta/aiws/blob/main/scripts/cadrille_run_metrics_analysis.py): `scripts/cadrille_run_metrics_analysis.py`
- [Candidate selection](https://github.com/hyrsta/aiws/blob/main/scripts/cadrille_reselect.py): `scripts/cadrille_reselect.py`
- [Metric postscale](https://github.com/hyrsta/aiws/blob/main/scripts/cadrille_metric_postscale.py): `scripts/cadrille_metric_postscale.py`
- [Body cleanup](https://github.com/hyrsta/aiws/blob/main/scripts/cadrille_body_cleanup.py): `scripts/cadrille_body_cleanup.py`
- [Stage metrics](https://github.com/hyrsta/aiws/blob/main/scripts/cadrille_stage_metrics.py): `scripts/cadrille_stage_metrics.py`

### Online Welding

- **RGB-D observations**
- **Recognition and segmentation**
- **Pose estimation and alignment**
- **Localization and weld planning**
- **CAD model database**

### Other components

- **Operator**

## Connections

- Operator → Job workspace: uses (evidence: `README.md`)
- Job workspace → Job setup: shows (evidence: `gui/frontend/src/App.tsx`)
- Job setup → API client: submits job
- API client → FastAPI service: HTTP requests (evidence: `README.md`)
- FastAPI service → Reconstruction runner: launches job
- Job workspace → Live progress: shows progress (evidence: `gui/frontend/src/App.tsx`)
- Job workspace → Result inspection: shows results (evidence: `gui/frontend/src/App.tsx`)
- Reconstruction runner → SAM3D mesh generation: runs reconstruction
- SAM3D mesh generation → Mesh-to-Cadrille prep: produces mesh input (evidence: `README.md`)
- Mesh-to-Cadrille prep → Cadrille batch runs: prepares split (evidence: `scripts/cadrille_batch.py`)
- Cadrille batch runs → Cadrille inference: launches runner (evidence: `scripts/cadrille_batch.py`)
- Cadrille inference → Reproducible sampling: uses seeded data (evidence: `scripts/cadrille_infer_wrapper.py`)
- Dataset preparation → Instance masks: prepares data
- SAM3D mesh generation → Pipeline analysis: analyzes outputs (evidence: `README.md`)
- Cadrille batch runs → Pipeline analysis: analyzes outputs (evidence: `README.md`)
- Cadrille inference → Candidate selection: selects candidates
- Candidate selection → Metric postscale: refines scale
- Metric postscale → Body cleanup: refines geometry
- Body cleanup → Stage metrics: scores stages (evidence: `scripts/cadrille_body_cleanup.py`)
- SAM3D mesh generation → CAD model database: builds CAD assets (evidence: `README.md`)
- CAD model database → Pose estimation and alignment: provides CAD models (evidence: `README.md`)
- RGB-D observations → Recognition and segmentation: observes workpiece (evidence: `README.md`)
- Recognition and segmentation → Pose estimation and alignment: estimates pose (evidence: `README.md`)
- Pose estimation and alignment → Localization and weld planning: localizes and plans (evidence: `README.md`)
