# capenaka/airway-ml-cfd-linux architecture

> Architecture diagram of the GitHub repository capenaka/airway-ml-cfd-linux, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-04-18). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/capenaka/airway-ml-cfd-linux
- Repository: https://github.com/capenaka/airway-ml-cfd-linux

## Overview

1. **Overall shape**
   - This is a **Python desktop application** for upper-airway medical imaging workflows, not a web service.
   - The repo centers on a GUI that orchestrates a pipeline from **CT/CBCT input → segmentation → 3D geometry → CFD simulation → reporting**.

2. **Entry points and app shell**
   - `Ortho_App/main.py` is the likely startup entry point.
   - `Ortho_App/gui/app.py` appears to build the main application window and wire together the tabs, navigation, and shared UI state.
   - Top-level helper scripts `blender_ortho.py` and `paraview_ortho.py` suggest direct integration points for external visualization/processing tools.

3. **Workflow is organized as a multi-tab desktop wizard**
   - `Ortho_App/gui/tabs/tab1.py` through `tab4.py` indicate a staged workflow UI.
   - The app likely guides users through sequential phases such as data import, segmentation review, CFD setup/run, and results/report viewing.
   - This tabbed structure is the main user-facing control boundary of the system.

4. **Reusable UI component layer**
   - `Ortho_App/gui/components/` contains shared widgets and dialogs: buttons, forms, navigation, progress, notebooks, info displays, and a PDF viewer.
   - This layer keeps workflow tabs thin and provides common interaction patterns like progress feedback and file/dialog handling.
   - The PDF viewer strongly suggests generated reports are displayed inside the app.

5. **Configuration and application concerns**
   - `Ortho_App/gui/config/` contains settings, logging configuration, and error-message definitions.
   - `app_logger.py` in `gui/utils` reinforces that runtime logging is part of the app’s operational model.
   - These modules define the boundary between the GUI and environment-specific behavior such as paths, logging, and user-facing errors.

6. **Medical-image processing and segmentation subsystem**
   - `Ortho_App/gui/utils/image_processing.py`, `segmentation.py`, and `get_cfd_data.py` are the core data-processing utilities.
   - The README states segmentation is automated using **nnU-Net**, so the pipeline likely consumes medical images and produces segmented airway outputs.
   - `basic_utils.py` and `tooltips.py` support this workflow with general utilities and UI guidance.

7. **3D geometry and visualization subsystem**
   - `blender_processor.py`, `stl_assem_image_render.py`, and `open3d_viewer.py` indicate the app works with 3D meshes and visual preview/rendering.
   - The presence of `geo_files/*.stl` and `P5T1.nii.gz` shows the repo includes sample geometry and image assets used for testing or demos.
   - Blender integration suggests mesh preparation/inspection is a distinct step before CFD.

8. **CFD simulation assets and case templates**
   - `Ortho_App/data/Master_cfd_file/` is a prebuilt **OpenFOAM case template** containing `system/`, `constant/`, and `0/` directories.
   - Files like `blockMeshDict`, `snappyHexMeshDict`, `controlDict`, `fvSchemes`, and `fvSolution` define the simulation setup and meshing behavior.
   - `Allrun`, `Allclean`, and `gnuplot*` scripts show the app relies on external OpenFOAM execution and postprocessing conventions rather than implementing CFD itself.

9. **Simulation output and postprocessing boundary**
   - The case data includes residuals and plotting scripts, implying the app collects solver outputs and converts them into readable metrics/plots.
   - `generate_airway_report.py` is the report-generation boundary that turns CFD and segmentation results into a clinical-style output.
   - `pdf_viewer.py` then closes the loop by letting the user inspect the generated report inside the GUI.

10. **External toolchain dependencies that materially shape the architecture**
   - The README names **Python 3.11, Blender 2.82, OpenFOAM 2306, ParaView 5.12, nnUNetv2**, and a CUDA-capable NVIDIA GPU.
   - This is a tool-orchestration application: the Python GUI coordinates external scientific/visualization software rather than doing all compute internally.
   - ParaView and Blender are likely used for 3D inspection and postprocessing, while nnU-Net handles segmentation inference.

