# nirmalkumar31/water-body-segmentation-repro architecture

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

- Interactive diagram: https://gitdiagram.com/nirmalkumar31/water-body-segmentation-repro
- Repository: https://github.com/nirmalkumar31/water-body-segmentation-repro
- Video tour (about a minute): https://gitdiagram.com/nirmalkumar31/water-body-segmentation-repro/video

## Overview

Satellite Water Segmentation prepares satellite imagery, trains and evaluates segmentation models, promotes and packages a selected model, then serves water masks and overlays. The main request path is user → FastAPI service → inference → returned mask. Training, recovery, experiment tracking, release checks, cloud workflows, and monitoring are separate capabilities. Edges reflect sampled calls, SOURCE INDEX references, or README statements; unsampled subsystem links are omitted where their wiring is not evidenced.

Main entry points: [`deployment/serve.py`](https://github.com/nirmalkumar31/water-body-segmentation-repro/blob/main/deployment/serve.py) (Inference API), [`training/train.py`](https://github.com/nirmalkumar31/water-body-segmentation-repro/blob/main/training/train.py) (Training loop), [`deployment/inference.py`](https://github.com/nirmalkumar31/water-body-segmentation-repro/blob/main/deployment/inference.py) (Image inference), [`data_pipeline/patch_dataset.py`](https://github.com/nirmalkumar31/water-body-segmentation-repro/blob/main/data_pipeline/patch_dataset.py) (Patch sampling)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_data["Data preparation"]
  node_dataset["Dataset audit<br/>[audit.py]"]
  node_patches["Patch sampling<br/>[patch_dataset.py]"]
  node_tiles["Tile dataset<br/>[tile_dataset.py]"]
  node_tiling["Tile operations<br/>[tiling.py]"]
  node_transforms["Image transforms<br/>[transforms.py]"]
  node_stitch["Prediction stitching<br/>[stitch.py]"]
end

subgraph group_training["Training and evaluation"]
  node_training_entry["Training loop<br/>[train.py]"]
  node_model["Segmentation model<br/>[model.py]"]
  node_loss["Training loss<br/>[loss.py]"]
  node_recovery["Training recovery<br/>[resume.py]"]
  node_tracking["Experiment tracking<br/>[tracking.py]"]
  node_mlflow["MLflow utilities<br/>[mlflow_utils.py]"]
end

subgraph group_release["Model release"]
  node_promotion["Model promotion<br/>[promote_model.py]"]
  node_export["Model export<br/>[export_model.py]"]
  node_release_gate["Release verification<br/>[release.py]"]
  node_cloud_jobs["Modal workflows<br/>[modal_app.py]"]
end

subgraph group_serving["Inference and operations"]
  node_service["Inference API<br/>[serve.py]"]
  node_inference["Image inference<br/>[inference.py]"]
  node_web_ui["Web interface<br/>[app.js]"]
  node_prediction_log[("Prediction log<br/>[prediction_log.py]")]
  node_metrics["Service metrics"]
  node_modal_web["Modal web app<br/>[modal_web.py]"]
end

node_user(("Image user"))
node_mask["Water mask"]

node_user -->|"uploads image"| node_service
node_service -->|"runs inference"| node_inference
node_inference -->|"tiles image"| node_tiling
node_inference -->|"preprocesses tiles"| node_transforms
node_inference -->|"stitches predictions"| node_stitch
node_service -->|"returns mask"| node_mask
node_service -->|"serves interface"| node_web_ui
node_service -->|"logs predictions"| node_prediction_log
node_service -->|"exports metrics"| node_metrics
node_modal_web -->|"routes to"| node_service
node_dataset -.->|"filters data"| node_patches
node_training_entry -->|"loads data"| node_patches
node_training_entry -->|"builds model"| node_model
node_training_entry -->|"computes loss"| node_loss
node_training_entry -->|"resumes state"| node_recovery
node_training_entry -->|"tracks runs"| node_tracking
node_tracking -.->|"uses helpers"| node_mlflow
node_tiles -->|"uses tile operations"| node_tiling
node_patches -->|"augments patches"| node_transforms
node_promotion -->|"uses tracking helpers"| node_mlflow
node_export -->|"uses promotion logic"| node_promotion
node_export -->|"selects model run"| node_mlflow
node_release_gate -->|"checks parity"| node_inference
node_release_gate -->|"checks release"| node_promotion
node_cloud_jobs -.->|"runs cloud training"| node_training_entry

click node_dataset "https://github.com/nirmalkumar31/water-body-segmentation-repro/blob/main/data_pipeline/audit.py"
click node_patches "https://github.com/nirmalkumar31/water-body-segmentation-repro/blob/main/data_pipeline/patch_dataset.py"
click node_tiles "https://github.com/nirmalkumar31/water-body-segmentation-repro/blob/main/data_pipeline/tile_dataset.py"
click node_tiling "https://github.com/nirmalkumar31/water-body-segmentation-repro/blob/main/data_pipeline/tiling.py"
click node_transforms "https://github.com/nirmalkumar31/water-body-segmentation-repro/blob/main/data_pipeline/transforms.py"
click node_stitch "https://github.com/nirmalkumar31/water-body-segmentation-repro/blob/main/data_pipeline/stitch.py"
click node_training_entry "https://github.com/nirmalkumar31/water-body-segmentation-repro/blob/main/training/train.py"
click node_model "https://github.com/nirmalkumar31/water-body-segmentation-repro/blob/main/training/model.py"
click node_loss "https://github.com/nirmalkumar31/water-body-segmentation-repro/blob/main/training/loss.py"
click node_recovery "https://github.com/nirmalkumar31/water-body-segmentation-repro/blob/main/training/resume.py"
click node_tracking "https://github.com/nirmalkumar31/water-body-segmentation-repro/blob/main/training/tracking.py"
click node_mlflow "https://github.com/nirmalkumar31/water-body-segmentation-repro/blob/main/common/mlflow_utils.py"
click node_promotion "https://github.com/nirmalkumar31/water-body-segmentation-repro/blob/main/deployment/promote_model.py"
click node_export "https://github.com/nirmalkumar31/water-body-segmentation-repro/blob/main/deployment/export_model.py"
click node_release_gate "https://github.com/nirmalkumar31/water-body-segmentation-repro/blob/main/tools/release.py"
click node_cloud_jobs "https://github.com/nirmalkumar31/water-body-segmentation-repro/blob/main/cloud/modal_app.py"
click node_service "https://github.com/nirmalkumar31/water-body-segmentation-repro/blob/main/deployment/serve.py"
click node_inference "https://github.com/nirmalkumar31/water-body-segmentation-repro/blob/main/deployment/inference.py"
click node_web_ui "https://github.com/nirmalkumar31/water-body-segmentation-repro/blob/main/deployment/static/app.js"
click node_prediction_log "https://github.com/nirmalkumar31/water-body-segmentation-repro/blob/main/deployment/prediction_log.py"
click node_metrics "https://github.com/nirmalkumar31/water-body-segmentation-repro/blob/main/deployment/metrics_exporter.py"
click node_modal_web "https://github.com/nirmalkumar31/water-body-segmentation-repro/blob/main/cloud/modal_web.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_dataset,node_patches,node_tiles,node_tiling,node_transforms,node_stitch,node_user toneBlue
class node_training_entry,node_model,node_loss,node_recovery,node_tracking,node_mlflow toneAmber
class node_promotion,node_export,node_release_gate,node_cloud_jobs toneMint
class node_service,node_inference,node_web_ui,node_prediction_log,node_metrics,node_modal_web toneRose
class node_mask toneIndigo
```

## Components

### Data preparation

- [Dataset audit](https://github.com/nirmalkumar31/water-body-segmentation-repro/blob/main/data_pipeline/audit.py): `data_pipeline/audit.py`
- [Patch sampling](https://github.com/nirmalkumar31/water-body-segmentation-repro/blob/main/data_pipeline/patch_dataset.py): `data_pipeline/patch_dataset.py`
- [Tile dataset](https://github.com/nirmalkumar31/water-body-segmentation-repro/blob/main/data_pipeline/tile_dataset.py): `data_pipeline/tile_dataset.py`
- [Tile operations](https://github.com/nirmalkumar31/water-body-segmentation-repro/blob/main/data_pipeline/tiling.py): `data_pipeline/tiling.py`
- [Image transforms](https://github.com/nirmalkumar31/water-body-segmentation-repro/blob/main/data_pipeline/transforms.py): `data_pipeline/transforms.py`
- [Prediction stitching](https://github.com/nirmalkumar31/water-body-segmentation-repro/blob/main/data_pipeline/stitch.py): `data_pipeline/stitch.py`

### Training and evaluation

- [Training loop](https://github.com/nirmalkumar31/water-body-segmentation-repro/blob/main/training/train.py): `training/train.py`
- [Segmentation model](https://github.com/nirmalkumar31/water-body-segmentation-repro/blob/main/training/model.py): `training/model.py`
- [Training loss](https://github.com/nirmalkumar31/water-body-segmentation-repro/blob/main/training/loss.py): `training/loss.py`
- [Training recovery](https://github.com/nirmalkumar31/water-body-segmentation-repro/blob/main/training/resume.py): `training/resume.py`
- [Experiment tracking](https://github.com/nirmalkumar31/water-body-segmentation-repro/blob/main/training/tracking.py): `training/tracking.py`
- [MLflow utilities](https://github.com/nirmalkumar31/water-body-segmentation-repro/blob/main/common/mlflow_utils.py): `common/mlflow_utils.py`

### Model release

- [Model promotion](https://github.com/nirmalkumar31/water-body-segmentation-repro/blob/main/deployment/promote_model.py): `deployment/promote_model.py`
- [Model export](https://github.com/nirmalkumar31/water-body-segmentation-repro/blob/main/deployment/export_model.py): `deployment/export_model.py`
- [Release verification](https://github.com/nirmalkumar31/water-body-segmentation-repro/blob/main/tools/release.py): `tools/release.py`
- [Modal workflows](https://github.com/nirmalkumar31/water-body-segmentation-repro/blob/main/cloud/modal_app.py): `cloud/modal_app.py`

### Inference and operations

- [Inference API](https://github.com/nirmalkumar31/water-body-segmentation-repro/blob/main/deployment/serve.py): `deployment/serve.py`
- [Image inference](https://github.com/nirmalkumar31/water-body-segmentation-repro/blob/main/deployment/inference.py): `deployment/inference.py`
- [Web interface](https://github.com/nirmalkumar31/water-body-segmentation-repro/blob/main/deployment/static/app.js): `deployment/static/app.js`
- [Prediction log](https://github.com/nirmalkumar31/water-body-segmentation-repro/blob/main/deployment/prediction_log.py): `deployment/prediction_log.py`
- [Service metrics](https://github.com/nirmalkumar31/water-body-segmentation-repro/blob/main/deployment/metrics_exporter.py): `deployment/metrics_exporter.py`
- [Modal web app](https://github.com/nirmalkumar31/water-body-segmentation-repro/blob/main/cloud/modal_web.py): `cloud/modal_web.py`

### Other components

- **Image user**
- **Water mask**

## Connections

- Image user → Inference API: uploads image (evidence: `README.md`)
- Inference API → Image inference: runs inference (evidence: `deployment/serve.py`)
- Image inference → Tile operations: tiles image (evidence: `deployment/inference.py`)
- Image inference → Image transforms: preprocesses tiles (evidence: `deployment/inference.py`)
- Image inference → Prediction stitching: stitches predictions (evidence: `deployment/inference.py`)
- Inference API → Water mask: returns mask (evidence: `README.md`)
- Inference API → Web interface: serves interface (evidence: `deployment/serve.py`)
- Inference API → Prediction log: logs predictions (evidence: `deployment/serve.py`)
- Inference API → Service metrics: exports metrics (evidence: `deployment/serve.py`)
- Modal web app → Inference API: routes to (evidence: `cloud/modal_web.py`)
- Dataset audit → Patch sampling: filters data
- Training loop → Patch sampling: loads data (evidence: `training/train.py`)
- Training loop → Segmentation model: builds model (evidence: `training/train.py`)
- Training loop → Training loss: computes loss (evidence: `training/train.py`)
- Training loop → Training recovery: resumes state (evidence: `training/train.py`)
- Training loop → Experiment tracking: tracks runs (evidence: `training/train.py`)
- Experiment tracking → MLflow utilities: uses helpers
- Tile dataset → Tile operations: uses tile operations (evidence: `data_pipeline/tile_dataset.py`)
- Patch sampling → Image transforms: augments patches (evidence: `data_pipeline/transforms.py`)
- Model promotion → MLflow utilities: uses tracking helpers (evidence: `deployment/promote_model.py`)
- Model export → Model promotion: uses promotion logic (evidence: `deployment/export_model.py`)
- Model export → MLflow utilities: selects model run (evidence: `deployment/export_model.py`)
- Release verification → Image inference: checks parity (evidence: `tools/release.py`)
- Release verification → Model promotion: checks release (evidence: `tools/release.py`)
- Modal workflows → Training loop: runs cloud training
