# ugarcil/rpixel architecture

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

- Interactive diagram: https://gitdiagram.com/ugarcil/rpixel
- Repository: https://github.com/ugarcil/rpixel

## Overview

RPixel is a PyQt desktop application for microscope imaging. The principal workflow is operating the live camera preview, organizing captures in a project with structured filename prefixes, and optionally applying camera flips and calibrated scale bars to saved images. The graph also shows camera presets and calibration/nomenclature support. Source excerpts establish the camera and image-processing behavior; omitted portions of main.py limit verification of some UI-to-capture and persistence connections, shown as unverified where appropriate.

Main entry points: [`main.py`](https://github.com/ugarcil/rpixel/blob/main/main.py) (Main controller), [`videoUtils.py`](https://github.com/ugarcil/rpixel/blob/main/videoUtils.py) (Video manager), [`constants.py`](https://github.com/ugarcil/rpixel/blob/main/constants.py) (Picamera2 camera), [`mainWindow.py`](https://github.com/ugarcil/rpixel/blob/main/mainWindow.py) (Main window UI)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["Application"]
  node_controller["Main controller<br/>[main.py]"]
  node_window["Main window UI<br/>[mainWindow.py]"]
  node_webcamwidget["Preview widget<br/>[mainWindow.py]"]
end

subgraph group_capture["Camera Capture"]
  node_camera["Picamera2 camera<br/>[constants.py]"]
  node_videoman["Video manager<br/>[videoUtils.py]"]
  node_preview["Live preview<br/>[videoUtils.py]"]
  node_image["Captured image<br/>[videoUtils.py]"]
end

subgraph group_organization["Image Organization"]
  node_project["Project images<br/>[main.py]"]
  node_prefix["Structured prefix<br/>[main.py]"]
  node_nomenclature["Nomenclature file<br/>[constants.py]"]
end

subgraph group_calibration["Calibration and Settings"]
  node_calibration["Scale calibration<br/>[main.py]"]
  node_scaleprocessing["Scale bar processing<br/>[videoUtils.py]"]
  node_camerastate["Camera settings<br/>[constants.py]"]
  node_presets["Camera presets<br/>[main.py]"]
end

node_user(("Operator"))

node_user -.->|"operates"| node_window
node_controller -->|"sets up"| node_window
node_controller -->|"creates"| node_videoman
node_controller -.->|"updates"| node_preview
node_videoman -->|"captures from"| node_camera
node_camera -->|"provides frames"| node_preview
node_videoman -->|"captures"| node_image
node_controller -.->|"organizes captures"| node_project
node_controller -->|"composes"| node_prefix
node_controller -->|"reads and updates"| node_nomenclature
node_controller -->|"loads and saves"| node_calibration
node_controller -.->|"applies scale bar"| node_scaleprocessing
node_videoman -->|"flips image"| node_image
node_controller -->|"uses settings"| node_camerastate
node_controller -->|"loads and saves"| node_presets

click node_controller "https://github.com/ugarcil/rpixel/blob/main/main.py"
click node_window "https://github.com/ugarcil/rpixel/blob/main/mainWindow.py"
click node_webcamwidget "https://github.com/ugarcil/rpixel/blob/main/mainWindow.py"
click node_camera "https://github.com/ugarcil/rpixel/blob/main/constants.py"
click node_videoman "https://github.com/ugarcil/rpixel/blob/main/videoUtils.py"
click node_preview "https://github.com/ugarcil/rpixel/blob/main/videoUtils.py"
click node_image "https://github.com/ugarcil/rpixel/blob/main/videoUtils.py"
click node_project "https://github.com/ugarcil/rpixel/blob/main/main.py"
click node_prefix "https://github.com/ugarcil/rpixel/blob/main/main.py"
click node_nomenclature "https://github.com/ugarcil/rpixel/blob/main/constants.py"
click node_calibration "https://github.com/ugarcil/rpixel/blob/main/main.py"
click node_scaleprocessing "https://github.com/ugarcil/rpixel/blob/main/videoUtils.py"
click node_camerastate "https://github.com/ugarcil/rpixel/blob/main/constants.py"
click node_presets "https://github.com/ugarcil/rpixel/blob/main/main.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_controller,node_window,node_webcamwidget toneBlue
class node_camera,node_videoman,node_preview,node_image toneAmber
class node_project,node_prefix,node_nomenclature toneMint
class node_calibration,node_scaleprocessing,node_camerastate,node_presets toneRose
class node_user toneIndigo
```

## Components

### Application

- [Main controller](https://github.com/ugarcil/rpixel/blob/main/main.py): `main.py`
- [Main window UI](https://github.com/ugarcil/rpixel/blob/main/mainWindow.py): `mainWindow.py`
- [Preview widget](https://github.com/ugarcil/rpixel/blob/main/mainWindow.py): `mainWindow.py`

### Camera Capture

- [Picamera2 camera](https://github.com/ugarcil/rpixel/blob/main/constants.py): `constants.py`
- [Video manager](https://github.com/ugarcil/rpixel/blob/main/videoUtils.py): `videoUtils.py`
- [Live preview](https://github.com/ugarcil/rpixel/blob/main/videoUtils.py): `videoUtils.py`
- [Captured image](https://github.com/ugarcil/rpixel/blob/main/videoUtils.py): `videoUtils.py`

### Image Organization

- [Project images](https://github.com/ugarcil/rpixel/blob/main/main.py): `main.py`
- [Structured prefix](https://github.com/ugarcil/rpixel/blob/main/main.py): `main.py`
- [Nomenclature file](https://github.com/ugarcil/rpixel/blob/main/constants.py): `constants.py`

### Calibration and Settings

- [Scale calibration](https://github.com/ugarcil/rpixel/blob/main/main.py): `main.py`
- [Scale bar processing](https://github.com/ugarcil/rpixel/blob/main/videoUtils.py): `videoUtils.py`
- [Camera settings](https://github.com/ugarcil/rpixel/blob/main/constants.py): `constants.py`
- [Camera presets](https://github.com/ugarcil/rpixel/blob/main/main.py): `main.py`

### Other components

- **Operator**

## Connections

- Operator → Main window UI: operates (evidence: `mainWindow.py`)
- Main controller → Main window UI: sets up (evidence: `main.py`)
- Main controller → Video manager: creates (evidence: `main.py`)
- Main controller → Live preview: updates (evidence: `main.py`)
- Video manager → Picamera2 camera: captures from (evidence: `videoUtils.py`)
- Picamera2 camera → Live preview: provides frames (evidence: `videoUtils.py`)
- Video manager → Captured image: captures (evidence: `videoUtils.py`)
- Main controller → Project images: organizes captures (evidence: `main.py`)
- Main controller → Structured prefix: composes (evidence: `main.py`)
- Main controller → Nomenclature file: reads and updates (evidence: `main.py`)
- Main controller → Scale calibration: loads and saves (evidence: `main.py`)
- Main controller → Scale bar processing: applies scale bar (evidence: `main.py`)
- Video manager → Captured image: flips image (evidence: `videoUtils.py`)
- Main controller → Camera settings: uses settings (evidence: `main.py`)
- Main controller → Camera presets: loads and saves (evidence: `main.py`)
