# rayen03/tumor-detect architecture

> Architecture diagram of the GitHub repository rayen03/tumor-detect, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/rayen03/tumor-detect
- Repository: https://github.com/rayen03/tumor-detect

## Overview

##### Project Type and Purpose
- A Streamlit-based web app for tumor prediction using a pre‐trained TensorFlow model
- Includes a Jupyter notebook for exploratory data analysis/training (offline)
- Serves image-based inputs (Chest CT scans) and returns classification output

##### Main Components
1. User Interface (Streamlit Frontend)
2. Inference Service (app.py)
3. Model Storage (TensorFlow SavedModel on disk)
4. Data Input Sources
– User-uploaded CT scan images
– Preloaded sample dataset
5. Offline Notebook (Tumor_Detect.ipynb)
– Data exploration & model training
– Produces the SavedModel
6. External Dependencies
– TensorFlow, Streamlit, image-processing libs

##### Interactions & Data Flow
- The user opens the Streamlit UI in their browser →
- Streamlit server (app.py) renders upload/component widgets →
- Uploaded image or sample image is passed to a preprocessing function →
- Preprocessed tensor is fed into the loaded TensorFlow model →
- Model returns prediction (e.g., “tumor” vs. “no tumor”) →
- Prediction is displayed in the UI

Offline (optional) flow:
- Analyst runs Tumor_Detect.ipynb locally →
- Notebook loads raw data, trains/evaluates TensorFlow model →
- Exports a SavedModel file used by the Streamlit app

##### Architectural Patterns & Design Principles
- Clear separation of concerns:
– UI layer (Streamlit) vs. Inference layer (model) vs. Data layer (inputs & model files)
- Stateless service: each user request is independent
- Single process server: no microservices (monolith)
- Reusable artifact: the TensorFlow SavedModel can be swapped without UI changes

##### Elements
– Component blocks: “Streamlit Frontend”, “Inference Engine (app.py)”, “Model Storage”
– Input sources: “User-Uploaded Images”, “Sample Images”
– Offline block: “Jupyter Notebook (Data Analysis & Training)”
– Dependencies cluster: “TensorFlow”, “Streamlit”, “Pillow” etc.
- UI (blue),
- Compute (green),
- Storage (orange),
- Offline/Training (gray)

Putting It All Together
– Top lane: Online Inference Workflow
2. In the top lane, left to right:
[User Browser] → [Streamlit UI (app.py)] → [Preprocessor Module] → [TensorFlow Model] → [UI Renderer]
3. In the bottom lane:
[Tumor_Detect.ipynb] → [Data Loader] → [Model Training] → [Export SavedModel]

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Online Inference Workflow"
        Browser["User Browser"]:::ui
        UI["Streamlit UI (app.py)"]:::ui
        Preprocessor["Preprocessor Module"]:::compute
        ModelEngine["Inference Engine (TensorFlow Model)"]:::compute
        Renderer["UI Renderer"]:::ui
        Storage[(SavedModel on Disk)]:::storage
    end

    Browser -->|"open app"| UI
    UI -->|"upload image"| Preprocessor
    Preprocessor -->|"predict()"| ModelEngine
    ModelEngine -->|"prediction"| Renderer
    ModelEngine -->|"load model"| Storage
    Renderer -->|"render result"| Browser

    subgraph "Offline Notebook Workflow"
        Notebook["Jupyter Notebook (Tumor_Detect.ipynb)"]:::offline
        DataLoader["Data Loader"]:::offline
        Training["Model Training"]:::offline
        Exporter["Export SavedModel"]:::offline
    end

    Notebook -->|"load raw data"| DataLoader
    DataLoader -->|"train model"| Training
    Training -->|"export model"| Exporter
    Exporter -.->|"output SavedModel"| Storage

    subgraph "External Dependencies"
        Deps["requirements.txt"]:::external
    end

    UI -.->|uses| Deps
    Preprocessor -.->|uses| Deps
    ModelEngine -.->|uses| Deps
    Notebook -.->|uses| Deps

    subgraph "Project Resources"
        Documentation["Project Documentation (readMe.md)"]:::docs
        Assets["Example Assets (screenshots/)"]:::assets
    end

    classDef ui fill:#D0E6FF,stroke:#0366d6,stroke-width:1px
    classDef compute fill:#E6F4EA,stroke:#28a745,stroke-width:1px
    classDef storage fill:#FFE8A1,stroke:#D69E2E,stroke-width:1px
    classDef offline fill:#F0F0F0,stroke:#888888,stroke-width:1px
    classDef external fill:#F5E6FF,stroke:#8e44ad,stroke-width:1px
    classDef docs fill:#FFF5E6,stroke:#d35400,stroke-width:1px
    classDef assets fill:#E8F1F2,stroke:#17a2b8,stroke-width:1px

    click UI "https://github.com/rayen03/tumor-detect/blob/main/app.py"
    click Notebook "https://github.com/rayen03/tumor-detect/blob/main/Tumor_Detect.ipynb"
    click Deps "https://github.com/rayen03/tumor-detect/blob/main/requirements.txt"
    click Documentation "https://github.com/rayen03/tumor-detect/blob/main/readMe.md"
    click Assets "https://github.com/rayen03/tumor-detect/tree/main/screenshots/"
```
