# mirzayasirabdullahbaig07/breast-cancer-prediction-model architecture

> Architecture diagram of the GitHub repository mirzayasirabdullahbaig07/breast-cancer-prediction-model, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-10-10). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/mirzayasirabdullahbaig07/breast-cancer-prediction-model
- Repository: https://github.com/mirzayasirabdullahbaig07/breast-cancer-prediction-model

## Overview

##### Project Type and Purpose
- This is a **full-stack, single-page web application** focused on **real-time ML inference**.
- The README and file tree show it is a **Streamlit** app (`app.py`) that loads a pre-trained model (`trained_model.sav`) to predict breast cancer risk, with optional offline training scripts in `model.py` and raw data in `data.csv`.

##### File Structure
- Top-level files:
- `app.py` – Streamlit front-end code, handles routing, UI elements, and calls inference functions.
- `model.py` – training script (uses Pandas/NumPy, Scikit-learn/TensorFlow) that reads `data.csv` and saves the model.
- `trained_model.sav` – serialized model for inference.
- `data.csv` – UCI dataset, used only in offline training.
- `requirements.txt` – dependency list for deployment.
- No separate “backend” or microservices: everything runs in one Python process hosted by Streamlit.

##### README for Additional Insights
- Tech stack: Python 3.9+, Streamlit (UI), NumPy/Pandas (data prep), Scikit-learn/TensorFlow (model), Pickle (serialization).
- Usage flow: User inputs 8 features → click Predict → model inference → display result card.
- No external database beyond `data.csv` (training only).

a. Main Components
- Browser / Client
- Streamlit Server (`app.py`)
- Inference Module (code in `app.py` or imported from `model.py`)
- Model Storage (`trained_model.sav`)
- (Offline) Training Module (`model.py` + `data.csv`)
- External Dataset Source (UCI)
b. Relationships & Interactions
1. Client (Browser) sends HTTP request via Streamlit UI.
2. Streamlit Server renders input form, collects features.
3. On “Predict,” Streamlit invokes the Inference Module.
4. Inference Module loads `trained_model.sav`, preprocesses inputs using NumPy/Pandas, computes prediction.
5. Result is returned to the Streamlit Server and rendered to the user.
6. (Optional, offline) Training Module reads `data.csv`, trains model, writes `trained_model.sav`.
c. Architectural Patterns & Principles
- Monolithic service with clear **separation of concerns**:
- UI Layer (Streamlit)
- Business Logic (Inference)
- Data Access (Model file, CSV)
- Single responsibility: `app.py` is for serving; `model.py` is for training.
- Light dependency injection: the model file is an external artifact, not hard-coded.
d. Key Technologies & Libraries
- Frontend: Streamlit
- Data Processing: Pandas, NumPy
- ML Frameworks: Scikit-learn, TensorFlow/Keras
- Serialization: Pickle
- Deployment: Streamlit Cloud or similar

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph "User Layer"
        Browser["Browser"]:::external
    end

    subgraph "UI Layer"
        Server["Streamlit Server"]:::ui
    end

    Browser -->|"HTTP Request"| Server

    subgraph "Real-time Inference Pipeline"
        Inference["Inference Module"]:::process
        ModelStorage[("trained_model.sav")]:::storage
    end

    Server -->|"Invoke Inference"| Inference
    Inference -->|"Load Model"| ModelStorage
    ModelStorage -->|"Return Prediction"| Inference
    Inference -->|"Result"| Server

    subgraph "Offline Training Pipeline"
        DataSource[("data.csv")]:::storage
        Training["Offline Training Module"]:::process
    end

    DataSource -->|"Train Model"| Training
    Training -->|"Save Model"| ModelStorage

    subgraph "Project Artifacts"
        README["README.md"]:::external
        Requirements["requirements.txt"]:::external
    end

    click Server "https://github.com/mirzayasirabdullahbaig07/breast-cancer-prediction-model/blob/main/app.py"
    click Inference "https://github.com/mirzayasirabdullahbaig07/breast-cancer-prediction-model/blob/main/app.py"
    click ModelStorage "https://github.com/mirzayasirabdullahbaig07/breast-cancer-prediction-model/blob/main/trained_model.sav"
    click Training "https://github.com/mirzayasirabdullahbaig07/breast-cancer-prediction-model/blob/main/model.py"
    click DataSource "https://github.com/mirzayasirabdullahbaig07/breast-cancer-prediction-model/blob/main/data.csv"
    click README "https://github.com/mirzayasirabdullahbaig07/breast-cancer-prediction-model/blob/main/README.md"
    click Requirements "https://github.com/mirzayasirabdullahbaig07/breast-cancer-prediction-model/blob/main/requirements.txt"

    classDef ui fill:#ADD8E6,stroke:#333,stroke-width:1px
    classDef process fill:#FFFF99,stroke:#333,stroke-width:1px
    classDef storage fill:#90EE90,stroke:#333,stroke-width:1px
    classDef external fill:#D3D3D3,stroke:#333,stroke-width:1px
```
