# berkay-durmus/trainstudio architecture

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

- Interactive diagram: https://gitdiagram.com/berkay-durmus/trainstudio
- Repository: https://github.com/berkay-durmus/trainstudio

## Overview

TrainStudio is a self-hosted image classification and segmentation platform. Its documented user journey runs from dataset selection and validation through model selection, settings, background training, results, and inference. The graph preserves medical-image reading, recommendations, live run monitoring, reports, explainability, and export as distinct capabilities. Several view and integration internals were not sampled; edges between those areas rely on the README’s documented workflow rather than claims of inspected implementation.

Main entry points: [`trainers/base.py`](https://github.com/berkay-durmus/trainstudio/blob/main/trainers/base.py) (Training backends), [`views/1_Dataset.py`](https://github.com/berkay-durmus/trainstudio/blob/main/views/1_Dataset.py) (Dataset setup), [`views/2_Model_Selection.py`](https://github.com/berkay-durmus/trainstudio/blob/main/views/2_Model_Selection.py) (Model selection), [`views/3_Settings.py`](https://github.com/berkay-durmus/trainstudio/blob/main/views/3_Settings.py) (Run settings)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["User workflow"]
  node_app["Streamlit app<br/>[app.py]"]
  node_dataset_view["Dataset setup<br/>[1_Dataset.py]"]
  node_model_view["Model selection"]
  node_settings_view["Run settings<br/>[3_Settings.py]"]
  node_training_view["Live training<br/>[4_Training.py]"]
  node_results_view["Results view<br/>[5_Results.py]"]
  node_inference_view["Inference view<br/>[6_Inference.py]"]
end

subgraph group_data["Dataset handling"]
  node_scan["Dataset scan<br/>[scan.py]"]
  node_dataset_spec["Dataset contract<br/>[spec.py]"]
  node_image_readers["Image readers<br/>[readers.py]"]
  node_datasets["2D datasets<br/>[datasets_2d.py]"]
end

subgraph group_runs["Training runtime"]
  node_launcher["Run launcher<br/>[launcher.py]"]
  node_runner["Worker process<br/>[runner.py]"]
  node_trainers["Training backends<br/>[base.py]"]
  node_events["Run event stream<br/>[events.py]"]
end

subgraph group_outputs["Results and inference"]
  node_reports["Metrics reports<br/>[report.py]"]
  node_inference["Prediction and export<br/>[inference.py]"]
  node_explain["Model explanations<br/>[explain.py]"]
end

subgraph group_platform["Core services"]
  node_recommend["Recommendations<br/>[recommend.py]"]
  node_registry["Model catalogue<br/>[registry.py]"]
  node_hardware["Hardware detection<br/>[hardware.py]"]
end

node_user(("Local user"))

node_user -->|"uses"| node_app
node_app -->|"opens workflow"| node_dataset_view
node_dataset_view -->|"validates dataset"| node_scan
node_scan -->|"checks layout"| node_dataset_spec
node_scan -->|"samples images"| node_image_readers
node_dataset_view -->|"continues to"| node_model_view
node_model_view -->|"chooses model"| node_registry
node_model_view -->|"continues to"| node_settings_view
node_settings_view -->|"requests suggestions"| node_recommend
node_settings_view -->|"starts run"| node_launcher
node_launcher -->|"spawns process"| node_runner
node_runner -->|"dispatches training"| node_trainers
node_trainers -->|"loads samples"| node_datasets
node_datasets -->|"reads images"| node_image_readers
node_trainers -->|"emits events"| node_events
node_training_view -->|"reads progress"| node_events
node_training_view -->|"continues to"| node_results_view
node_trainers -->|"writes reports"| node_reports
node_results_view -->|"shows results"| node_reports
node_results_view -->|"continues to"| node_inference_view
node_inference_view -->|"runs predictions"| node_inference
node_inference_view -->|"requests explanations"| node_explain
node_inference -->|"reads input"| node_image_readers
node_recommend -->|"uses device data"| node_hardware

click node_app "https://github.com/berkay-durmus/trainstudio/blob/main/app.py"
click node_dataset_view "https://github.com/berkay-durmus/trainstudio/blob/main/views/1_Dataset.py"
click node_model_view "https://github.com/berkay-durmus/trainstudio/blob/main/views/2_Model_Selection.py"
click node_settings_view "https://github.com/berkay-durmus/trainstudio/blob/main/views/3_Settings.py"
click node_training_view "https://github.com/berkay-durmus/trainstudio/blob/main/views/4_Training.py"
click node_results_view "https://github.com/berkay-durmus/trainstudio/blob/main/views/5_Results.py"
click node_inference_view "https://github.com/berkay-durmus/trainstudio/blob/main/views/6_Inference.py"
click node_scan "https://github.com/berkay-durmus/trainstudio/blob/main/data/scan.py"
click node_dataset_spec "https://github.com/berkay-durmus/trainstudio/blob/main/data/spec.py"
click node_image_readers "https://github.com/berkay-durmus/trainstudio/blob/main/data/readers.py"
click node_datasets "https://github.com/berkay-durmus/trainstudio/blob/main/data/datasets_2d.py"
click node_recommend "https://github.com/berkay-durmus/trainstudio/blob/main/core/recommend.py"
click node_registry "https://github.com/berkay-durmus/trainstudio/blob/main/core/registry.py"
click node_launcher "https://github.com/berkay-durmus/trainstudio/blob/main/core/launcher.py"
click node_runner "https://github.com/berkay-durmus/trainstudio/blob/main/runner.py"
click node_trainers "https://github.com/berkay-durmus/trainstudio/blob/main/trainers/base.py"
click node_events "https://github.com/berkay-durmus/trainstudio/blob/main/core/events.py"
click node_reports "https://github.com/berkay-durmus/trainstudio/blob/main/metrics/report.py"
click node_inference "https://github.com/berkay-durmus/trainstudio/blob/main/export/inference.py"
click node_explain "https://github.com/berkay-durmus/trainstudio/blob/main/export/explain.py"
click node_hardware "https://github.com/berkay-durmus/trainstudio/blob/main/core/hardware.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_dataset_view,node_model_view,node_settings_view,node_training_view,node_results_view,node_inference_view,node_user toneBlue
class node_scan,node_dataset_spec,node_image_readers,node_datasets toneAmber
class node_launcher,node_runner,node_trainers,node_events toneMint
class node_reports,node_inference,node_explain toneRose
class node_recommend,node_registry,node_hardware toneIndigo
```

## Components

### User workflow

- [Streamlit app](https://github.com/berkay-durmus/trainstudio/blob/main/app.py): `app.py`
- [Dataset setup](https://github.com/berkay-durmus/trainstudio/blob/main/views/1_Dataset.py): `views/1_Dataset.py`
- [Model selection](https://github.com/berkay-durmus/trainstudio/blob/main/views/2_Model_Selection.py): `views/2_Model_Selection.py`
- [Run settings](https://github.com/berkay-durmus/trainstudio/blob/main/views/3_Settings.py): `views/3_Settings.py`
- [Live training](https://github.com/berkay-durmus/trainstudio/blob/main/views/4_Training.py): `views/4_Training.py`
- [Results view](https://github.com/berkay-durmus/trainstudio/blob/main/views/5_Results.py): `views/5_Results.py`
- [Inference view](https://github.com/berkay-durmus/trainstudio/blob/main/views/6_Inference.py): `views/6_Inference.py`

### Dataset handling

- [Dataset scan](https://github.com/berkay-durmus/trainstudio/blob/main/data/scan.py): `data/scan.py`
- [Dataset contract](https://github.com/berkay-durmus/trainstudio/blob/main/data/spec.py): `data/spec.py`
- [Image readers](https://github.com/berkay-durmus/trainstudio/blob/main/data/readers.py): `data/readers.py`
- [2D datasets](https://github.com/berkay-durmus/trainstudio/blob/main/data/datasets_2d.py): `data/datasets_2d.py`

### Training runtime

- [Run launcher](https://github.com/berkay-durmus/trainstudio/blob/main/core/launcher.py): `core/launcher.py`
- [Worker process](https://github.com/berkay-durmus/trainstudio/blob/main/runner.py): `runner.py`
- [Training backends](https://github.com/berkay-durmus/trainstudio/blob/main/trainers/base.py): `trainers/base.py`
- [Run event stream](https://github.com/berkay-durmus/trainstudio/blob/main/core/events.py): `core/events.py`

### Results and inference

- [Metrics reports](https://github.com/berkay-durmus/trainstudio/blob/main/metrics/report.py): `metrics/report.py`
- [Prediction and export](https://github.com/berkay-durmus/trainstudio/blob/main/export/inference.py): `export/inference.py`
- [Model explanations](https://github.com/berkay-durmus/trainstudio/blob/main/export/explain.py): `export/explain.py`

### Core services

- [Recommendations](https://github.com/berkay-durmus/trainstudio/blob/main/core/recommend.py): `core/recommend.py`
- [Model catalogue](https://github.com/berkay-durmus/trainstudio/blob/main/core/registry.py): `core/registry.py`
- [Hardware detection](https://github.com/berkay-durmus/trainstudio/blob/main/core/hardware.py): `core/hardware.py`

### Other components

- **Local user**

## Connections

- Local user → Streamlit app: uses (evidence: `README.md`)
- Streamlit app → Dataset setup: opens workflow (evidence: `README.md`)
- Dataset setup → Dataset scan: validates dataset (evidence: `views/1_Dataset.py`)
- Dataset scan → Dataset contract: checks layout (evidence: `data/scan.py`)
- Dataset scan → Image readers: samples images (evidence: `data/scan.py`)
- Dataset setup → Model selection: continues to (evidence: `README.md`)
- Model selection → Model catalogue: chooses model
- Model selection → Run settings: continues to (evidence: `README.md`)
- Run settings → Recommendations: requests suggestions (evidence: `views/3_Settings.py`)
- Run settings → Run launcher: starts run (evidence: `views/3_Settings.py`)
- Run launcher → Worker process: spawns process (evidence: `README.md`)
- Worker process → Training backends: dispatches training (evidence: `runner.py`)
- Training backends → 2D datasets: loads samples (evidence: `trainers/base.py`)
- 2D datasets → Image readers: reads images (evidence: `data/datasets_2d.py`)
- Training backends → Run event stream: emits events (evidence: `trainers/base.py`)
- Live training → Run event stream: reads progress (evidence: `views/4_Training.py`)
- Live training → Results view: continues to (evidence: `README.md`)
- Training backends → Metrics reports: writes reports (evidence: `metrics/report.py`)
- Results view → Metrics reports: shows results (evidence: `README.md`)
- Results view → Inference view: continues to (evidence: `README.md`)
- Inference view → Prediction and export: runs predictions (evidence: `views/6_Inference.py`)
- Inference view → Model explanations: requests explanations (evidence: `README.md`)
- Prediction and export → Image readers: reads input (evidence: `export/inference.py`)
- Recommendations → Hardware detection: uses device data (evidence: `core/recommend.py`)
