# kasemrrash/tumor-detection-ai architecture

> Architecture diagram of the GitHub repository kasemrrash/tumor-detection-ai, 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/kasemrrash/tumor-detection-ai
- Repository: https://github.com/kasemrrash/tumor-detection-ai

## Overview

TUMOR AI is a Flask-based MRI tumor-classification demo. A user uploads an image; the Flask route saves and preprocesses it, runs model inference, derives a confidence result, creates a Grad-CAM overlay, and renders the result. The README also describes model training and example data. The two Python entry points contain similar workflows; the graph shows the documented `predict.py` runtime and the alternative `app.py` entry point. Training and dataset links reflect README descriptions; notebook internals were not sampled.

Main entry points: [`TumorAI/predict.py`](https://github.com/kasemrrash/tumor-detection-ai/blob/main/TumorAI/predict.py) (Flask workflow), [`TumorAI/app.py`](https://github.com/kasemrrash/tumor-detection-ai/blob/main/TumorAI/app.py) (Alternate workflow), [`TumorAI/static/uploads`](https://github.com/kasemrrash/tumor-detection-ai/tree/main/TumorAI/static/uploads) (Uploaded images), [`TumorAI/templates/result.html`](https://github.com/kasemrrash/tumor-detection-ai/blob/main/TumorAI/templates/result.html) (Result view)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web experience"]
  node_predict_app["Flask workflow<br/>[predict.py]"]
  node_alternate_app["Alternate workflow<br/>[app.py]"]
  node_upload_view["Upload view<br/>[index.html]"]
  node_result_view["Result view<br/>[result.html]"]
  node_browser_assets["Page styling<br/>[style.css]"]
  node_browser_script["Page script<br/>[script.js]"]
end

subgraph group_analysis["Image analysis"]
  node_image_prep["Image preprocessing<br/>[predict.py]"]
  node_classifier["Tumor classifier<br/>[predict.py]"]
  node_confidence["Class and confidence<br/>[predict.py]"]
  node_gradcam["Grad-CAM heatmap<br/>[predict.py]"]
  node_overlay["Overlay generation<br/>[predict.py]"]
  node_model_file["Keras model"]
end

subgraph group_training["Training data"]
  node_training_notebook["Model training"]
  node_dataset["MRI dataset"]
end

subgraph group_assets["Generated assets"]
  node_uploads["Uploaded images"]
  node_results["Overlay images"]
end

node_user(("User"))

node_user -->|"submits image"| node_predict_app
node_predict_app -->|"renders upload"| node_upload_view
node_predict_app -->|"saves upload"| node_uploads
node_predict_app -->|"preprocesses"| node_image_prep
node_image_prep -->|"reads image"| node_uploads
node_predict_app -->|"predicts"| node_classifier
node_classifier -->|"loads model"| node_model_file
node_predict_app -->|"derives result"| node_confidence
node_predict_app -->|"computes heatmap"| node_gradcam
node_gradcam -->|"uses model layers"| node_model_file
node_predict_app -->|"creates overlay"| node_overlay
node_overlay -->|"reads original"| node_uploads
node_overlay -->|"writes overlay"| node_results
node_predict_app -->|"renders result"| node_result_view
node_result_view -->|"references overlay"| node_results
node_result_view -->|"references original"| node_uploads
node_predict_app -->|"serves page style"| node_browser_assets
node_predict_app -->|"serves page script"| node_browser_script
node_user -.->|"submits image"| node_alternate_app
node_alternate_app -.->|"renders upload"| node_upload_view
node_alternate_app -.->|"saves upload"| node_uploads
node_alternate_app -.->|"loads model"| node_model_file
node_alternate_app -.->|"writes overlay"| node_results
node_alternate_app -.->|"renders analysis"| node_upload_view
node_dataset -.->|"training examples"| node_training_notebook
node_training_notebook -.->|"trains model"| node_model_file

click node_predict_app "https://github.com/kasemrrash/tumor-detection-ai/blob/main/TumorAI/predict.py"
click node_alternate_app "https://github.com/kasemrrash/tumor-detection-ai/blob/main/TumorAI/app.py"
click node_upload_view "https://github.com/kasemrrash/tumor-detection-ai/blob/main/TumorAI/templates/index.html"
click node_result_view "https://github.com/kasemrrash/tumor-detection-ai/blob/main/TumorAI/templates/result.html"
click node_browser_assets "https://github.com/kasemrrash/tumor-detection-ai/blob/main/TumorAI/static/style.css"
click node_browser_script "https://github.com/kasemrrash/tumor-detection-ai/blob/main/TumorAI/static/script.js"
click node_image_prep "https://github.com/kasemrrash/tumor-detection-ai/blob/main/TumorAI/predict.py"
click node_classifier "https://github.com/kasemrrash/tumor-detection-ai/blob/main/TumorAI/predict.py"
click node_confidence "https://github.com/kasemrrash/tumor-detection-ai/blob/main/TumorAI/predict.py"
click node_gradcam "https://github.com/kasemrrash/tumor-detection-ai/blob/main/TumorAI/predict.py"
click node_overlay "https://github.com/kasemrrash/tumor-detection-ai/blob/main/TumorAI/predict.py"
click node_uploads "https://github.com/kasemrrash/tumor-detection-ai/tree/main/TumorAI/static/uploads"
click node_results "https://github.com/kasemrrash/tumor-detection-ai/tree/main/TumorAI/static/results"
click node_training_notebook "https://github.com/kasemrrash/tumor-detection-ai/blob/main/TumorAI/trainingsmodell.ipynb"
click node_dataset "https://github.com/kasemrrash/tumor-detection-ai/tree/main/TumorAI/archive/brain_tumor_dataset"

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_predict_app,node_alternate_app,node_upload_view,node_result_view,node_browser_assets,node_browser_script,node_user toneBlue
class node_image_prep,node_classifier,node_confidence,node_gradcam,node_overlay,node_model_file toneAmber
class node_training_notebook,node_dataset toneMint
class node_uploads,node_results toneRose
```

## Components

### Web experience

- [Flask workflow](https://github.com/kasemrrash/tumor-detection-ai/blob/main/TumorAI/predict.py): `TumorAI/predict.py`
- [Alternate workflow](https://github.com/kasemrrash/tumor-detection-ai/blob/main/TumorAI/app.py): `TumorAI/app.py`
- [Upload view](https://github.com/kasemrrash/tumor-detection-ai/blob/main/TumorAI/templates/index.html): `TumorAI/templates/index.html`
- [Result view](https://github.com/kasemrrash/tumor-detection-ai/blob/main/TumorAI/templates/result.html): `TumorAI/templates/result.html`
- [Page styling](https://github.com/kasemrrash/tumor-detection-ai/blob/main/TumorAI/static/style.css): `TumorAI/static/style.css`
- [Page script](https://github.com/kasemrrash/tumor-detection-ai/blob/main/TumorAI/static/script.js): `TumorAI/static/script.js`

### Image analysis

- [Image preprocessing](https://github.com/kasemrrash/tumor-detection-ai/blob/main/TumorAI/predict.py): `TumorAI/predict.py`
- [Tumor classifier](https://github.com/kasemrrash/tumor-detection-ai/blob/main/TumorAI/predict.py): `TumorAI/predict.py`
- [Class and confidence](https://github.com/kasemrrash/tumor-detection-ai/blob/main/TumorAI/predict.py): `TumorAI/predict.py`
- [Grad-CAM heatmap](https://github.com/kasemrrash/tumor-detection-ai/blob/main/TumorAI/predict.py): `TumorAI/predict.py`
- [Overlay generation](https://github.com/kasemrrash/tumor-detection-ai/blob/main/TumorAI/predict.py): `TumorAI/predict.py`
- **Keras model**

### Training data

- [Model training](https://github.com/kasemrrash/tumor-detection-ai/blob/main/TumorAI/trainingsmodell.ipynb): `TumorAI/trainingsmodell.ipynb`
- [MRI dataset](https://github.com/kasemrrash/tumor-detection-ai/tree/main/TumorAI/archive/brain_tumor_dataset): `TumorAI/archive/brain_tumor_dataset`

### Generated assets

- [Uploaded images](https://github.com/kasemrrash/tumor-detection-ai/tree/main/TumorAI/static/uploads): `TumorAI/static/uploads`
- [Overlay images](https://github.com/kasemrrash/tumor-detection-ai/tree/main/TumorAI/static/results): `TumorAI/static/results`

### Other components

- **User**

## Connections

- User → Flask workflow: submits image
- Flask workflow → Upload view: renders upload
- Flask workflow → Uploaded images: saves upload
- Flask workflow → Image preprocessing: preprocesses
- Image preprocessing → Uploaded images: reads image
- Flask workflow → Tumor classifier: predicts
- Tumor classifier → Keras model: loads model
- Flask workflow → Class and confidence: derives result
- Flask workflow → Grad-CAM heatmap: computes heatmap
- Grad-CAM heatmap → Keras model: uses model layers
- Flask workflow → Overlay generation: creates overlay
- Overlay generation → Uploaded images: reads original
- Overlay generation → Overlay images: writes overlay
- Flask workflow → Result view: renders result
- Result view → Overlay images: references overlay
- Result view → Uploaded images: references original
- Flask workflow → Page styling: serves page style
- Flask workflow → Page script: serves page script
- User → Alternate workflow: submits image
- Alternate workflow → Upload view: renders upload
- Alternate workflow → Uploaded images: saves upload
- Alternate workflow → Keras model: loads model
- Alternate workflow → Overlay images: writes overlay
- Alternate workflow → Upload view: renders analysis
- MRI dataset → Model training: training examples
- Model training → Keras model: trains model
