Healthcare AI / RAG / Full Stack
Medical Chatbot
A retrieval-augmented medical chatbot built as a learning project. Rather than answering from whatever the model happens to remember, it retrieves passages from a curated set of medical articles and answers from those — with authentication and saved conversations around it.
This is an educational project built to practise retrieval-augmented generation. It is not a medical device, it does not provide diagnosis, and it is not a substitute for advice from a qualified clinician.
What it is.
The project was my way into RAG on a domain where being wrong matters. Medical text is a good stress test: the vocabulary is precise, and a plausible-sounding but unsourced answer is worse than no answer at all.
The knowledge base is a curated article set that is chunked and embedded ahead of time. At query time the chatbot retrieves the closest passages and answers strictly from them, so what it says can be traced back to a source.
02 — The problem
General-purpose chat models answer medical questions fluently whether or not they actually know the answer, and there is no way for the reader to see where a claim came from.
03 — The approach
Constrain the model to a fixed, curated corpus. Retrieve first, generate second, and keep the retrieved passage visible so the answer is checkable rather than taken on trust.
What it actually does.
Curated knowledge base
A fixed set of medical articles is pre-processed and embedded, so the retrieval scope is known and reviewable.
Retrieval-grounded answers
Every response is generated from retrieved passages rather than from unconstrained model memory.
Authenticated sessions
NextAuth handles sign-in so each user's conversations stay private to them.
Persistent conversations
Chat threads are stored in MongoDB and can be reopened and continued.
Scope guardrails
Questions outside the knowledge base return a clear 'not covered' response instead of an invented answer.
How the pieces fit together.
Next.js client
Chat interface and NextAuth-backed session management.
Flask service
Python service handling embedding, retrieval and the OpenAI call.
Knowledge base
Medical articles chunked and embedded ahead of time into a vector index.
MongoDB
Users and conversation history.
The stack.
Chosen for the problem, not for the resume.
- Next.jsReactNextAuth
- FlaskPythonREST APIs
- OpenAIRAGEmbeddings
- MongoDB
From input to output.
The sequence a single request travels through.
- 01
Curate
Source articles are selected and cleaned before anything is indexed.
- 02
Embed
Chunks are embedded once, ahead of time, so query latency stays low.
- 03
Retrieve
The question is embedded and matched against the index by semantic similarity.
- 04
Answer
The model is prompted to answer only from the retrieved passages, and to say so when they do not cover the question.
The part that stuck.
Student portfolio, so this section is the point — here is what this build actually taught me.
Saying 'I don't have that in my sources' is a feature. Getting the model to do that reliably took more prompt iteration than getting it to answer well.
Pre-computing embeddings for a fixed corpus is dramatically faster at query time than embedding on demand, and it makes the retrieval scope auditable.
Working in a domain with real-world consequences changed how I write disclaimers and scope limits — they belong in the product, not just the README.
AI-Powered Project Management System
A project and task manager where an admin can assign work and then just ask a chatbot who is doing what.
Have a project idea?
I'm open to freelance projects, collaborations, internships, and opportunities where I can contribute while continuing to grow.
Usually replies within a day · Lahore, Pakistan · PKT (UTC+5)