Skip to content

thisisAtharv/Vitality

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

12 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿงฌ Vitality โ€“ Personalized Health Intelligence Platform

๐Ÿ† Awarded "Best Project" - Sem 6 TEIT

Vitality is an intelligent healthcare system that uses machine learning to analyze blood biomarkers and predict potential metabolic health risks. The platform addresses the lack of personalized, clinical-data-driven healthcare by providing actionable diet and lifestyle recommendations.

It combines a React glassmorphism frontend, a Flask/MongoDB backend, an AI-driven OCR microservice, and a Multi-Output Random Forest Classifier to eliminate manual data entry and generate highly specific, downloadable health protocols.


โœจ Features

๐Ÿ” Secure Onboarding & State Management

  • Secure Access: Powered by Firebase Authentication (Google Sign-In).
  • Data Decoupling: Sensitive medical history and physical parameters are securely persisted in a cloud MongoDB Atlas database, completely decoupled from the authentication layer.

๐Ÿค– AI-Driven Clinical OCR

Vitality eliminates tedious manual entry using an asynchronous microservice pipeline:

  • n8n Workflows: Acts as the webhook receiver and PDF processor.
  • Groq LLM API: Performs strict JSON entity extraction to pull exact biomarkers (Fasting Glucose, HbA1c, Vitamin D, etc.) from messy, unstructured lab reports.
  • Instant Sync: The React UI instantly auto-fills sliders based on the AI extraction.

๐Ÿง  Intelligence Engine & Report Generation (Core)

  • Metabolic Risk Prediction: Powered by a custom Multi-Output Random Forest Classifier (model.pkl), the backend analyzes blood anomalies to predict specific metabolic risks.
  • Multi-Tag Classification: Simultaneously generates distinct, medically-aware Diet tags and Exercise tags tailored to the user's age, gender, and deficiencies.
  • Downloadable PDF Reports: Compiles the user's clinical data and predicted lifestyle protocols into a clean, exportable PDF document for personal tracking or doctor visits.

๐Ÿ›ก๏ธ User Control & Privacy

  • Live Notifications: Uses Python smtplib for real-time email alerts.
  • GDPR-Style Privacy: A strict one-click "Delete Data" protocol that permanently wipes a user's medical history from the database.

๐Ÿ› ๏ธ Technology Stack

Domain Tech Used Deployment
Frontend React.js (Vite), Tailwind CSS, Shadcn UI Vercel (Custom Domain)
Backend & ML Python, Flask, Scikit-learn, Pandas, smtplib Hugging Face Spaces (16GB RAM)
Database MongoDB Atlas MongoDB Cloud
Authentication Firebase Authentication (Google Sign-In) Firebase
AI / Microservice n8n (Automation), Groq API (Llama 3), Caddy Azure Linux VM (South Korea)

๐Ÿ—๏ธ System Architecture

  1. Frontend: React UI hosted on Vercel communicates with the Flask backend via REST APIs and handles live state.
  2. Auth: Firebase handles secure Google authentication and token management.
  3. AI Microservice: Self-hosted n8n running via Docker on an Azure VM processes uploaded pathology reports into structured JSON parameters using the Groq API.
  4. ML Backend: The Flask server hosted on Hugging Face Spaces feeds clinical parameters into the Random Forest model to classify personalized diet/exercise tags.
  5. Database: MongoDB Atlas securely stores user profiles, clinical parameters, and generated health plans in the cloud.

๐Ÿ“ธ Screenshots

๐Ÿ–ฅ๏ธ The Core UI & Input

Dashboard AI-OCR Input Wizard
Dashboard Clinical OCR

๐Ÿง  The ML Intelligence

Health Analysis Results Generated Diet & Workout PDF
Analysis Health Plan

๐Ÿ›ก๏ธ User Tracking & Control

History Log Settings & Privacy
History Settings

โš™๏ธ The Backend Architecture

n8n AI Extraction Workflow Firebase Auth Integration
n8n Workflow Firebase

๐Ÿ“ Project Structure

Vitality/
โ”œโ”€โ”€ backend/                       # Flask Backend & Machine Learning Services
โ”‚   โ”œโ”€โ”€ static/                    # Backend static storage (e.g., uploaded user avatars)
โ”‚   โ”œโ”€โ”€ app.py                     # Main Flask server, API endpoints, and email services
โ”‚   โ”œโ”€โ”€ classes.txt                # ML model labels and classification mapping
โ”‚   โ”œโ”€โ”€ model.pkl                  # Large ML predictive model (ignored from Git)
โ”‚   โ”œโ”€โ”€ requirements.txt           # Python dependencies (Flask, Pandas, etc.)
โ”‚   โ”œโ”€โ”€ test_email.py              # Sandbox script for testing SMTP notifications
โ”‚   โ”œโ”€โ”€ vitality.db                # SQLite user database (ignored from Git)
โ”‚   โ””โ”€โ”€ .env                       # Backend environment variables / API Keys (ignored)
โ”‚
โ”œโ”€โ”€ frontend/                      # React Frontend Application (Vite)
โ”‚   โ”œโ”€โ”€ public/                    # Public static assets
โ”‚   โ”œโ”€โ”€ src/                       # Frontend source code
โ”‚   โ”‚   โ”œโ”€โ”€ assets/                # Image illustrations and SVGs
โ”‚   โ”‚   โ”œโ”€โ”€ components/            # Reusable UI elements (InputWizard, Sidebar, etc.)
โ”‚   โ”‚   โ”œโ”€โ”€ components/ui/         # Shadcn/Radix UI base components
โ”‚   โ”‚   โ”œโ”€โ”€ contexts/              # Global React state (AuthContext, HealthDataContext)
โ”‚   โ”‚   โ”œโ”€โ”€ hooks/                 # Custom React hooks (e.g., use-toast, use-mobile)
โ”‚   โ”‚   โ”œโ”€โ”€ lib/                   # Utility functions
โ”‚   โ”‚   โ”œโ”€โ”€ pages/                 # Full application views (Dashboard, Profile, etc.)
โ”‚   โ”‚   โ”œโ”€โ”€ App.jsx                # Main application routing
โ”‚   โ”‚   โ”œโ”€โ”€ firebase.js            # Firebase Auth client configuration
โ”‚   โ”‚   โ”œโ”€โ”€ i18n.js                # Multi-language internationalization setup
โ”‚   โ”‚   โ”œโ”€โ”€ index.css              # Global styles, Tailwind config, and themes
โ”‚   โ”‚   โ””โ”€โ”€ main.jsx               # React DOM entry point
โ”‚   โ”‚
โ”‚   โ”œโ”€โ”€ .env                       # Frontend environment variables (ignored)
โ”‚   โ”œโ”€โ”€ eslint.config.js           # Linting configuration
โ”‚   โ”œโ”€โ”€ index.html                 # Main HTML template
โ”‚   โ”œโ”€โ”€ package.json               # Node.js dependencies and run scripts
โ”‚   โ””โ”€โ”€ vite.config.js             # Vite build and server configuration
โ”‚
โ”œโ”€โ”€ .gitignore                     # Centralized Git ignore rules for the platform
โ”œโ”€โ”€ LICENSE                        # Open-source license file
โ””โ”€โ”€ README.md                      # Project documentation and setup guide

๐Ÿš€ Getting Started

Prerequisites

  • Node.js (v18 or higher)
  • Python (3.9 or higher)
  • n8n installed globally (npm install -g n8n)
  • Firebase Project (for Auth credentials)
  • Groq API Key (for LLM extraction)

Installation

  1. Clone the Repository

    git clone https://github.com/thisisAtharv/Vitality.git
    cd Vitality
  2. Frontend Setup

    cd frontend
    npm install
  3. Backend Setup Note: The model.pkl Random Forest model must be generated locally or acquired, as it is ignored via Git.

    cd ../backend
    pip install -r requirements.txt
  4. Environment Setup This project uses separate credentials for the frontend and backend.

    Frontend Environment Variables (frontend/.env)

    VITE_FIREBASE_API_KEY=your_api_key
    VITE_FIREBASE_AUTH_DOMAIN=your_project_id.firebaseapp.com
    VITE_FIREBASE_PROJECT_ID=your_project_id
    VITE_FIREBASE_STORAGE_BUCKET=your_project_id.appspot.com
    VITE_FIREBASE_MESSAGING_SENDER_ID=your_sender_id
    VITE_FIREBASE_APP_ID=your_app_id

    Backend Environment Variables (backend/.env)

    MAIL_APP_PASSWORD=your_gmail_app_password
    SECRET_KEY=your_flask_secret_key
    GROQ_API_KEY=your_groq_api_key
  5. Run the Application (Requires 3 Terminals)

    Terminal 1: Frontend

    cd frontend
    npm run dev

    Terminal 2: Backend

    cd backend
    python app.py

    Terminal 3: AI Microservice (n8n)

    npx n8n

    Open http://localhost:5678, import your workflow, add your Groq API key to the HTTP node, and set the workflow to Active.


๐Ÿง  Learning Outcomes

  • Training and deploying a Multi-Output Random Forest Classifier for multi-tag prediction.
  • Architecting a decoupled microservice backend with Flask and n8n.
  • Integrating Large Language Models (Groq/Llama 3) for structured JSON data extraction.
  • Building complex, responsive React Glassmorphism UIs using Shadcn.

๐Ÿ”ฎ Roadmap & Enhancements

โœ… Completed Milestones

  • Cloud Database Migration: Successfully migrated from local SQLite to a distributed MongoDB Atlas cluster.
  • Production ML Engine: Deployed the heavy Random Forest classifier to a dedicated Hugging Face Space (16GB RAM tier).
  • Self-Hosted AI Microservice: Containerized n8n with Docker and deployed it on an Azure Linux VM to bypass API geo-blocks.
  • Automated SSL/HTTPS: Implemented Caddy Reverse Proxy for secure, auto-renewing certificates.

๐Ÿš€ Upcoming Features

  • ๐Ÿ“ฆ Cloud Storage: Migrate local avatar/image uploads to Firebase Storage or AWS S3.
  • ๐Ÿ“Š Advanced Analytics: Add longitudinal charting to track biomarkers over time.

๐Ÿ“ License

This project is licensed under the MIT License.

About

HealthTech platform using an AI-OCR microservice and Machine Learning to generate personalized health protocols from medical reports.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors