An end-to-end medical question-answering chatbot built using Retrieval-Augmented Generation (RAG). Users can ask medical-related questions and receive informed responses backed by a vectorized medical knowledge base.
This chatbot combines the reasoning ability of Large Language Models with the precision of vector-based document retrieval. It pulls relevant medical context from a Pinecone vector database and uses an LLM to generate accurate, grounded answers — all served through a clean Flask web interface.
- Python — Core programming language
- LangChain — Framework for chaining LLM calls and retrieval
- Flask — Lightweight web server for the chat interface
- Groq / OpenAI — Language model inference
- Pinecone — Vector database for semantic search
- Docker — Containerization
- AWS (ECR + EC2) — Cloud deployment
- GitHub Actions — CI/CD automation
Before getting started, make sure you have:
- Python 3.10 installed
- Anaconda or Miniconda
- A Pinecone account (free tier works fine)
- A Groq or OpenAI API key
- Git installed locally
git clone https://github.com/Aryan09092001/Medical-Chatbot.gitAfter moving into the project folder, create and activate a dedicated environment:
conda create -n medibot python=3.10 -yconda activate medibotpip install -r requirements.txtIn the root folder of the project, create a file named .env and add your API credentials:
PINECONE_API_KEY = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
OPENAI_API_KEY = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxx"💡 Tip: Never commit your
.envfile to GitHub. It's already excluded by.gitignore.
This script processes your medical documents and stores their embeddings in Pinecone:
python store_index.pypython app.pyNow open your browser and head to:
open up localhost:Your chatbot UI should be live and ready for questions. 🎉
The following walks through automating deployment using AWS services and GitHub Actions. Every time you push to main, the pipeline rebuilds your Docker image and refreshes the live deployment.
The CI/CD setup automates this flow:
- Builds a Docker image from your source code
- Pushes the image to AWS Elastic Container Registry (ECR)
- Pulls that image down onto your EC2 instance
- Starts the container so your app is live
Head over to aws.amazon.com and log into your account.
Provision a dedicated IAM user that GitHub Actions will use to interact with AWS.
Required service access:
- EC2 — Virtual machine where your app will run
- ECR — Elastic Container Registry to host your Docker image
Attach these IAM policies:
AmazonEC2ContainerRegistryFullAccessAmazonEC2FullAccess
This is where your Docker images will be stored. Once created, copy and save the repository URI — you'll need it for GitHub secrets.
Save the URI: 315865595366.dkr.ecr.us-east-1.amazonaws.com/medicalbot
Spin up a fresh Ubuntu EC2 instance. A t2.medium or larger is recommended given the size of the ML dependencies.
⚠️ Don't forget: Open port 3000 in your EC2 security group's inbound rules so users can reach your chatbot.
SSH into your EC2 and run these commands.
Optional — update system packages first:
sudo apt-get update -y
sudo apt-get upgradeRequired — install Docker:
curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh
sudo usermod -aG docker ubuntu
newgrp dockerThis lets GitHub Actions execute deployment steps directly on your EC2 box.
Navigate to:
Settings > Actions > Runners > New self-hosted runner
Pick your OS (Linux for Ubuntu EC2), then copy and run the commands GitHub provides one at a time on your EC2 instance.
Go to your repo → Settings → Secrets and variables → Actions → New repository secret.
Add the following secrets:
AWS_ACCESS_KEY_IDAWS_SECRET_ACCESS_KEYAWS_DEFAULT_REGIONECR_REPOPINECONE_API_KEYOPENAI_API_KEY
Once these are in place, push any change to main and watch the Actions tab — your pipeline should kick off automatically.
Medical-Chatbot/
├── .github/
│ └── workflows/
│ └── cicd.yaml # CI/CD pipeline definition
├── data/ # Source medical documents
├── research/ # Notebooks for experimentation
├── src/ # Helper modules
├── static/ # CSS / JS for frontend
├── templates/ # HTML templates
├── app.py # Flask application entry point
├── store_index.py # Pinecone indexing script
├── dockerfile # Container build instructions
├── requirements.txt # Python dependencies
└── README.md
Built by Aryan as part of an end-to-end ML deployment learning journey.
If this project helped you, consider giving it a ⭐ on GitHub!