11. **Data organization and persistence model**
   - The README describes per-user folders for images, segmentation artifacts, CFD outputs, and reports, even though those folders are not committed here.
   - The committed `Master_cfd_file` and `Master_cfd_file_backup` look like reusable templates/backups rather than user-specific results.
   - This implies a clear split between **static application assets** and **runtime user workspace data**.

12. **What a diagram should emphasize**
   - The main flow is: **GUI tabs → processing utilities → external tools/case templates → results/report viewer**.
   - The important boundaries are:
     - UI vs. processing logic
     - processing logic vs. external executables
     - template case files vs. per-user runtime output
     - generated CFD/segmentation artifacts vs. final report presentation

Main entry points: [`Ortho_App/gui/app.py`](https://github.com/capenaka/airway-ml-cfd-linux/blob/main/Ortho_App/gui/app.py) (App shell), [`Ortho_App/gui/tabs/tab2.py`](https://github.com/capenaka/airway-ml-cfd-linux/blob/main/Ortho_App/gui/tabs/tab2.py) (Tab 2), [`Ortho_App/gui/tabs/tab3.py`](https://github.com/capenaka/airway-ml-cfd-linux/blob/main/Ortho_App/gui/tabs/tab3.py) (Tab 3), [`Ortho_App/data/Master_cfd_file/system/controlDict`](https://github.com/capenaka/airway-ml-cfd-linux/tree/main/Ortho_App/data/Master_cfd_file/system/controlDict) (OpenFOAM case)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_grp_ui["GUI shell"]
  node_n_main["main.py<br/>entrypoint<br/>[main.py]"]
  node_n_gui_app["App shell<br/>window<br/>[app.py]"]
  node_n_gui_ortho["GUI bridge<br/>launcher<br/>[GUI_ortho.py]"]
  node_n_tab1["Tab 1<br/>workflow tab<br/>[tab1.py]"]
  node_n_tab2["Tab 2<br/>workflow tab<br/>[tab2.py]"]
  node_n_tab3["Tab 3<br/>workflow tab<br/>[tab3.py]"]
  node_n_tab4["Tab 4<br/>workflow tab<br/>[tab4.py]"]
  node_n_components["Widgets<br/>ui toolkit<br/>[__init__.py]"]
  node_n_config["Config<br/>settings<br/>[__init__.py]"]
  node_n_logger["Logger<br/>runtime logging<br/>[app_logger.py]"]
end

subgraph group_grp_processing["Processing pipeline"]
  node_n_image["Image ops<br/>medical imaging"]
  node_n_segment["Segmentation<br/>nnU-Net pipeline<br/>[segmentation.py]"]
  node_n_cfd_data["CFD data<br/>data extraction<br/>[get_cfd_data.py]"]
  node_n_blender_proc["Blender proc<br/>3d prep"]
  node_n_render["3D render<br/>visualization"]
  node_n_viewer["Open3D view<br/>viewer<br/>[open3d_viewer.py]"]
  node_n_report["Report"]
end

subgraph group_grp_cfd["CFD template"]
  node_n_case[("OpenFOAM case<br/>template case")]
  node_n_case_backup[("Case backup<br/>template backup")]
  node_n_run_scripts["Run scripts<br/>solver scripts"]
end

node_n_blender_script["blender_ortho.py<br/>external bridge<br/>[blender_ortho.py]"]
node_n_paraview_script["paraview_ortho.py<br/>external bridge<br/>[paraview_ortho.py]"]

node_n_main -->|"starts"| node_n_gui_app
node_n_gui_ortho -->|"launches"| node_n_gui_app
node_n_gui_app -->|"hosts"| node_n_tab1
node_n_gui_app -->|"hosts"| node_n_tab2
node_n_gui_app -->|"hosts"| node_n_tab3
node_n_gui_app -->|"hosts"| node_n_tab4
node_n_gui_app -->|"uses"| node_n_components
node_n_gui_app -->|"loads"| node_n_config
node_n_config -->|"configures"| node_n_logger
node_n_tab1 -->|"imports"| node_n_image
node_n_tab1 -->|"starts"| node_n_segment
node_n_tab2 -->|"prepares"| node_n_blender_proc
node_n_tab2 -->|"reviews"| node_n_viewer
node_n_tab2 -->|"renders"| node_n_render
node_n_tab3 -->|"packages"| node_n_cfd_data
node_n_tab3 -->|"writes to"| node_n_case
node_n_tab3 -->|"executes"| node_n_run_scripts
node_n_tab4 -->|"generates"| node_n_report
node_n_tab4 -->|"displays"| node_n_components
node_n_image -->|"feeds"| node_n_segment
node_n_segment -->|"outputs"| node_n_cfd_data
node_n_blender_proc -->|"bridges"| node_n_blender_script
node_n_viewer -->|"bridges"| node_n_paraview_script
node_n_case -.->|"mirrors"| node_n_case_backup
node_n_case -->|"contains"| node_n_run_scripts
node_n_report -->|"renders"| node_n_components
node_n_case -.->|"supplies metrics"| node_n_report

click node_n_main "https://github.com/capenaka/airway-ml-cfd-linux/blob/main/Ortho_App/main.py"
click node_n_gui_app "https://github.com/capenaka/airway-ml-cfd-linux/blob/main/Ortho_App/gui/app.py"
click node_n_gui_ortho "https://github.com/capenaka/airway-ml-cfd-linux/blob/main/Ortho_App/GUI_ortho.py"
click node_n_tab1 "https://github.com/capenaka/airway-ml-cfd-linux/blob/main/Ortho_App/gui/tabs/tab1.py"
click node_n_tab2 "https://github.com/capenaka/airway-ml-cfd-linux/blob/main/Ortho_App/gui/tabs/tab2.py"
click node_n_tab3 "https://github.com/capenaka/airway-ml-cfd-linux/blob/main/Ortho_App/gui/tabs/tab3.py"
click node_n_tab4 "https://github.com/capenaka/airway-ml-cfd-linux/blob/main/Ortho_App/gui/tabs/tab4.py"
click node_n_components "https://github.com/capenaka/airway-ml-cfd-linux/blob/main/Ortho_App/gui/components/__init__.py"
click node_n_config "https://github.com/capenaka/airway-ml-cfd-linux/blob/main/Ortho_App/gui/config/__init__.py"
click node_n_logger "https://github.com/capenaka/airway-ml-cfd-linux/blob/main/Ortho_App/gui/utils/app_logger.py"
click node_n_image "https://github.com/capenaka/airway-ml-cfd-linux/blob/main/Ortho_App/gui/utils/image_processing.py"
click node_n_segment "https://github.com/capenaka/airway-ml-cfd-linux/blob/main/Ortho_App/gui/utils/segmentation.py"
click node_n_cfd_data "https://github.com/capenaka/airway-ml-cfd-linux/blob/main/Ortho_App/gui/utils/get_cfd_data.py"
click node_n_blender_proc "https://github.com/capenaka/airway-ml-cfd-linux/blob/main/Ortho_App/gui/utils/blender_processor.py"
click node_n_render "https://github.com/capenaka/airway-ml-cfd-linux/blob/main/Ortho_App/gui/utils/stl_assem_image_render.py"
click node_n_viewer "https://github.com/capenaka/airway-ml-cfd-linux/blob/main/Ortho_App/gui/utils/open3d_viewer.py"
click node_n_report "https://github.com/capenaka/airway-ml-cfd-linux/blob/main/Ortho_App/gui/utils/generate_airway_report.py"
click node_n_blender_script "https://github.com/capenaka/airway-ml-cfd-linux/blob/main/Ortho_App/blender_ortho.py"
click node_n_paraview_script "https://github.com/capenaka/airway-ml-cfd-linux/blob/main/Ortho_App/paraview_ortho.py"
click node_n_case "https://github.com/capenaka/airway-ml-cfd-linux/tree/main/Ortho_App/data/Master_cfd_file/system/controlDict"
click node_n_case_backup "https://github.com/capenaka/airway-ml-cfd-linux/tree/main/Ortho_App/data/Master_cfd_file_backup/system/controlDict"
click node_n_run_scripts "https://github.com/capenaka/airway-ml-cfd-linux/tree/main/Ortho_App/data/Master_cfd_file/Allrun"

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_n_main,node_n_gui_app,node_n_gui_ortho,node_n_tab1,node_n_tab2,node_n_tab3,node_n_tab4,node_n_components,node_n_config,node_n_logger toneBlue
class node_n_image,node_n_segment,node_n_cfd_data,node_n_blender_proc,node_n_render,node_n_viewer,node_n_report toneAmber
class node_n_case,node_n_case_backup,node_n_run_scripts toneMint
class node_n_blender_script,node_n_paraview_script toneNeutral
```

## Components

### GUI shell

Desktop application entry, tab workflow, and shared widgets.

- [main.py](https://github.com/capenaka/airway-ml-cfd-linux/blob/main/Ortho_App/main.py): entrypoint · Application startup entry point. · `Ortho_App/main.py`
- [App shell](https://github.com/capenaka/airway-ml-cfd-linux/blob/main/Ortho_App/gui/app.py): window · Builds the main window and wires workflow state. · `Ortho_App/gui/app.py`
- [GUI bridge](https://github.com/capenaka/airway-ml-cfd-linux/blob/main/Ortho_App/GUI_ortho.py): launcher · Top-level GUI launcher/helper module. · `Ortho_App/GUI_ortho.py`
- [Tab 1](https://github.com/capenaka/airway-ml-cfd-linux/blob/main/Ortho_App/gui/tabs/tab1.py): workflow tab · First stage of the staged desktop workflow. · `Ortho_App/gui/tabs/tab1.py`
- [Tab 2](https://github.com/capenaka/airway-ml-cfd-linux/blob/main/Ortho_App/gui/tabs/tab2.py): workflow tab · Middle workflow stage for review or setup. · `Ortho_App/gui/tabs/tab2.py`
- [Tab 3](https://github.com/capenaka/airway-ml-cfd-linux/blob/main/Ortho_App/gui/tabs/tab3.py): workflow tab · CFD-related workflow stage. · `Ortho_App/gui/tabs/tab3.py`
- [Tab 4](https://github.com/capenaka/airway-ml-cfd-linux/blob/main/Ortho_App/gui/tabs/tab4.py): workflow tab · Final stage for results and report viewing. · `Ortho_App/gui/tabs/tab4.py`
- [Widgets](https://github.com/capenaka/airway-ml-cfd-linux/blob/main/Ortho_App/gui/components/__init__.py): ui toolkit · Shared buttons, dialogs, forms, navigation, progress, notebook, info, and PDF viewer components. · `Ortho_App/gui/components/__init__.py`
- [Config](https://github.com/capenaka/airway-ml-cfd-linux/blob/main/Ortho_App/gui/config/__init__.py): settings · Settings, logging configuration, and user-facing error messages. · `Ortho_App/gui/config/__init__.py`
- [Logger](https://github.com/capenaka/airway-ml-cfd-linux/blob/main/Ortho_App/gui/utils/app_logger.py): runtime logging · Application logging helper used across the GUI stack. · `Ortho_App/gui/utils/app_logger.py`

### Processing pipeline

Image processing, segmentation, 3D geometry, and report generation.

- [Image ops](https://github.com/capenaka/airway-ml-cfd-linux/blob/main/Ortho_App/gui/utils/image_processing.py): medical imaging · Loads and prepares CT/CBCT image data for the workflow. · `Ortho_App/gui/utils/image_processing.py`
- [Segmentation](https://github.com/capenaka/airway-ml-cfd-linux/blob/main/Ortho_App/gui/utils/segmentation.py): nnU-Net pipeline · Automated airway segmentation and mask handling. · `Ortho_App/gui/utils/segmentation.py`
- [CFD data](https://github.com/capenaka/airway-ml-cfd-linux/blob/main/Ortho_App/gui/utils/get_cfd_data.py): data extraction · Extracts and packages CFD-relevant inputs and outputs. · `Ortho_App/gui/utils/get_cfd_data.py`
- [Blender proc](https://github.com/capenaka/airway-ml-cfd-linux/blob/main/Ortho_App/gui/utils/blender_processor.py): 3d prep · Prepares or inspects mesh geometry through Blender integration. · `Ortho_App/gui/utils/blender_processor.py`
- [3D render](https://github.com/capenaka/airway-ml-cfd-linux/blob/main/Ortho_App/gui/utils/stl_assem_image_render.py): visualization · STL assembly and image rendering for geometry review. · `Ortho_App/gui/utils/stl_assem_image_render.py`
- [Open3D view](https://github.com/capenaka/airway-ml-cfd-linux/blob/main/Ortho_App/gui/utils/open3d_viewer.py): viewer · Interactive 3D geometry viewer. · `Ortho_App/gui/utils/open3d_viewer.py`
- [Report](https://github.com/capenaka/airway-ml-cfd-linux/blob/main/Ortho_App/gui/utils/generate_airway_report.py): reporting · Generates the airway report from processing and CFD results. · `Ortho_App/gui/utils/generate_airway_report.py`

### CFD template

Reusable OpenFOAM case assets and solver/postprocessing scripts.

- [OpenFOAM case](https://github.com/capenaka/airway-ml-cfd-linux/tree/main/Ortho_App/data/Master_cfd_file/system/controlDict): template case · Reusable CFD case template with system, constant, and initial-condition files. · `Ortho_App/data/Master_cfd_file/system/controlDict`
- [Case backup](https://github.com/capenaka/airway-ml-cfd-linux/tree/main/Ortho_App/data/Master_cfd_file_backup/system/controlDict): template backup · Backup copy of the OpenFOAM case template. · `Ortho_App/data/Master_cfd_file_backup/system/controlDict`
- [Run scripts](https://github.com/capenaka/airway-ml-cfd-linux/tree/main/Ortho_App/data/Master_cfd_file/Allrun): solver scripts · Allrun, Allclean, and gnuplot scripts for OpenFOAM execution and plotting. · `Ortho_App/data/Master_cfd_file/Allrun`

### Other components

- [blender_ortho.py](https://github.com/capenaka/airway-ml-cfd-linux/blob/main/Ortho_App/blender_ortho.py): external bridge · Standalone Blender-facing integration script. · `Ortho_App/blender_ortho.py`
- [paraview_ortho.py](https://github.com/capenaka/airway-ml-cfd-linux/blob/main/Ortho_App/paraview_ortho.py): external bridge · Standalone ParaView-facing integration script. · `Ortho_App/paraview_ortho.py`

## Connections

- main.py → App shell: starts · Main entry launches the application shell.
- GUI bridge → App shell: launches · Alternative launcher routes into the same GUI shell.
- App shell → Tab 1: hosts · App shell instantiates the staged workflow tabs.
- App shell → Tab 2: hosts · App shell instantiates the staged workflow tabs.
- App shell → Tab 3: hosts · App shell instantiates the staged workflow tabs.
- App shell → Tab 4: hosts · App shell instantiates the staged workflow tabs.
- App shell → Widgets: uses · Tabs and shell share reusable widgets and dialogs.
- App shell → Config: loads · App shell uses runtime settings and logging configuration.
- Config → Logger: configures · Logging setup feeds the shared logger.
- Tab 1 → Image ops: imports · Early workflow stage handles image input and preparation.
- Tab 1 → Segmentation: starts · Segmentation is triggered from the workflow.
- Tab 2 → Blender proc: prepares · Geometry review and mesh preparation step.
- Tab 2 → Open3D view: reviews · Interactive geometry inspection.
- Tab 2 → 3D render: renders · Workflow generates preview imagery for geometry review.
- Tab 3 → CFD data: packages · CFD stage collects simulation inputs and outputs.
- Tab 3 → OpenFOAM case: writes to · Workflow populates the OpenFOAM case template.
- Tab 3 → Run scripts: executes · Simulation run and plotting are delegated to case scripts.
- Tab 4 → Report: generates · Final stage produces the clinical-style report.
- Tab 4 → Widgets: displays · PDF viewer and related widgets present results in-app.
- Image ops → Segmentation: feeds · Prepared images are consumed by segmentation.
- Segmentation → CFD data: outputs · Segmentation results become CFD-relevant data.
- Blender proc → blender_ortho.py: bridges · Blender integration is exposed through a dedicated script.
- Open3D view → paraview_ortho.py: bridges · ParaView integration is exposed through a dedicated script.
- OpenFOAM case → Case backup: mirrors · Backup preserves a parallel copy of the case template.
- OpenFOAM case → Run scripts: contains · Template bundles solver and plotting scripts.
- Report → Widgets: renders · Generated PDF report is shown through shared UI components.
- OpenFOAM case → Report: supplies metrics · CFD outputs inform the report generation boundary.
