Skip to content

Repository files navigation

💊 MediCure - AI-Powered Healthcare Assistant

MediCure Banner

A comprehensive full-stack healthcare application powered by AI and Machine Learning

FastAPI React Python PyTorch License

FeaturesInstallationUsageAPIArchitecture


📋 Table of Contents


🌟 Overview

MediCure is an advanced AI-powered healthcare assistant that combines traditional medicine knowledge with cutting-edge machine learning technology. The application provides intelligent healthcare solutions through three main modules:

Key Capabilities

  • 🔍 Medicine Prediction System: Analyzes medicine names using fine-tuned BERT models

    • Common usage and indications (583 categories)
    • Possible side effects (1,271 categories)
    • Alternative substitutes (43,297 categories)
  • 🌿 Home Remedies Engine:

    • Database of 144+ traditional remedies
    • AI-powered remedy generation using Google Gemini
    • Yoga pose recommendations
    • Smart search with multiple matching strategies
  • 🤖 AI Doctor Chatbot:

    • Conversational health assistant powered by Google Gemini 2.0 Flash
    • Symptom analysis and disease predictions
    • Diet and workout recommendations
    • Precautionary measures

✨ Features

🏥 Medicine Analysis Module

  • Usage Prediction: Identify what a medicine is commonly used for
  • Side Effects Detection: Get comprehensive list of potential side effects
  • Substitute Finder: Discover alternative medicines
  • Fast Inference: Optimized BERT models for quick predictions
  • Real-time Results: Instant predictions without delays

🌿 Home Remedies Module

  • Database Search: Search through 144+ traditional remedies
  • AI Fallback: Generates 5 remedies when database doesn't have results
  • Yoga Integration: Links to recommended yoga poses
  • Bullet-Point Format: Easy-to-read numbered remedy instructions
  • Source Tracking: Visual indicators for database vs AI-generated content
  • Popular Searches: Quick access to common conditions

🤖 AI Chatbot Module

  • Natural Conversation: Chat naturally about health concerns
  • Symptom Analysis: AI analyzes symptoms and suggests possible conditions (max 2)
  • Holistic Advice: Diet plans, workouts, and precautions
  • Context Awareness: Maintains conversation history
  • Medical Disclaimer: Always reminds users to consult professionals
  • Real-time Responses: Powered by Google Gemini 2.0 Flash

🎨 User Experience

  • Responsive Design: Works on desktop, tablet, and mobile
  • Modern UI: Built with Tailwind CSS
  • Real-time Updates: Instant results and feedback
  • Loading States: Visual feedback during API calls
  • Error Handling: Graceful error messages

🛠️ Technology Stack

Backend

Technology Version Purpose
Python 3.8+ Core language
FastAPI 0.115.6 Web framework
Uvicorn 0.34.0 ASGI server
PyTorch 2.7.0 Deep learning
Transformers 4.52.3 BERT models
Google Gemini AI 0.8.5 Conversational AI
Pandas 2.2.3 Data processing
Joblib 1.5.1 Model serialization

Frontend

Technology Version Purpose
React 18.3.1 UI library
Vite 6.0.3 Build tool
Tailwind CSS 3.4.17 Styling
React Router 6.28.0 Routing
Axios 1.7.9 HTTP client
Lucide React 0.263.1 Icons

Machine Learning

  • BERT Base Uncased: Pre-trained transformer model
  • Fine-tuned Models: Custom training for medical domain
    • Medicine Usage: 583 labels
    • Side Effects: 1,271 labels
    • Substitutes: 43,297 labels
  • Label Encoders: For classification decoding

📁 Project Structure

medicure-fullstack/
│
├── 📂 backend/                              # FastAPI Backend
│   ├── main.py                              # Main application (400+ lines)
│   ├── requirements.txt                     # Python dependencies
│   ├── .env                                 # Environment variables (gitignored)
│   ├── .env.example                         # Environment template
│   ├── .gitignore                           # Git ignore rules
│   │
│   ├── 🧠 ML Models (150MB+)
│   ├── bert_finetuned_model_prediction.pkl  # Medicine usage model
│   ├── bert_finetuned_model_sideffects.pkl  # Side effects model
│   ├── bert_finetuned_model_substitute.pkl  # Substitutes model
│   ├── label_encoder_prediction.pkl         # Usage labels encoder
│   ├── label_encoder_sideeffects.pkl        # Side effects labels
│   ├── label_encoder_substitute.pkl         # Substitute labels
│   │
│   ├── 📊 Data
│   ├── Home Remedies.csv                    # 144 traditional remedies
│   │
│   └── venv/                                # Virtual environment
│
├── 📂 frontend/                             # React Frontend
│   ├── 📂 public/
│   │   └── vite.svg                         # Favicon
│   │
│   ├── 📂 src/
│   │   ├── 📂 components/
│   │   │   └── Layout.jsx                   # Navigation & layout
│   │   │
│   │   ├── 📂 pages/
│   │   │   ├── Home.jsx                     # Landing page
│   │   │   ├── MedicinePrediction.jsx       # Medicine analysis
│   │   │   ├── HomeRemedies.jsx             # Remedies search
│   │   │   └── Chatbot.jsx                  # AI doctor chat
│   │   │
│   │   ├── 📂 services/
│   │   │   └── api.js                       # Axios API client
│   │   │
│   │   ├── App.jsx                          # Main app component
│   │   ├── main.jsx                         # Entry point
│   │   └── index.css                        # Global styles + Tailwind
│   │
│   ├── index.html                           # HTML template
│   ├── package.json                         # Dependencies
│   ├── vite.config.js                       # Vite config
│   ├── tailwind.config.js                   # Tailwind config
│   ├── postcss.config.js                    # PostCSS config
│   ├── .env.example                         # Environment template
│   ├── .gitignore
│   └── node_modules/                        # Dependencies
│
├── 📂 Documentation
├── README.md                                # Main documentation
├── API_DOCUMENTATION.md                     # API reference
├── DEPLOYMENT.md                            # Deployment guide
├── PROJECT_STRUCTURE.md                     # Detailed structure
├── QUICK_REFERENCE.md                       # Quick commands
└── COPY_FILES_INSTRUCTIONS.md               # Setup instructions
│
└── 📂 Scripts
    ├── setup.bat                            # Windows setup
    ├── setup.sh                             # Linux/Mac setup
    └── start.bat                            # Windows launcher

🚀 Installation

🧰 Prerequisites

Make sure you have the following installed before running the project:

Quick Setup

Windows

git clone https://github.com/yourusername/medicure-fullstack.git
cd medicure-fullstack
setup.bat

Linux/Mac

git clone https://github.com/yourusername/medicure-fullstack.git
cd medicure-fullstack
chmod +x setup.sh
./setup.sh

Manual Installation

Backend Setup

cd backend
python -m venv venv
venv\Scripts\activate  # Windows
source venv/bin/activate  # Linux/Mac
pip install -r requirements.txt

Copy Model Files

Copy these 7 files to backend/:

  • bert_finetuned_model_prediction.pkl
  • bert_finetuned_model_sideffects.pkl
  • bert_finetuned_model_substitute.pkl
  • label_encoder_prediction.pkl
  • label_encoder_sideeffects.pkl
  • label_encoder_substitute.pkl
  • Home Remedies.csv

Frontend Setup

cd frontend
npm install

⚙️ Configuration

Backend (.env)

GEMINI_API_KEY=your_gemini_api_key_here
PORT=8000

Frontend (.env)

VITE_API_URL=http://localhost:8000

🎯 Usage

Starting the Application

Manual Start

# Terminal 1 - Backend
cd backend
venv\Scripts\activate
python main.py

# Terminal 2 - Frontend
cd frontend
npm run dev

Access Points



🤖 Chatbot Architecture

Flow Diagram

User Input
    ↓
Frontend (React)
    ↓
API Call (POST /api/chat)
    ↓
Backend (FastAPI)
    ↓
Add Medical Context
    ↓
Google Gemini AI
    ↓
Generate Response
    ↓
Return to Frontend
    ↓
Display to User

🧠 Model Architecture

BERT Models

Medicine Usage Prediction

  • Input: Medicine name
  • Output: Usage category (583 classes)
  • Architecture: BERT Base + Classification Head

Side Effects Prediction

  • Input: Medicine name
  • Output: Side effects list (1,271 classes)

Substitutes Prediction

  • Input: Medicine name
  • Output: Alternative medicines (43,297 classes)

⚠️ Disclaimer

IMPORTANT MEDICAL DISCLAIMER

This application is for informational and educational purposes only.

Key Points:

  1. Not Medical Professional: This is an AI tool, not a licensed doctor
  2. No Medical Advice: Information provided is not medical advice
  3. Consult Healthcare Professionals: Always seek professional medical advice
  4. Emergency Situations: Call emergency services for urgent medical issues
  5. AI Limitations: Predictions may not be accurate or complete
  6. Use at Your Own Risk: Developers assume no liability

When to Seek Immediate Medical Help:

  • Severe symptoms
  • Chest pain or difficulty breathing
  • Persistent high fever
  • Signs of stroke or heart attack
  • Any life-threatening emergency

Call 911 or your local emergency number immediately for emergencies.


👥 Author

Built with ❤️ by

Kumar Abhishek

Kumar Abhishek

ML Engineer & Full Stack Developer

🎓 BTech ECE @ IIIT Una

💡 Specializing in AI/ML, GenAI, and Web Development

Email LinkedIn GitHub


📞 Contact & Support


🔄 Version History

v1.0.0 (Current)

  • ✅ Medicine prediction with BERT
  • ✅ Home remedies with AI fallback
  • ✅ AI doctor chatbot
  • ✅ Responsive UI

Planned (v1.1.0)

  • 🔜 User authentication
  • 🔜 Save chat history
  • 🔜 Medicine interaction checker
  • 🔜 Multi-language support

Made with ❤️ for better healthcare accessibility

⭐ Star this repo if you find it helpful!

⬆ Back to Top

About

MediCure - Your AI health assistant for medicine predictions, side effects analysis, substitute recommendations, and symptom consultations.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages