MedRec is an advanced, production-ready AI chatbot designed to provide instant, accurate, and reliable information about medicines. Built using a robust Retrieval-Augmented Generation (RAG) architecture, it leverages a massive dataset of medicine information, storing it in a high-performance vector database to deliver context-aware answers using Google's Gemini LLM.
⚠️ Disclaimer: MedRec is designed for informational and educational 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.
- 🧠 Advanced RAG Pipeline: Combines the reasoning power of Gemini 2.5 with a highly structured medical database to prevent hallucination and ensure accurate responses.
- ⚡ Serverless & Lightweight: Completely relies on cloud APIs (Hugging Face & Gemini) for ML operations, drastically reducing memory footprint and deployment costs.
- ☁️ Cloud Vector Storage: Uses Supabase
pgvectorfor lighting-fast semantic search across ~114,000+ medical data chunks. - 💬 Dual-Response System: Provides answers strictly from the verified medical knowledge base alongside a generalized AI response.
- 🔒 Secure User Sessions: Built with a Custom Django Authentication Model. Uses email-based login (no usernames) and securely saves chat histories in a PostgreSQL database.
- ⚙️ Dynamic Admin Control: Switch between LLM Providers (Gemini, OpenRouter, Groq) dynamically via the Django Admin panel using predefined dropdown choices.
- 🚀 Production Ready: Fully configured with
gunicorn,whitenoise, and deployment scripts for seamless hosting on platforms like Render or Railway.
- Backend Framework: Django 5.2
- LLM Orchestration: LlamaIndex
- Generative AI: Google Gemini (2.5 Flash / 2.5 Pro)
- Embedding Model: Hugging Face Inference API (
BAAI/bge-small-en-v1.5) - Vector Database: Supabase (
pgvectorviavecs) - Relational Database: Supabase PostgreSQL (via
dj-database-url)
MedRec/
├── accounts/ # Django app for user authentication
├── app/ # Main Django app handling chatbot and RAG logic
│ ├── static/ # CSS, JS, and local FAISS vector indices
│ └── views.py # Chatbot API endpoints and LLM fallback logic
├── data/ # Directory for storing raw medicine CSV datasets
├── MedRec/ # Django project settings and root configurations
├── templates/ # HTML templates (accounts and chatbot UI)
├── .env # Environment variables (API keys, DB URLs)
├── build.sh # Deployment build script for Render
├── manage.py # Django command-line utility
├── requirements.txt # Python dependencies
└── upload_to_supabase.py # One-time script for ingesting data to Supabase
Before you begin, ensure you have the following API keys and URLs ready:
- Google AI API Key (For Gemini LLM)
- Hugging Face Access Token (Fine-grained token with Inference API permissions)
- Supabase Database URL (PostgreSQL connection string with a valid password)
git clone https://github.com/ArkaKarmoker/MedRec.git
cd MedRecpython -m venv venv
source venv/bin/activate # On Windows use: .\venv\Scripts\activatepip install -r requirements.txtCreate a .env file in the root directory and add your credentials:
GEMINI_API_KEY=your_gemini_api_key_here
HF_TOKEN=your_huggingface_fine_grained_token_here
SUPABASE_DB_URL=postgresql://postgres.xxx:yourpassword@aws-xxx.pooler.supabase.com:5432/postgres
SECRET_KEY=your_django_secret_key_here
DEBUG=TrueSince Django is connected to Supabase PostgreSQL, this will create the necessary auth and session tables in the cloud.
python manage.py migratepython manage.py runserverVisit http://127.0.0.1:8000/ in your browser.
If you have a new CSV dataset of medicines and need to upload it to Supabase for the very first time:
- Place your CSV file in the
data/folder. - Update the file path in
upload_to_supabase.py. - Run the ingestion script (This will take some time depending on dataset size):
python upload_to_supabase.pyNote: This script generates embeddings locally via SentenceTransformers and saves them to both Supabase and a local FAISS index (as backup).
This project is fully optimized for free-tier deployments on Render.
- Create a New Web Service and connect this GitHub repository.
- Set the Build Command to:
./build.sh
- Set the Start Command to:
gunicorn MedRec.wsgi:application
- Add all environment variables from your
.envfile into Render's Environment Variables dashboard (SetDEBUGtoFalse). - Click Deploy.
© 2026 Arka Karmoker. All rights reserved.