# aman-chhetri/medicare architecture

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

- Interactive diagram: https://gitdiagram.com/aman-chhetri/medicare
- Repository: https://github.com/aman-chhetri/medicare

## Overview

##### Project Type and Purpose
- This is a machine learning web application built using Streamlit. Its main purpose is to predict three diseases (Diabetes, Heart Disease, and Parkinson’s) from user-provided health parameters.
- The application leverages pre-trained models (stored as pickle files) and uses datasets as a basis for the model’s training process (provided in CSV format).
- The README also shows that the project integrates a front-end (user interaction via Streamlit) with machine learning inference functionalities.

##### Analyzing the File Structure
- Top-level files and folders include:
- README.md – provides project description and usage instructions.
- app.py – the main entry point for the Streamlit web application.
- assets – contains static assets such as the banner image used on the UI.
- collab files – includes several Jupyter notebooks (for Diabetes, Heart, and Parkinson’s) that likely document model training and analysis.
- datasets – contains CSV files for each disease, representing the raw data.
- model – holds the pre-trained pickle model files corresponding to each disease prediction.
- requirements.txt – list of dependencies to run the software.

a. Main Components:
- User Interface: Represented by the Streamlit application (app.py) coupled with static assets (assets directory).
- Prediction Engine: The ML inference component which loads the appropriate pickle models from the model folder.
- Data Management: Datasets stored in the datasets directory that are used for model training/validation (though not directly used in the Streamlit app, they are a core part of the project).
- Development/Analysis Tools: Notebooks in the collab files folder used for model training, exploratory data analysis, and validation.
- Dependencies & Configuration: Highlight dependency management via requirements.txt.

b. Relationships and Interactions:
- The User Interface (Streamlit front-end) gathers health parameters from the user.
- Once a prediction is requested, app.py calls the Prediction Engine, which loads the relevant pre-trained model (using the pickle file from the model folder) to generate output.
- The prediction results are then displayed back on the UI.
- The underlying development notebooks (in collab files) show the process behind generating these models and possibly provide a feedback loop for model improvement.
- Optionally, if re-training or further analysis is considered, the datasets feed into the training notebooks, and re-trained pickle files get deployed into the model folder.

c. Architectural Patterns and Design Principles:
- Separation of Concerns: Clear partition between user interface (Streamlit), machine learning model inference (pickle files in model folder), and data management/training (datasets and notebooks).
- Modularization: Components such as prediction logic are decoupled from the front-end interface, making it easier to update or swap out models without major UI changes.
- Extensibility: The design hints at the possibility of adding more models or diseases by following a similar directory structure and pattern.

d. Relevant Technologies and Frameworks:
- Streamlit for fast web UI development.
- scikit-learn (along with numpy, pandas, matplotlib, seaborn) for machine learning model development and data visualization in the notebooks.
- Pickle for model serialization.
- Git for version control and collaboration.

##### Elements
- UI Component: “Streamlit App (app.py)” with a sub-label for assets.
- Prediction Component: “ML Prediction Engine” which loads models from the “model” directory.
- Data Sources: “Datasets (CSV files)” and “Experimental Notebooks (collab files)” to indicate the training/preparation steps.
- Dependency Management: “requirements.txt” to signify external libraries and frameworks.
- Data flow from the user (input parameters) → Streamlit App → Prediction Engine → back to the UI (output predictions).
- Dependency links such as the UI depending on both the underlying ML models and libraries.

## Diagram (Mermaid)

```mermaid
flowchart TD
    User["User"]:::user

    subgraph "User Interface Layer"
        UI["Streamlit App (app.py)"]:::ui
        ASSET["Static Assets (assets)"]:::asset
    end

    subgraph "Prediction Engine"
        PE["ML Prediction Engine"]:::ml
        DMODEL1["Diabetes Model"]:::model
        DMODEL2["Heart Disease Model"]:::model
        DMODEL3["Parkinsons Model"]:::model
    end

    subgraph "Data and Development"
        subgraph "Datasets"
            DS1["Diabetes CSV"]:::data
            DS2["Heart CSV"]:::data
            DS3["Parkinsons CSV"]:::data
        end
        subgraph "Experimental Notebooks"
            NB1["Diabetes Notebook"]:::nb
            NB2["Heart Notebook"]:::nb
            NB3["Parkinsons Notebook"]:::nb
        end
    end

    DM["Dependency Management (requirements.txt)"]:::dep
    DOC["Project Documentation (README.md)"]:::doc

    User -->|"providesInput"| UI
    UI -->|"sendsTo"| PE
    PE -->|"returnsPrediction"| UI

    PE -->|"loads"| DMODEL1
    PE -->|"loads"| DMODEL2
    PE -->|"loads"| DMODEL3

    DS1 -->|"providesData"| NB1
    DS2 -->|"providesData"| NB2
    DS3 -->|"providesData"| NB3

    NB1 -->|"updates"| PE
    NB2 -->|"updates"| PE
    NB3 -->|"updates"| PE

    DM -->|"dependency"| UI
    DM -->|"dependency"| PE

    DOC -->|"documentation"| UI

    click UI "https://github.com/aman-chhetri/medicare/blob/main/app.py"
    click ASSET "https://github.com/aman-chhetri/medicare/tree/main/assets"
    click DMODEL1 "https://github.com/aman-chhetri/medicare/blob/main/model/diabetes_model.pkl"
    click DMODEL2 "https://github.com/aman-chhetri/medicare/blob/main/model/heart_disease_model.pkl"
    click DMODEL3 "https://github.com/aman-chhetri/medicare/blob/main/model/parkinsons_model.pkl"
    click DS1 "https://github.com/aman-chhetri/medicare/blob/main/datasets/diabetes.csv"
    click DS2 "https://github.com/aman-chhetri/medicare/blob/main/datasets/heart.csv"
    click DS3 "https://github.com/aman-chhetri/medicare/blob/main/datasets/parkinsons.csv"
    click NB1 "https://github.com/aman-chhetri/medicare/blob/main/collab files/MediCare_Diabetes.ipynb"
    click NB2 "https://github.com/aman-chhetri/medicare/blob/main/collab files/MediCare_Heart.ipynb"
    click NB3 "https://github.com/aman-chhetri/medicare/blob/main/collab files/MediCare_Parkinsons.ipynb"
    click DM "https://github.com/aman-chhetri/medicare/blob/main/requirements.txt"
    click DOC "https://github.com/aman-chhetri/medicare/blob/main/README.md"

    classDef ui fill:#f9e79f,stroke:#b9770e,stroke-width:2px;
    classDef asset fill:#d6eaf8,stroke:#3498db,stroke-width:2px;
    classDef ml fill:#fadbd8,stroke:#e74c3c,stroke-width:2px;
    classDef model fill:#d2b4de,stroke:#8e44ad,stroke-width:2px;
    classDef data fill:#d5f5e3,stroke:#28b463,stroke-width:2px;
    classDef nb fill:#fcf3cf,stroke:#f1c40f,stroke-width:2px;
    classDef dep fill:#fdebd0,stroke:#e67e22,stroke-width:2px;
    classDef doc fill:#d6eaf8,stroke:#5dade2,stroke-width:2px;
    classDef user fill:#fadbd8,stroke:#e74c3c,stroke-width:2px;
```
