# beruk-ggg/brain-eye-arm architecture

> Architecture diagram of the GitHub repository beruk-ggg/brain-eye-arm, 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/beruk-ggg/brain-eye-arm
- Repository: https://github.com/beruk-ggg/brain-eye-arm

## Overview

Brain-Eye-Arm is a camera-guided shape-sorting system: the operator views live detections and requests a pick; vision turns camera frames into tracked, robot-coordinate parts, and a worker runs a retryable pick-and-place cycle through the Dobot TCP server. The map follows that workflow and includes the detector’s model, measurement, and calibration layers. Edges reflect the excerpts or README; unsampled capabilities and internals are represented only where documented, not inferred from filenames.

Main entry points: [`vision/detector.py`](https://github.com/beruk-ggg/brain-eye-arm/blob/main/vision/detector.py) (Shape detector), [`app/web.py`](https://github.com/beruk-ggg/brain-eye-arm/blob/main/app/web.py) (Flask HMI), [`app/service.py`](https://github.com/beruk-ggg/brain-eye-arm/blob/main/app/service.py) (Vision service), [`config.py`](https://github.com/beruk-ggg/brain-eye-arm/blob/main/config.py) (Runtime configuration)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_vision["Vision"]
  node_camera["Basler camera<br/>[camera.py]"]
  node_vision_service["Vision service<br/>[service.py]"]
  node_detector["Shape detector<br/>[detector.py]"]
  node_onnx["ONNX inference<br/>[onnx_model.py]"]
  node_orientation["Orientation measure<br/>[orientation.py]"]
  node_color["Color classifier<br/>[color.py]"]
  node_calibration["Coordinate calibration<br/>[calibration.py]"]
  node_shapes["Shape model<br/>[shapes.py]"]
  node_tracker["Centroid tracker<br/>[tracker.py]"]
end

subgraph group_app["Operator app"]
  node_web["Flask HMI<br/>[web.py]"]
  node_hmi["HMI page<br/>[hmi.js]"]
  node_overlay["Detection overlay<br/>[overlay.py]"]
  node_selection["Pick selection<br/>[selection.py]"]
  node_worker["Pick worker<br/>[pick_worker.py]"]
end

subgraph group_robot["Robot control"]
  node_picker["Pick-and-place controller<br/>[picker.py]"]
  node_client["Robot TCP client<br/>[client.py]"]
  node_dobot["Dobot TCP server"]
end

subgraph group_setup["Configuration"]
  node_config["Runtime configuration<br/>[config.py]"]
end

node_operator(("Operator"))

node_operator -->|"uses"| node_hmi
node_hmi -->|"requests"| node_web
node_camera -->|"supplies frames"| node_vision_service
node_vision_service -->|"detects frames"| node_detector
node_detector -->|"runs inference"| node_onnx
node_detector -->|"measures tilt"| node_orientation
node_detector -->|"classifies color"| node_color
node_detector -->|"maps coordinates"| node_calibration
node_detector -->|"builds detections"| node_shapes
node_vision_service -->|"updates tracks"| node_tracker
node_web -->|"reads snapshots"| node_vision_service
node_web -->|"draws detections"| node_overlay
node_web -->|"filters picks"| node_selection
node_web -->|"submits jobs"| node_worker
node_worker -->|"pauses and redetects"| node_vision_service
node_worker -->|"runs cycle"| node_picker
node_picker -->|"sends robot commands"| node_client
node_client -->|"TCP protocol"| node_dobot
node_config -->|"configures"| node_detector
node_config -->|"sets targets and motion"| node_picker
node_config -->|"sets connection"| node_client

click node_camera "https://github.com/beruk-ggg/brain-eye-arm/blob/main/vision/camera.py"
click node_vision_service "https://github.com/beruk-ggg/brain-eye-arm/blob/main/app/service.py"
click node_detector "https://github.com/beruk-ggg/brain-eye-arm/blob/main/vision/detector.py"
click node_onnx "https://github.com/beruk-ggg/brain-eye-arm/blob/main/vision/onnx_model.py"
click node_orientation "https://github.com/beruk-ggg/brain-eye-arm/blob/main/vision/orientation.py"
click node_color "https://github.com/beruk-ggg/brain-eye-arm/blob/main/vision/color.py"
click node_calibration "https://github.com/beruk-ggg/brain-eye-arm/blob/main/vision/calibration.py"
click node_shapes "https://github.com/beruk-ggg/brain-eye-arm/blob/main/vision/shapes.py"
click node_tracker "https://github.com/beruk-ggg/brain-eye-arm/blob/main/vision/tracker.py"
click node_web "https://github.com/beruk-ggg/brain-eye-arm/blob/main/app/web.py"
click node_hmi "https://github.com/beruk-ggg/brain-eye-arm/blob/main/app/static/hmi.js"
click node_overlay "https://github.com/beruk-ggg/brain-eye-arm/blob/main/app/overlay.py"
click node_selection "https://github.com/beruk-ggg/brain-eye-arm/blob/main/app/selection.py"
click node_worker "https://github.com/beruk-ggg/brain-eye-arm/blob/main/app/pick_worker.py"
click node_picker "https://github.com/beruk-ggg/brain-eye-arm/blob/main/robot/picker.py"
click node_client "https://github.com/beruk-ggg/brain-eye-arm/blob/main/robot/client.py"
click node_dobot "https://github.com/beruk-ggg/brain-eye-arm/blob/main/server_script/dobot_tcp_server.py"
click node_config "https://github.com/beruk-ggg/brain-eye-arm/blob/main/config.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_camera,node_vision_service,node_detector,node_onnx,node_orientation,node_color,node_calibration,node_shapes,node_tracker toneBlue
class node_web,node_hmi,node_overlay,node_selection,node_worker toneAmber
class node_picker,node_client,node_dobot toneMint
class node_config toneRose
class node_operator toneIndigo
```

## Components

### Vision

- [Basler camera](https://github.com/beruk-ggg/brain-eye-arm/blob/main/vision/camera.py): `vision/camera.py`
- [Vision service](https://github.com/beruk-ggg/brain-eye-arm/blob/main/app/service.py): `app/service.py`
- [Shape detector](https://github.com/beruk-ggg/brain-eye-arm/blob/main/vision/detector.py): `vision/detector.py`
- [ONNX inference](https://github.com/beruk-ggg/brain-eye-arm/blob/main/vision/onnx_model.py): `vision/onnx_model.py`
- [Orientation measure](https://github.com/beruk-ggg/brain-eye-arm/blob/main/vision/orientation.py): `vision/orientation.py`
- [Color classifier](https://github.com/beruk-ggg/brain-eye-arm/blob/main/vision/color.py): `vision/color.py`
- [Coordinate calibration](https://github.com/beruk-ggg/brain-eye-arm/blob/main/vision/calibration.py): `vision/calibration.py`
- [Shape model](https://github.com/beruk-ggg/brain-eye-arm/blob/main/vision/shapes.py): `vision/shapes.py`
- [Centroid tracker](https://github.com/beruk-ggg/brain-eye-arm/blob/main/vision/tracker.py): `vision/tracker.py`

### Operator app

- [Flask HMI](https://github.com/beruk-ggg/brain-eye-arm/blob/main/app/web.py): `app/web.py`
- [HMI page](https://github.com/beruk-ggg/brain-eye-arm/blob/main/app/static/hmi.js): `app/static/hmi.js`
- [Detection overlay](https://github.com/beruk-ggg/brain-eye-arm/blob/main/app/overlay.py): `app/overlay.py`
- [Pick selection](https://github.com/beruk-ggg/brain-eye-arm/blob/main/app/selection.py): `app/selection.py`
- [Pick worker](https://github.com/beruk-ggg/brain-eye-arm/blob/main/app/pick_worker.py): `app/pick_worker.py`

### Robot control

- [Pick-and-place controller](https://github.com/beruk-ggg/brain-eye-arm/blob/main/robot/picker.py): `robot/picker.py`
- [Robot TCP client](https://github.com/beruk-ggg/brain-eye-arm/blob/main/robot/client.py): `robot/client.py`
- [Dobot TCP server](https://github.com/beruk-ggg/brain-eye-arm/blob/main/server_script/dobot_tcp_server.py): `server_script/dobot_tcp_server.py`

### Configuration

- [Runtime configuration](https://github.com/beruk-ggg/brain-eye-arm/blob/main/config.py): `config.py`

### Other components

- **Operator**

## Connections

- Operator → HMI page: uses (evidence: `README.md`)
- HMI page → Flask HMI: requests (evidence: `README.md`)
- Basler camera → Vision service: supplies frames (evidence: `app/service.py`)
- Vision service → Shape detector: detects frames (evidence: `app/service.py`)
- Shape detector → ONNX inference: runs inference (evidence: `vision/detector.py`)
- Shape detector → Orientation measure: measures tilt (evidence: `vision/detector.py`)
- Shape detector → Color classifier: classifies color (evidence: `vision/detector.py`)
- Shape detector → Coordinate calibration: maps coordinates (evidence: `vision/detector.py`)
- Shape detector → Shape model: builds detections (evidence: `vision/detector.py`)
- Vision service → Centroid tracker: updates tracks (evidence: `app/service.py`)
- Flask HMI → Vision service: reads snapshots (evidence: `README.md`)
- Flask HMI → Detection overlay: draws detections (evidence: `app/web.py`)
- Flask HMI → Pick selection: filters picks (evidence: `app/web.py`)
- Flask HMI → Pick worker: submits jobs (evidence: `README.md`)
- Pick worker → Vision service: pauses and redetects (evidence: `app/pick_worker.py`)
- Pick worker → Pick-and-place controller: runs cycle (evidence: `app/pick_worker.py`)
- Pick-and-place controller → Robot TCP client: sends robot commands (evidence: `robot/picker.py`)
- Robot TCP client → Dobot TCP server: TCP protocol (evidence: `robot/client.py`)
- Runtime configuration → Shape detector: configures (evidence: `main.py`)
- Runtime configuration → Pick-and-place controller: sets targets and motion (evidence: `main.py`)
- Runtime configuration → Robot TCP client: sets connection (evidence: `main.py`)
