# rama-alsadeq/osteo-by-ai architecture

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

- Interactive diagram: https://gitdiagram.com/rama-alsadeq/osteo-by-ai
- Repository: https://github.com/rama-alsadeq/osteo-by-ai

## Overview

Osteo-by-AI is a Flask diagnostic web application for osteoarthritis and osteoporosis. Users submit knee X-rays and/or osteoporosis inputs; the Flask routes dispatch OA images through joint localization and OA grading, and dispatch OP inputs to BMD rules or knee-image analysis. The README also describes a clinical risk-factor model, dynamic multi-source fusion, and SHAP explanations, which are retained as documented capabilities. Runtime relationships are based on the shown excerpts and SOURCE INDEX; unsampled subsystem details are not inferred.

Main entry points: [`osteo_app.py`](https://github.com/rama-alsadeq/osteo-by-ai/blob/main/osteo_app.py) (Flask routes), [`pipelines/OP_Frame2.py`](https://github.com/rama-alsadeq/osteo-by-ai/blob/main/pipelines/OP_Frame2.py) (OP knee analysis), [`pipelines/OA_pipeline2.py`](https://github.com/rama-alsadeq/osteo-by-ai/blob/main/pipelines/OA_pipeline2.py) (OA grading), [`models`](https://github.com/rama-alsadeq/osteo-by-ai/tree/main/models) (Clinical risk model)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web interface"]
  node_web_ui["Diagnostic interface"]
  node_flask["Flask routes<br/>[osteo_app.py]"]
end

subgraph group_oa["Osteoarthritis"]
  node_oa_localize["Knee localization<br/>[OA_pipeline.py]"]
  node_oa_grade["OA grading<br/>[OA_pipeline2.py]"]
end

subgraph group_op["Osteoporosis"]
  node_op_bmd["BMD rules<br/>[OP_Frame1.py]"]
  node_op_image["OP knee analysis<br/>[OP_Frame2.py]"]
  node_op_clinical["Clinical risk model"]
  node_op_fusion["Dynamic fusion"]
end

subgraph group_models["Models and explanations"]
  node_oa_weights["OA model weights"]
  node_op_weights["OP model weights"]
  node_yolo_weights["YOLO helper weights"]
  node_gradcam["Image explanations<br/>[OA_pipeline2.py]"]
  node_shap["Clinical explanations"]
end

node_clinician(("Clinician"))

node_clinician -->|"submits inputs"| node_web_ui
node_web_ui -.->|"sends requests"| node_flask
node_flask -->|"renders responses"| node_web_ui
node_flask -->|"localizes knees"| node_oa_localize
node_flask -->|"grades crops"| node_oa_grade
node_oa_localize -->|"returns resized crops"| node_oa_grade
node_flask -->|"requests BMD diagnosis"| node_op_bmd
node_flask -->|"analyzes X-rays"| node_op_image
node_flask -.->|"predicts risk"| node_op_clinical
node_op_bmd -.->|"provides modality result"| node_op_fusion
node_op_image -.->|"provides modality result"| node_op_fusion
node_op_clinical -.->|"provides modality result"| node_op_fusion
node_oa_grade -->|"generates Grad-CAM"| node_gradcam
node_op_image -->|"generates Grad-CAM"| node_gradcam
node_op_clinical -.->|"explains risk factors"| node_shap
node_oa_weights -.->|"loaded by"| node_oa_grade
node_yolo_weights -.->|"used for detection"| node_oa_localize
node_op_weights -.->|"used for inference"| node_op_image

click node_web_ui "https://github.com/rama-alsadeq/osteo-by-ai/tree/main/templates"
click node_flask "https://github.com/rama-alsadeq/osteo-by-ai/blob/main/osteo_app.py"
click node_oa_localize "https://github.com/rama-alsadeq/osteo-by-ai/blob/main/pipelines/OA_pipeline.py"
click node_oa_grade "https://github.com/rama-alsadeq/osteo-by-ai/blob/main/pipelines/OA_pipeline2.py"
click node_op_bmd "https://github.com/rama-alsadeq/osteo-by-ai/blob/main/pipelines/OP_Frame1.py"
click node_op_image "https://github.com/rama-alsadeq/osteo-by-ai/blob/main/pipelines/OP_Frame2.py"
click node_op_clinical "https://github.com/rama-alsadeq/osteo-by-ai/tree/main/models"
click node_op_fusion "https://github.com/rama-alsadeq/osteo-by-ai/tree/main/models"
click node_oa_weights "https://github.com/rama-alsadeq/osteo-by-ai/tree/main/models"
click node_op_weights "https://github.com/rama-alsadeq/osteo-by-ai/tree/main/models"
click node_yolo_weights "https://github.com/rama-alsadeq/osteo-by-ai/tree/main/models"
click node_gradcam "https://github.com/rama-alsadeq/osteo-by-ai/blob/main/pipelines/OA_pipeline2.py"
click node_shap "https://github.com/rama-alsadeq/osteo-by-ai/tree/main/models"

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_web_ui,node_flask toneBlue
class node_oa_localize,node_oa_grade toneAmber
class node_op_bmd,node_op_image,node_op_clinical,node_op_fusion toneMint
class node_oa_weights,node_op_weights,node_yolo_weights,node_gradcam,node_shap toneRose
class node_clinician toneIndigo
```

## Components

### Web interface

- [Diagnostic interface](https://github.com/rama-alsadeq/osteo-by-ai/tree/main/templates): `templates`
- [Flask routes](https://github.com/rama-alsadeq/osteo-by-ai/blob/main/osteo_app.py): `osteo_app.py`

### Osteoarthritis

- [Knee localization](https://github.com/rama-alsadeq/osteo-by-ai/blob/main/pipelines/OA_pipeline.py): `pipelines/OA_pipeline.py`
- [OA grading](https://github.com/rama-alsadeq/osteo-by-ai/blob/main/pipelines/OA_pipeline2.py): `pipelines/OA_pipeline2.py`

### Osteoporosis

- [BMD rules](https://github.com/rama-alsadeq/osteo-by-ai/blob/main/pipelines/OP_Frame1.py): `pipelines/OP_Frame1.py`
- [OP knee analysis](https://github.com/rama-alsadeq/osteo-by-ai/blob/main/pipelines/OP_Frame2.py): `pipelines/OP_Frame2.py`
- [Clinical risk model](https://github.com/rama-alsadeq/osteo-by-ai/tree/main/models): `models`
- [Dynamic fusion](https://github.com/rama-alsadeq/osteo-by-ai/tree/main/models): `models`

### Models and explanations

- [OA model weights](https://github.com/rama-alsadeq/osteo-by-ai/tree/main/models): `models`
- [OP model weights](https://github.com/rama-alsadeq/osteo-by-ai/tree/main/models): `models`
- [YOLO helper weights](https://github.com/rama-alsadeq/osteo-by-ai/tree/main/models): `models`
- [Image explanations](https://github.com/rama-alsadeq/osteo-by-ai/blob/main/pipelines/OA_pipeline2.py): `pipelines/OA_pipeline2.py`
- [Clinical explanations](https://github.com/rama-alsadeq/osteo-by-ai/tree/main/models): `models`

### Other components

- **Clinician**

## Connections

- Clinician → Diagnostic interface: submits inputs (evidence: `README.md`)
- Diagnostic interface → Flask routes: sends requests
- Flask routes → Diagnostic interface: renders responses (evidence: `osteo_app.py`)
- Flask routes → Knee localization: localizes knees (evidence: `osteo_app.py`)
- Flask routes → OA grading: grades crops (evidence: `osteo_app.py`)
- Knee localization → OA grading: returns resized crops (evidence: `osteo_app.py`)
- Flask routes → BMD rules: requests BMD diagnosis (evidence: `osteo_app.py`)
- Flask routes → OP knee analysis: analyzes X-rays (evidence: `osteo_app.py`)
- Flask routes → Clinical risk model: predicts risk
- BMD rules → Dynamic fusion: provides modality result
- OP knee analysis → Dynamic fusion: provides modality result
- Clinical risk model → Dynamic fusion: provides modality result
- OA grading → Image explanations: generates Grad-CAM (evidence: `pipelines/OA_pipeline2.py`)
- OP knee analysis → Image explanations: generates Grad-CAM (evidence: `pipelines/OP_Frame2.py`)
- Clinical risk model → Clinical explanations: explains risk factors
- OA model weights → OA grading: loaded by
- YOLO helper weights → Knee localization: used for detection
- OP model weights → OP knee analysis: used for inference
