Skip to content

PRITAM-TU/AI-Health-Tracker-Disease-Predictor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

1 Commit
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ₯ AI Health Tracker & Disease Predictor

A comprehensive web application that uses Machine Learning to predict potential health risks and diseases based on user symptoms and vital statistics. The app provides early warning signs and helps users make informed decisions about consulting healthcare professionals.

Health Tracker React Node.js Python

πŸ“‹ Table of Contents

✨ Features

🎯 Core Functionality

  • AI-Powered Health Predictions: Machine Learning models for disease risk assessment
  • Symptom Analysis: Multi-symptom input with intelligent risk calculation
  • Real-time Risk Assessment: Instant health risk evaluation with confidence scores
  • Health History Tracking: Complete record of all predictions and assessments
  • Interactive Analytics: Visual charts and insights into health trends

🎨 User Experience

  • Modern Responsive UI: Clean, professional medical interface
  • Interactive Dashboard: Overview of health statistics and recent activities
  • Risk Visualization: Color-coded risk meters and progress indicators
  • Data Export: CSV export functionality for health records
  • Mobile-Friendly: Fully responsive design for all devices

πŸ”§ Technical Features

  • RESTful API Architecture: Scalable backend services
  • Real-time Data Processing: Immediate prediction results
  • Secure Data Storage: MongoDB database with proper data modeling
  • Modular ML Service: Separate Python service for machine learning
  • Error Handling: Comprehensive error management and user feedback

πŸ›  Technology Stack

Frontend

Technology Version Purpose
React 18.2.0 UI Framework
Vite 5.0.0 Build Tool & Dev Server
Tailwind CSS 3.3.6 Utility-first CSS Framework
React Router DOM 6.8.0 Client-side Routing
Axios 1.6.0 HTTP Client for API calls
Recharts 2.8.0 Data Visualization Charts
Lucide React 0.294.0 Icon Library

Backend

Technology Version Purpose
Node.js 18+ JavaScript Runtime
Express.js 4.18.2 Web Framework
MongoDB 6.0+ NoSQL Database
Mongoose 8.0.0 MongoDB ODM
CORS 2.8.5 Cross-Origin Resource Sharing
Helmet 7.1.0 Security Middleware
Express Rate Limit 7.1.0 API Rate Limiting

Machine Learning Service

Technology Version Purpose
Python 3.8+ ML Service Runtime
Flask 2.3.3 Python Web Framework
Pandas 2.1.0 Data Manipulation
Scikit-learn 1.3.0 Machine Learning Library
NumPy 1.24.0 Numerical Computing
Joblib 1.3.0 Model Serialization

πŸ“ Project Structure

health-tracker/
β”œβ”€β”€ client/                 # React Frontend
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ components/     # Reusable UI Components
β”‚   β”‚   β”œβ”€β”€ pages/          # Page Components
β”‚   β”‚   β”œβ”€β”€ context/        # React Context for State Management
β”‚   β”‚   β”œβ”€β”€ services/       # API Service Functions
β”‚   β”‚   └── assets/         # Static Assets
β”‚   β”œβ”€β”€ package.json
β”‚   └── vite.config.js
β”œβ”€β”€ server/                 # Node.js Backend
β”‚   β”œβ”€β”€ models/             # MongoDB Data Models
β”‚   β”œβ”€β”€ routes/             # API Route Handlers
β”‚   β”œβ”€β”€ middleware/         # Custom Middleware
β”‚   β”œβ”€β”€ server.js           # Express Server Entry Point
β”‚   └── package.json
β”œβ”€β”€ ml-service/             # Python ML Service
β”‚   β”œβ”€β”€ app.py              # Flask Application
β”‚   β”œβ”€β”€ requirements.txt    # Python Dependencies
β”‚   └── models/             # Trained ML Models
└── README.md

πŸš€ Installation Guide

Prerequisites

Before you begin, ensure you have the following installed on your system:

  • Node.js (v18 or higher)
  • Python (v3.8 or higher)
  • MongoDB (v6.0 or higher)
  • npm or yarn package manager

Step 1: Clone the Repository

git clone https://github.com/your-username/health-tracker.git
cd health-tracker

Step 2: Setup the Backend Server

# Navigate to server directory
cd server

# Install dependencies
npm install

# Create environment file
echo "MONGODB_URI=mongodb://localhost:27017/health-tracker" > .env
echo "ML_SERVICE_URL=http://localhost:8000" >> .env
echo "PORT=5000" >> .env
echo "NODE_ENV=development" >> .env

# Start the server (development mode)
npm run dev

# Or start in production mode
npm start

Step 3: Setup the ML Service

# Open a new terminal and navigate to ml-service
cd ml-service

# Create virtual environment (recommended)
python -m venv venv

