# styx4d/galet architecture

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

- Interactive diagram: https://gitdiagram.com/styx4d/galet
- Repository: https://github.com/styx4d/galet

## Overview

GALET is a QGIS client and localhost Mask R-CNN server for segmenting gravel grains in ordinary images and georeferenced orthomosaics. The principal workflow is to submit image data from a QGIS processing tool, run instance segmentation on the server, then use the returned masks and boxes to produce GIS results. Orthomosaic processing adds spatial clipping, tiling, and duplicate merging; image processing has its own raster workflow. The repository also includes a grain-specific training setup. The processing excerpts are partial, so uncertain links between later geospatial steps are omitted.

Main entry points: [`Qgis_processing_ORTHO.py`](https://github.com/styx4d/galet/blob/main/Qgis_processing_ORTHO.py) (Ortho tool), [`Qgis_processing_IMAGE.py`](https://github.com/styx4d/galet/blob/main/Qgis_processing_IMAGE.py) (Image tool), [`Galet_Server.py`](https://github.com/styx4d/galet/blob/main/Galet_Server.py) (TCP request handler), [`ShareArrays.py`](https://github.com/styx4d/galet/blob/main/ShareArrays.py) (Array transfer)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_qgis["QGIS processing"]
  node_image_tool["Image tool"]
  node_image_tiles["Image tiling"]
  node_image_result["Image GIS output"]
  node_ortho_tool["Ortho tool"]
  node_ortho_clip["Ortho clipping"]
  node_ortho_tiles["Ortho tiling"]
  node_ortho_merge["Duplicate merging"]
  node_ortho_output["Ortho GIS output"]
end

subgraph group_service["Inference service"]
  node_server["TCP request handler<br/>[Galet_Server.py]"]
  node_model_setup["Model setup<br/>[Galet_Server.py]"]
end

subgraph group_network["Mask R-CNN"]
  node_mask_model["Segmentation model<br/>[model.py]"]
  node_model_config["Network settings<br/>[config.py]"]
  node_model_utils["Detection utilities<br/>[utils.py]"]
end

subgraph group_training["Training support"]
  node_grain_config["Grain configuration<br/>[grain.py]"]
  node_grain_dataset["Grain dataset<br/>[grain.py]"]
  node_training_runtime["Training runtime<br/>[model.py]"]
end

subgraph group_transport["Shared-memory transport"]
  node_shared_arrays["Array transfer<br/>[ShareArrays.py]"]
end

node_user(("GIS user"))
node_local_socket(("Local TCP"))
node_weights["Model weights"]

node_user -->|"runs"| node_image_tool
node_user -->|"runs"| node_ortho_tool
node_image_tool -->|"prepares tiles"| node_image_tiles
node_image_tiles -->|"shares image"| node_shared_arrays
node_image_tool -->|"requests inference"| node_server
node_image_tool -->|"reads results"| node_shared_arrays
node_image_tool -->|"writes GIS output"| node_image_result
node_ortho_tool -->|"clips raster"| node_ortho_clip
node_ortho_tool -->|"builds grid"| node_ortho_tiles
node_ortho_tiles -->|"shares tile data"| node_shared_arrays
node_ortho_tool -->|"requests inference"| node_server
node_ortho_tool -->|"reads results"| node_shared_arrays
node_ortho_tool -->|"merges detections"| node_ortho_merge
node_ortho_tool -->|"writes GIS output"| node_ortho_output
node_server -->|"serves requests"| node_local_socket
node_image_tool -->|"sends request"| node_local_socket
node_ortho_tool -->|"sends request"| node_local_socket
node_server -->|"reads image"| node_shared_arrays
node_server -->|"shares detections"| node_shared_arrays
node_server -->|"runs detect"| node_mask_model
node_model_setup -->|"creates model"| node_mask_model
node_model_setup -->|"uses settings"| node_grain_config
node_model_setup -->|"loads"| node_weights
node_mask_model -->|"uses settings"| node_model_config
node_mask_model -->|"uses utilities"| node_model_utils
node_grain_dataset -->|"extends dataset base"| node_model_utils
node_grain_dataset -->|"provides training data"| node_training_runtime
node_grain_config -->|"configures training"| node_training_runtime

click node_image_tool "https://github.com/styx4d/galet/blob/main/Qgis_processing_IMAGE.py"
click node_image_tiles "https://github.com/styx4d/galet/blob/main/Qgis_processing_IMAGE.py"
click node_image_result "https://github.com/styx4d/galet/blob/main/Qgis_processing_IMAGE.py"
click node_ortho_tool "https://github.com/styx4d/galet/blob/main/Qgis_processing_ORTHO.py"
click node_ortho_clip "https://github.com/styx4d/galet/blob/main/Qgis_processing_ORTHO.py"
click node_ortho_tiles "https://github.com/styx4d/galet/blob/main/Qgis_processing_ORTHO.py"
click node_ortho_merge "https://github.com/styx4d/galet/blob/main/Qgis_processing_ORTHO.py"
click node_ortho_output "https://github.com/styx4d/galet/blob/main/Qgis_processing_ORTHO.py"
click node_server "https://github.com/styx4d/galet/blob/main/Galet_Server.py"
click node_model_setup "https://github.com/styx4d/galet/blob/main/Galet_Server.py"
click node_grain_config "https://github.com/styx4d/galet/blob/main/GALET_RCNN_V3/grain.py"
click node_mask_model "https://github.com/styx4d/galet/blob/main/GALET_RCNN_V3/mrcnn/model.py"
click node_model_config "https://github.com/styx4d/galet/blob/main/GALET_RCNN_V3/mrcnn/config.py"
click node_model_utils "https://github.com/styx4d/galet/blob/main/GALET_RCNN_V3/mrcnn/utils.py"
click node_grain_dataset "https://github.com/styx4d/galet/blob/main/GALET_RCNN_V3/grain.py"
click node_training_runtime "https://github.com/styx4d/galet/blob/main/GALET_RCNN_V3/mrcnn/model.py"
click node_shared_arrays "https://github.com/styx4d/galet/blob/main/ShareArrays.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_image_tool,node_image_tiles,node_image_result,node_ortho_tool,node_ortho_clip,node_ortho_tiles,node_ortho_merge,node_ortho_output,node_user toneBlue
class node_server,node_model_setup toneAmber
class node_mask_model,node_model_config,node_model_utils toneMint
class node_grain_config,node_grain_dataset,node_training_runtime toneRose
class node_shared_arrays,node_local_socket,node_weights toneIndigo
```

## Components

### QGIS processing

- [Image tool](https://github.com/styx4d/galet/blob/main/Qgis_processing_IMAGE.py): `Qgis_processing_IMAGE.py`
- [Image tiling](https://github.com/styx4d/galet/blob/main/Qgis_processing_IMAGE.py): `Qgis_processing_IMAGE.py`
- [Image GIS output](https://github.com/styx4d/galet/blob/main/Qgis_processing_IMAGE.py): `Qgis_processing_IMAGE.py`
- [Ortho tool](https://github.com/styx4d/galet/blob/main/Qgis_processing_ORTHO.py): `Qgis_processing_ORTHO.py`
- [Ortho clipping](https://github.com/styx4d/galet/blob/main/Qgis_processing_ORTHO.py): `Qgis_processing_ORTHO.py`
- [Ortho tiling](https://github.com/styx4d/galet/blob/main/Qgis_processing_ORTHO.py): `Qgis_processing_ORTHO.py`
- [Duplicate merging](https://github.com/styx4d/galet/blob/main/Qgis_processing_ORTHO.py): `Qgis_processing_ORTHO.py`
- [Ortho GIS output](https://github.com/styx4d/galet/blob/main/Qgis_processing_ORTHO.py): `Qgis_processing_ORTHO.py`

### Inference service

- [TCP request handler](https://github.com/styx4d/galet/blob/main/Galet_Server.py): `Galet_Server.py`
- [Model setup](https://github.com/styx4d/galet/blob/main/Galet_Server.py): `Galet_Server.py`

### Mask R-CNN

- [Segmentation model](https://github.com/styx4d/galet/blob/main/GALET_RCNN_V3/mrcnn/model.py): `GALET_RCNN_V3/mrcnn/model.py`
- [Network settings](https://github.com/styx4d/galet/blob/main/GALET_RCNN_V3/mrcnn/config.py): `GALET_RCNN_V3/mrcnn/config.py`
- [Detection utilities](https://github.com/styx4d/galet/blob/main/GALET_RCNN_V3/mrcnn/utils.py): `GALET_RCNN_V3/mrcnn/utils.py`

### Training support

- [Grain configuration](https://github.com/styx4d/galet/blob/main/GALET_RCNN_V3/grain.py): `GALET_RCNN_V3/grain.py`
- [Grain dataset](https://github.com/styx4d/galet/blob/main/GALET_RCNN_V3/grain.py): `GALET_RCNN_V3/grain.py`
- [Training runtime](https://github.com/styx4d/galet/blob/main/GALET_RCNN_V3/mrcnn/model.py): `GALET_RCNN_V3/mrcnn/model.py`

### Shared-memory transport

- [Array transfer](https://github.com/styx4d/galet/blob/main/ShareArrays.py): `ShareArrays.py`

### Other components

- **GIS user**
- **Local TCP**
- **Model weights**

## Connections

- GIS user → Image tool: runs
- GIS user → Ortho tool: runs
- Image tool → Image tiling: prepares tiles
- Image tiling → Array transfer: shares image
- Image tool → TCP request handler: requests inference
- Image tool → Array transfer: reads results
- Image tool → Image GIS output: writes GIS output
- Ortho tool → Ortho clipping: clips raster
- Ortho tool → Ortho tiling: builds grid
- Ortho tiling → Array transfer: shares tile data
- Ortho tool → TCP request handler: requests inference
- Ortho tool → Array transfer: reads results
- Ortho tool → Duplicate merging: merges detections
- Ortho tool → Ortho GIS output: writes GIS output
- TCP request handler → Local TCP: serves requests
- Image tool → Local TCP: sends request
- Ortho tool → Local TCP: sends request
- TCP request handler → Array transfer: reads image
- TCP request handler → Array transfer: shares detections
- TCP request handler → Segmentation model: runs detect
- Model setup → Segmentation model: creates model
- Model setup → Grain configuration: uses settings
- Model setup → Model weights: loads
- Segmentation model → Network settings: uses settings
- Segmentation model → Detection utilities: uses utilities
- Grain dataset → Detection utilities: extends dataset base
- Grain dataset → Training runtime: provides training data
- Grain configuration → Training runtime: configures training
