# vishalm029/health_help architecture

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

- Interactive diagram: https://gitdiagram.com/vishalm029/health_help
- Repository: https://github.com/vishalm029/health_help

## Overview

##### Project type and purpose
- From the README and file‐tree, this is a full-stack web application (“Healthcare Management Platform”) built in Flask (Python).
- Core features: disease prediction via ML models, online appointment booking, medical record storage.

##### File structure
- Top-level files:
- app.py – main Flask application entry point
- db/medilab.sql – database schema/data
- flask_session/ – server-side session store
- Data/ – CSV data and pickle files for training and loading ML models
- DiseasePrediction.ipynb – Jupyter notebook for model development
- README.md – project overview
- Directories:
- Templates/ – Jinja2 HTML templates (views) for all user flows (patient, doctor, shared header/footer)
- Static/ – front-end assets (css/, js/, fonts/, img/)
- Pattern: classic MVC/MVT (Model-View-Controller / Model-View-Template)
- Deployment hints: uses Flask’s builtin server, Python dependencies (in README “npm install” looks misplaced but likely “pip install”), no separate microservices.

##### README for additional insights
- Stack: Python/Flask backend, SQLite (or MySQL) database, client renders static assets plus dynamic HTML via Jinja2.
- ML integration: two pre-trained models (KNN, Random Forest) loaded at runtime.

1. Client (Web Browser)
2. Web Server / Application Layer (Flask app.py)
3. Template Engine (Jinja2 + Templates/)
4. Static‐Assets Server (Static/)
5. Machine Learning Engine (Data/ models + loading code)
6. Database (db/medilab.sql)
7. Session Store (flask_session/)
- Client → HTTP request → Flask app
- Flask app → selects Template → Jinja2 → renders HTML → Client
- Client fetches CSS/JS/img from Static/
- For disease prediction: Flask app invokes ML engine → loads pickle → returns prediction → inject into template
- For appointments & records: Flask app performs CRUD → Database
- Flask app reads/writes session data → Session Store
c. Architectural patterns & design principles:
- MVC/MVT: clear separation of views (Templates), controllers (Flask routes in app.py), models (DB layer + ML models)
- Single-process, monolithic server but logical separation of concerns
d. Key technologies/frameworks:
- Flask (Python)
- Jinja2
- SQLite/MySQL (via db/medilab.sql)
- Server-side sessions (flask_session)
- Machine Learning: scikit-learn KNN and Random Forest (pickle files)
- Frontend: HTML5, CSS3, JavaScript (custom.js), FontAwesome

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Presentation Tier
    subgraph "Presentation Tier"
        direction TB
        Browser["Client Browser"]:::frontend
        TemplateEngine["Template Engine (Jinja2 Views)"]:::frontend
        StaticAssets["Static Assets Server"]:::frontend
        StyleCSS["CSS (style.css)"]:::frontend
        ScriptJS["JavaScript (custom.js)"]:::frontend
        Browser -->|"HTTP Request"| FlaskApp
        Browser -->|"Fetch CSS/JS/Images"| StaticAssets
        StaticAssets --> StyleCSS
        StaticAssets --> ScriptJS
        FlaskApp -->|"Render HTML"| TemplateEngine
        TemplateEngine --> Browser
    end

    %% Application Tier
    subgraph "Application Tier"
        direction TB
        FlaskApp["Flask App (app.py)"]:::backend
        MLEngine["Machine Learning Engine"]:::ml
        KNNModel["KNN Model (knn_disease_model.pkl)"]:::ml
        RFModel["Random Forest Model (rf_disease_model.pkl)"]:::ml
        CSVData["Training Data (CSV)"]:::ml
        SessionStore["Session Store"]:::datastore

        FlaskApp -->|"load model.predict()"| MLEngine
        MLEngine -->|"predict() → result"| FlaskApp
        MLEngine --> KNNModel
        MLEngine --> RFModel
        MLEngine --> CSVData
        FlaskApp -->|"Read/Write Session"| SessionStore
    end

    %% Data Tier
    subgraph "Data Tier"
        direction TB
        Database["Database (medilab.sql)"]:::datastore
        Notebook["ML Development Notebook"]:::ml
        FlaskApp -->|"SQL CRUD"| Database
        MLEngine -->|"Dataset Exploration"| Notebook
    end

    %% Click events
    click FlaskApp "https://github.com/vishalm029/health_help/blob/main/app.py"
    click TemplateEngine "https://github.com/vishalm029/health_help/tree/main/Templates/"
    click StaticAssets "https://github.com/vishalm029/health_help/tree/main/Static/"
    click StyleCSS "https://github.com/vishalm029/health_help/blob/main/Static/css/style.css"
    click ScriptJS "https://github.com/vishalm029/health_help/blob/main/Static/js/custom.js"
    click KNNModel "https://github.com/vishalm029/health_help/blob/main/Data/knn_disease_model.pkl"
    click RFModel "https://github.com/vishalm029/health_help/blob/main/Data/rf_disease_model.pkl"
    click CSVData "https://github.com/vishalm029/health_help/tree/main/Data/"
    click Database "https://github.com/vishalm029/health_help/blob/main/db/medilab.sql"
    click SessionStore "https://github.com/vishalm029/health_help/tree/main/flask_session/"
    click Notebook "https://github.com/vishalm029/health_help/blob/main/DiseasePrediction.ipynb"

    %% Styles
    classDef frontend fill:#D6E9FE,stroke:#0575CD,color:#000
    classDef backend fill:#D5F5D6,stroke:#27AE60,color:#000
    classDef datastore fill:#FDEBD0,stroke:#D35400,color:#000
    classDef ml fill:#EBDEF0,stroke:#8E44AD,color:#000
```
