# harsh-p-shukla/phrs architecture

> Architecture diagram of the GitHub repository harsh-p-shukla/phrs, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-07-25). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/harsh-p-shukla/phrs
- Repository: https://github.com/harsh-p-shukla/phrs

## Overview

##### Project type and purpose
- This is a full-stack, Flask-based web application that serves as a Personalized Medical Recommendation System.
- It exposes a one-screen dashboard where users enter symptoms; the backend runs ML inference and returns predictions plus disease descriptions, precautions, diet plans, workout routines, and medications.

##### File structure
- Top level:
- main.Harsh.py – entry point for the Flask app
- model/ – pretrained pickled models (rf.pkl, svc.pkl)
- static/ – CSS (styles.css) and upload folder for user-submitted files
- templates/ – Jinja2 HTML templates (index, about, blog, contact, developer)
- dataset/ – source CSVs and chest X-ray image folders used during model training
- notebooks & archive/ – exploratory and historical data-science artifacts (not part of runtime)
- venv/ – isolated Python environment
- Patterns & clues:
- MVC style: templates as Views, main.Harsh.py routes as Controllers, data-loading & ML modules as Models
- No external database—data is read from CSVs at runtime
- Configuration files (.gitignore) and local environment (venv) imply simple file-system deployment

##### README for additional insights
- Confirms Flask API backend, use of scikit-learn, pandas, numpy, textblob for text correction, and pickle for model serialization
- Describes core features: synonym dictionary, auto-spelling correction, and ML predictions feeding comprehensive recommendations

## Diagram (Mermaid)

```mermaid
graph TB
    %% User Interface Layer
    subgraph "User Interface" 
        direction TB
        Browser["Web Browser"]:::frontend
        subgraph "Templates" 
            direction TB
            Index["index.html"]:::frontend
            About["about.html"]:::frontend
            Blog["blog.html"]:::frontend
            Contact["contact.html"]:::frontend
            Developer["developer.html"]:::frontend
        end
        subgraph "Static Assets"
            direction TB
            Styles["styles.css"]:::frontend
            Uploads["uploads/"]:::frontend
        end
    end

    %% Backend Application Server
    subgraph "Backend Server"
        direction TB
        FlaskApp["Flask App (main.Harsh.py)"]:::backend
        subgraph "Pre-processing Module"
            direction TB
            SpellCorrector["Spell Correction (TextBlob)"]:::backend
            SynonymMapper["Synonym Mapping"]:::backend
            Encoder["Input Encoding"]:::backend
        end
        subgraph "Inference Module"
            direction TB
            RFModel["rf.pkl"]:::storage
            SVCModel["svc.pkl"]:::storage
        end
        subgraph "Response Renderer"
            direction TB
            Renderer["Jinja2 Template Renderer"]:::backend
        end
    end

    %% Data Access Layer
    subgraph "Data Access Layer"
        direction TB
        CSV_Descriptions["description.csv"]:::storage
        CSV_Diets["diets.csv"]:::storage
        CSV_Medications["medications.csv"]:::storage
        CSV_Precautions["precautions_df.csv"]:::storage
        CSV_Workouts["workout_df.csv"]:::storage
        CSV_Severity["Symptom-severity.csv"]:::storage
        CSV_Training["Training.csv"]:::storage
    end

    %% Offline & Configuration
    subgraph "Offline Artifacts & Config"
        direction TB
        Archive["archive/"]:::config
        Notebook["data_description.ipynb"]:::config
        Gitignore[".gitignore"]:::config
        Venv["venv/"]:::config
        Readme["README.md"]:::config
    end

    %% Data Flows
    Browser -->|"POST /predict"| FlaskApp
    FlaskApp -->|"spell_correct(text)"| SpellCorrector
    SpellCorrector --> SynonymMapper
    SynonymMapper --> Encoder
    Encoder -->|"load_model() "| RFModel
    Encoder -->|"load_model() "| SVCModel
    RFModel -->|"predict() "| FlaskApp
    SVCModel -->|"predict() "| FlaskApp
    FlaskApp -->|"read_csv() "| CSV_Descriptions
    FlaskApp -->|"read_csv() "| CSV_Diets
    FlaskApp -->|"read_csv() "| CSV_Medications
    FlaskApp -->|"read_csv() "| CSV_Precautions
    FlaskApp -->|"read_csv() "| CSV_Workouts
    FlaskApp -->|"read_csv() "| CSV_Severity
    FlaskApp -->|"read_csv() "| CSV_Training
    FlaskApp -->|"render_template() "| Renderer
    Renderer --> Browser

    %% Click Events
    click Index "https://github.com/harsh-p-shukla/phrs/blob/master/templates/index.html"
    click About "https://github.com/harsh-p-shukla/phrs/blob/master/templates/about.html"
    click Blog "https://github.com/harsh-p-shukla/phrs/blob/master/templates/blog.html"
    click Contact "https://github.com/harsh-p-shukla/phrs/blob/master/templates/contact.html"
    click Developer "https://github.com/harsh-p-shukla/phrs/blob/master/templates/developer.html"
    click Styles "https://github.com/harsh-p-shukla/phrs/blob/master/static/styles.css"
    click Uploads "https://github.com/harsh-p-shukla/phrs/tree/master/static/uploads/"
    click FlaskApp "https://github.com/harsh-p-shukla/phrs/blob/master/main.Harsh.py"
    click RFModel "https://github.com/harsh-p-shukla/phrs/blob/master/model/rf.pkl"
    click SVCModel "https://github.com/harsh-p-shukla/phrs/blob/master/model/svc.pkl"
    click CSV_Descriptions "https://github.com/harsh-p-shukla/phrs/blob/master/dataset/description.csv"
    click CSV_Diets "https://github.com/harsh-p-shukla/phrs/blob/master/dataset/diets.csv"
    click CSV_Medications "https://github.com/harsh-p-shukla/phrs/blob/master/dataset/medications.csv"
    click CSV_Precautions "https://github.com/harsh-p-shukla/phrs/blob/master/dataset/precautions_df.csv"
    click CSV_Workouts "https://github.com/harsh-p-shukla/phrs/blob/master/dataset/workout_df.csv"
    click CSV_Severity "https://github.com/harsh-p-shukla/phrs/blob/master/dataset/Symptom-severity.csv"
    click CSV_Training "https://github.com/harsh-p-shukla/phrs/blob/master/dataset/Training.csv"
    click Archive "https://github.com/harsh-p-shukla/phrs/tree/master/archive/"
    click Notebook "https://github.com/harsh-p-shukla/phrs/blob/master/notebooks/data_description.ipynb"
    click Gitignore "https://github.com/harsh-p-shukla/phrs/blob/master/.gitignore"
    click Venv "https://github.com/harsh-p-shukla/phrs/tree/master/venv/"
    click Readme "https://github.com/harsh-p-shukla/phrs/blob/master/README.md"

    %% Styles
    classDef frontend fill:#D6EFFF,stroke:#0366D6,color:#0366D6;
    classDef backend fill:#E3FCEF,stroke:#00A361,color:#007F36;
    classDef storage fill:#E6FFED,stroke:#23BF08,color:#006622,stroke-dasharray: 5 5;
    classDef config fill:#FEEFB3,stroke:#D8A100,color:#8A5E00;
```
