# roshniranads27/a_flask-api_driven_machine_learning_model-personalized_medical_recommendation_system architecture

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

- Interactive diagram: https://gitdiagram.com/roshniranads27/a_flask-api_driven_machine_learning_model-personalized_medical_recommendation_system
- Repository: https://github.com/roshniranads27/a_flask-api_driven_machine_learning_model-personalized_medical_recommendation_system

## Overview

##### Project Type and Purpose
- This is a full-stack machine learning application primarily built as a Flask API. Its purpose is to take user symptom inputs via a one-screen dashboard, process them using machine learning models (such as Linear Regression, SVC, RandomForest, etc.), and return personalized medical recommendations including disease predictions, descriptions, medication lists, workout routines, diets, and precautionary advice.
- The README clearly states that the system integrates data science workflows (data cleaning, model training using libraries like scikit-learn, pandas, and others) with a web-based interface, making it an end-to-end solution for personalized diagnostics.

##### Analyzing the File Structure
- Top-Level Files: Notebooks like “HealthCareML_Code_Roshni.ipynb”, “Intial_Analysis_Project_4.ipynb”, and “data_description.ipynb” show the exploratory data analysis, cleaning, and model training phases.
- Directories:
– “archive”: Contains older and versioned analyses (notebooks, CSV files, pickled models) indicating historical experiments.
– “dataset”: Houses datasets including CSV files for symptoms, diagnostics, and chest X-ray images, reinforcing the data-intensive nature.
– “model”: Stores pre-trained models (rf.pkl, svc.pkl) as artifacts used by the Flask backend.
– “static”: Contains CSS files and the “uploads” folder for client-side assets.
– “templates”: Contains HTML files (like index, about, blog, contact, developer) that form the web dashboard.
– “main.Roshni.py”: Likely the main Flask application entrance point.

##### Architectural Patterns and Key Components
- Frontend/UI:
– Built using HTML templates in the “templates” folder.
– Static assets (CSS, images) are served from the “static” directory.
– Represents the user dashboard where symptom inputs are provided and recommendations are displayed.
- Backend/API:
– Implemented using Flask (as mentioned in the README).
– “main.Roshni.py” acts as the central controller: it receives user input, handles API routing, and interfaces with the ML models.
- Machine Learning Component:
– ML models are stored in the “model” folder (e.g., rf.pkl, svc.pkl) and are loaded during runtime.
– The code leverages various libraries (scikit-learn, pandas, numpy) to process user inputs, perform predictions, and then generate complete recommendations (including auto-spelling correction and synonym mapping).
- Data Management/Processing:
– Notebooks and CSV files found under “archive” and “dataset” suggest that data cleaning and analysis pipelines exist. Although these are used in the development/training phase, they are part of the overall lifecycle.
– Images and additional datasets (for chest X-rays) could also indicate support for image data pipelines if used for further diagnostic purposes.

## Diagram (Mermaid)

```mermaid
graph TD
    subgraph "Frontend UI"
        UI1["HTML Templates"]:::frontend
        UI2["Static Assets"]:::frontend
    end

    subgraph "Backend"
        API["Flask Application - main.Roshni.py"]:::backend
    end

    subgraph "Machine Learning Module"
        ML1["Pre-trained Models (rf.pkl, svc.pkl)"]:::ml
        ML2["HealthCareML_Code_Roshni.ipynb"]:::ml
        ML3["Intial_Analysis_Project_4 copy.ipynb"]:::ml
        ML4["data_description.ipynb"]:::ml
    end

    subgraph "Data Repository"
        DS1["Datasets (CSV, Images)"]:::data
        DS2["Archive (Historical Data)"]:::data
    end

    %% Data Flow: Frontend to Backend
    UI1 -->|"submits-input"| API
    UI2 -->|"loads-assets"| API

    %% Backend invoking ML module
    API -->|"invokes"| ML1
    API -->|"invokes"| ML2
    API -->|"invokes"| ML3
    API -->|"invokes"| ML4

    %% ML module retrieving data from repository
    ML1 -->|"retrieves-data"| DS1
    ML1 -->|"retrieves-data"| DS2
    ML2 -->|"retrieves-data"| DS1
    ML2 -->|"retrieves-data"| DS2
    ML3 -->|"retrieves-data"| DS1
    ML3 -->|"retrieves-data"| DS2
    ML4 -->|"retrieves-data"| DS1
    ML4 -->|"retrieves-data"| DS2

    %% ML module returning predictions to Backend
    ML1 -->|"returns-prediction"| API
    ML2 -->|"returns-prediction"| API
    ML3 -->|"returns-prediction"| API
    ML4 -->|"returns-prediction"| API

    %% Backend sending recommendations back to Frontend
    API -->|"sends-recommendations"| UI1
    API -->|"sends-recommendations"| UI2

    %% Click Events
    click UI1 "https://github.com/roshniranads27/a_flask-api_driven_machine_learning_model-personalized_medical_recommendation_system/tree/main//templates"
    click UI2 "https://github.com/roshniranads27/a_flask-api_driven_machine_learning_model-personalized_medical_recommendation_system/tree/main//static"
    click API "https://github.com/roshniranads27/a_flask-api_driven_machine_learning_model-personalized_medical_recommendation_system/blob/main//main.Roshni.py"
    click ML1 "https://github.com/roshniranads27/a_flask-api_driven_machine_learning_model-personalized_medical_recommendation_system/tree/main//model"
    click ML2 "https://github.com/roshniranads27/a_flask-api_driven_machine_learning_model-personalized_medical_recommendation_system/blob/main/HealthCareML_Code_Roshni.ipynb"
    click ML3 "https://github.com/roshniranads27/a_flask-api_driven_machine_learning_model-personalized_medical_recommendation_system/blob/main/Intial_Analysis_Project_4 copy.ipynb"
    click ML4 "https://github.com/roshniranads27/a_flask-api_driven_machine_learning_model-personalized_medical_recommendation_system/blob/main/data_description.ipynb"
    click DS1 "https://github.com/roshniranads27/a_flask-api_driven_machine_learning_model-personalized_medical_recommendation_system/tree/main//dataset"
    click DS2 "https://github.com/roshniranads27/a_flask-api_driven_machine_learning_model-personalized_medical_recommendation_system/tree/main//archive"

    %% Styles
    classDef frontend fill:#FFEEAD,stroke:#333,stroke-width:2px;
    classDef backend fill:#CEF6F5,stroke:#333,stroke-width:2px;
    classDef ml fill:#C3FDB8,stroke:#333,stroke-width:2px;
    classDef data fill:#F5CCD3,stroke:#333,stroke-width:2px;
```
