# uday2kranth/health-care-ml-final-project architecture

> Architecture diagram of the GitHub repository uday2kranth/health-care-ml-final-project, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-07-16). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/uday2kranth/health-care-ml-final-project
- Repository: https://github.com/uday2kranth/health-care-ml-final-project

## Overview

##### Project Type and Purpose
- Type: Full-stack single-service web application combining ML model development and real-time serving.
- Purpose:
– Expose these models in an interactive Streamlit dashboard for end users.

##### File Structure
Top level:
- Healthcare_ML_Models_Annotated_and_Visualized.ipynb – EDA + Model development
- healthcare_app.py – Streamlit app (data loading, model training/caching, UI, prediction)
- requirements.txt – Python dependencies
- resources/ – Static assets (images for UI)
- README.md, LICENSE, .gitignore

No separate “frontend”/“backend” folders; the Streamlit script unifies UI, data-prep, model logic, and visualization.

##### Architectural Patterns
- Single service “app” deployed on Streamlit Cloud (or local): no microservices.
- Caching decorators (`@st.cache_data`, `@st.cache_resource`) separate costly operations (data load, model training) from per-request logic.
- MVC-like separation within the Streamlit script:
– Model layer: data-prep & XGBoost training functions
– View layer: Streamlit UI components (sidebar, sliders, charts)
– Controller logic: event-driven handlers that tie UI inputs to model predictions and charts

##### Main System Components
A. Data Sources
– Breast cancer CSV (from scikit-learn)
– Diabetes CSV (from scikit-learn)
B. Model-Development Pipeline (Notebook)
– EDA: Pandas, Seaborn, Matplotlib, Plotly
– Preprocessing: scaling, feature selection
– Model training: XGBoost Classifier & Regressor
– Model evaluation: metrics, cross-validation
C. Streamlit App (healthcare_app.py)
1. Data Loading & Caching
- load_and_prepare_data()
2. Model Training & Caching
- train_breast_cancer_model()
- train_diabetes_model()
3. UI Components
- Sidebar (model selection, project info)
- Main area tabs (classification, regression, exploration)
4. Prediction Engine
- Accept slider inputs → call cached model → output predictions
5. Visualization Engine
- Render charts (feature importance, ROC, scatter, heatmaps)
6. Resource Loader
- load_image_from_resources() for static UI assets
D. External & Deployment
– Users (browser)
– Streamlit Cloud / Local Python runtime
– Python libraries (Streamlit, XGBoost, Pandas, Plotly, Seaborn, PIL)

##### Highlighting Architectural Principles
- Single-service, event-driven architecture – Streamlit acts as both server and UI
- Caching to optimize performance and avoid retraining on every request
- Modular functions for data-prep, training, I/O, and visualization
- Clear separation of concerns even within a single script

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Data Sources
    subgraph "Data Sources"
        DS1["Breast Cancer CSV"]:::ml
        DS2["Diabetes CSV"]:::ml
    end

    %% Notebook Pipeline
    Notebook["Model-Development Pipeline\n(Notebook)"]:::ml
    DS1 -->|"load_data()"| Notebook
    DS2 -->|"load_data()"| Notebook

    %% Model Artifacts
    Artifacts["Trained Models\n(XGBoost Classifier & Regressor)"]:::ml
    Notebook -->|"train_model()"| Artifacts

    %% Caching Layer
    Cache["In-Memory Cache\n(@st.cache_data, @st.cache_resource)"]:::cache
    Artifacts -->|"cache_models()"| Cache

    %% Streamlit Application
    App["Streamlit App\n(healthcare_app.py)"]:::ui
    Cache -->|"load_cached_model()"| App
    Resource["Resource Loader\nload_image_from_resources()"]:::ui
    Resource -->|"provide_assets()"| App

    %% UI Components
    subgraph "UI Components"
        Sidebar["Sidebar\n(model selection, info)"]:::ui
        MainTabs["Main Area Tabs\n(classification, regression, exploration)"]:::ui
        PredictionEngine["Prediction Engine\n(slider inputs → predict())"]:::ui
        VisualizationEngine["Visualization Engine\n(charts, plots)"]:::ui
    end
    App --> Sidebar
    App --> MainTabs
    Sidebar --> PredictionEngine
    MainTabs --> PredictionEngine
    PredictionEngine -->|"predict()"| Cache
    PredictionEngine --> VisualizationEngine
    VisualizationEngine --> App

    %% Deployment & Users
    User["User (Browser)"]:::infra
    Deployment["Deployment\nStreamlit Cloud / Local"]:::infra
    User -->|"HTTP Request"| App
    App -->|"HTTP Response"| User
    Deployment --> App

    %% Project Files
    subgraph "Project Files"
        Requirements["requirements.txt"]:::infra
        ProjectReadme["README.md"]:::infra
        LicenseF["LICENSE"]:::infra
        Gitignore[".gitignore"]:::infra
    end

    %% Click Events
    click Notebook "https://github.com/uday2kranth/health-care-ml-final-project/blob/main/Healthcare_ML_Models_Annotated_and_Visualized.ipynb"
    click App "https://github.com/uday2kranth/health-care-ml-final-project/blob/main/healthcare_app.py"
    click Resource "https://github.com/uday2kranth/health-care-ml-final-project/tree/main/resources/"
    click Requirements "https://github.com/uday2kranth/health-care-ml-final-project/blob/main/requirements.txt"
    click ProjectReadme "https://github.com/uday2kranth/health-care-ml-final-project/blob/main/README.md"
    click LicenseF "https://github.com/uday2kranth/health-care-ml-final-project/tree/main/LICENSE"
    click Gitignore "https://github.com/uday2kranth/health-care-ml-final-project/blob/main/.gitignore"

    %% Styles
    classDef ml fill:#E3F2FD,stroke:#2196F3,color:#0D47A1,stroke-width:2px;
    classDef ui fill:#E8F5E9,stroke:#4CAF50,color:#1B5E20,stroke-width:2px;
    classDef cache fill:#FFF3E0,stroke:#FF9800,color:#E65100,stroke-width:2px;
    classDef infra fill:#ECEFF1,stroke:#607D8B,color:#263238,stroke-width:2px;
```
