“Build a role-based medical chatbot using FastAPI, Groq LLaMA 3, Pinecone, and MongoDB Atlas. Features document-grounded RAG with strict RBAC for Doctors, Nurses, and Patients.”
Medical data requires strict privacy boundaries and grounded accuracy. A single generic chatbot cannot safely serve both a surgeon reviewing clinical reports and a patient checking basic health guidelines.
This project implements a full-stack, role-aware medical assistant that combines Retrieval-Augmented Generation (RAG) with Role-Based Access Control (RBAC).
The architecture enforces permission checks at every stage, from document ingestion to vector retrieval:
Authentication & RBAC: MongoDB Atlas and Bcrypt manage user persistence and role definitions (Admin, Doctor, Nurse, Patient, and Others).
Document Ingestion (Admin Only): Administrators upload clinical PDFs, which are chunked, embedded via Google AI Embeddings, and indexed in Pinecone with role-level metadata.
Role-Filtered Retrieval: When a query is made, Pinecone filters chunks based on the user's role before returning context.
Low-Latency Generation: Retrieved context is passed to Groq (LLaMA 3) to produce grounded, sub-second responses.
Frontend: A Streamlit dashboard dynamically renders views according to authenticated privileges.
Layer | Technology | Function |
Backend API | FastAPI | Modular REST routing and dependency injection |
LLM Inference | Groq (LLaMA 3) | Sub-second generative response synthesis |
Vector Database | Pinecone | Metadata-filtered semantic retrieval |
Embeddings | Google AI Embeddings | Document and query vectorization |
User Store & Auth | MongoDB Atlas + Bcrypt | User state, credentials, and RBAC policies |
User Interface | Streamlit | Dynamic, role-aware interactive client |
By applying metadata filters during vector search and securing endpoints with FastAPI dependencies, the system prevents unauthorized data access and keeps LLM responses strictly grounded in verified medical records.
Ask questions, discuss architecture, and share insights with other developers.
Sign in to join the discussion and share your thoughts with other developers.
Sign In to Comment