# Activate virtual environment
# On Windows:
venv\Scripts\activate
# On macOS/Linux:
source venv/bin/activate

# Install Python dependencies
pip install -r requirements.txt

# Start the ML service
python app.py

Step 4: Setup the Frontend Client

# Open a new terminal and navigate to client
cd client

# Install dependencies
npm install

# Start the development server
npm run dev

Step 5: Start MongoDB

# Using Docker (recommended)
docker run -d -p 27017:27017 --name mongodb mongo:latest

# Or using locally installed MongoDB
mongod --dbpath /path/to/your/database

Step 6: Verify Installation

Open your browser and navigate to:

🎯 Quick Start (Docker Method)

Using Docker Compose (Recommended)

# Clone the repository
git clone https://github.com/your-username/health-tracker.git
cd health-tracker

# Start all services with Docker Compose
docker-compose up -d

# Check running services
docker-compose ps

# View logs
docker-compose logs -f

Docker Compose File

version: '3.8'
services:
  mongodb:
    image: mongo:latest
    ports:
      - "27017:27017"
    volumes:
      - mongodb_data:/data/db

  ml-service:
    build: ./ml-service
    ports:
      - "8000:8000"
    environment:
      - FLASK_ENV=production

  server:
    build: ./server
    ports:
      - "5000:5000"
    environment:
      - MONGODB_URI=mongodb://mongodb:27017/health-tracker
      - ML_SERVICE_URL=http://ml-service:8000
    depends_on:
      - mongodb
      - ml-service

  client:
    build: ./client
    ports:
      - "3000:3000"
    depends_on:
      - server

volumes:
  mongodb_data:

πŸ“Š API Endpoints

Health Prediction Endpoints

Method Endpoint Description Request Body
POST /api/predict Make health prediction Health data JSON
GET /api/predictions Get prediction history -
GET /api/stats Get analytics statistics -
DELETE /api/predictions/:id Delete a prediction -

Example API Usage

// Make a prediction
const healthData = {
  age: 45,
  gender: "male",
  bloodPressure: 145,
  cholesterol: 240,
  heartRate: 92,
  glucose: 130,
  bmi: 28.5,
  symptoms: ["Fatigue", "Chest Pain"]
};

const response = await fetch('/api/predict', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify(healthData)
});

const prediction = await response.json();
console.log(prediction);

πŸ€– ML Model Details

Prediction Algorithm

The application uses a rule-based risk assessment system that can be enhanced with trained ML models:

# Current Risk Calculation (Rule-based)
risk_score = 0

# Age factor
if age > 50: risk_score += 0.3
elif age > 30: risk_score += 0.1

# Blood pressure factor  
if bp > 140: risk_score += 0.3
elif bp > 120: risk_score += 0.1

# Cholesterol factor
if cholesterol > 240: risk_score += 0.3
elif cholesterol > 200: risk_score += 0.1

# Glucose factor
if glucose > 126: risk_score += 0.3
elif glucose > 100: risk_score += 0.1

Future ML Enhancements

  • Random Forest Classifier for disease prediction
  • Logistic Regression for probability scores
  • Neural Networks for complex pattern recognition
  • Integration with Kaggle health datasets

πŸ“Έ Screenshots

Dashboard

![Dashboard]alt text

Health Assessment Form

![Health Form]alt text

Analytics

![Analytics]alt text

πŸ›  Development

Adding New Features

  1. Frontend Components:
cd client/src/components
# Create new component files
  1. Backend Routes:
cd server/routes
# Add new API endpoints
  1. ML Models:
cd ml-service
# Add new prediction algorithms

Running Tests

# Frontend tests
cd client
npm test

# Backend tests  
cd server
npm test

# ML service tests
cd ml-service
python -m pytest

Building for Production

# Build frontend
cd client
npm run build

# Build backend (if using TypeScript)
cd server
npm run build

# The build files will be in dist/ folders

🀝 Contributing

We welcome contributions! Please see our Contributing Guide for details.

Development Workflow

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Code Style

  • Frontend: ESLint + Prettier configuration
  • Backend: Standard JavaScript style
  • Python: PEP 8 compliance
  • Commit Messages: Conventional commits format

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

⚠️ Important Disclaimer

This application is for educational and informational purposes only. It is not a substitute for professional medical advice, diagnosis, or treatment. Always seek the advice of your physician or other qualified health provider with any questions you may have regarding a medical condition.

πŸ†˜ Support

If you encounter any issues or have questions:

  1. Check the Troubleshooting Guide
  2. Search existing GitHub Issues
  3. Create a new issue with detailed information

πŸ“ž Contact


Made with ❀️ for better health awareness

If you find this project helpful, please give it a ⭐ on GitHub!

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors