This repository contains the complete source code submitted alongside the written dissertation:
An agentic AI-powered medical assistant built with LangGraph, Retrieval-Augmented Generation and real-time tool-calling for healthcare professionals.
MedAssist is a full-stack intelligent medical assistant that allows healthcare professionals to interact with pharmaceutical knowledge through natural language. Instead of searching through textbooks or databases, a clinician can simply ask:
"Can my patient take Azithromycin alongside Atorvastatin?" "What are the contraindications of Amlodipine in elderly patients?" "Generate a dosage card for Sofia Loukisa."
The system understands the intent, queries the right tools, retrieves grounded information from real pharmaceutical PDFs and delivers a structured, cited response β all in real time.
| Feature | Description |
|---|---|
| π¬ Conversational Interface | Natural language chat with real-time token streaming |
| π RAG-Powered Queries | Answers grounded in uploaded pharmaceutical PDFs, not AI hallucination |
| Severity-rated DDI checking (mild / moderate / severe / contraindicated) | |
| π Dosage Card Generation | Auto-generated structured medication cards per patient |
| π€ Patient Management | Full CRUD for patients, medications, allergies, and medical history |
| π§ Agentic Tool-Calling | ReAct loop with 10 specialised tools, visible in real time |
| π Bookmarks | Save any critical AI response for later reference |
| π Secure Auth | JWT authentication with bcrypt-hashed passwords |
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β React 18 Frontend β
β (TypeScript Β· Tailwind CSS Β· Vite) β
β Chat UI Β· Patient Dashboard Β· PDF Manager Β· Cards β
ββββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββ
β REST + SSE Streaming
ββββββββββββββββββββββββββΌβββββββββββββββββββββββββββββββββ
β Express Backend (Node.js) β
β JWT Auth Β· Chat Service Β· CRUD β
β β
β βββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β LangGraph Agent β β
β β β β
β β ββββββββββββ βββββββββββββββββββββββββ β β
β β β Router βββββΆβ toolAgent β β β
β β β (Intent β β (ReAct Loop Γ 5) β β β
β β βClassify) β β 10 LangChain Tools β β β
β β ββββββββββββ βββββββββββββββββββββββββ β β
β βββββββββββββββββββββββββββββββββββββββββββββββββββ β
ββββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββ
β Drizzle ORM
ββββββββββββββββββββββββββΌβββββββββββββββββββββββββββββββββ
β PostgreSQL 16 + pgvector β
β Relational Data Vector Store (HNSW index) β
β Users Β· Patients Β· 768-dim Embeddings β
β Medications Β· Chat Cosine Similarity Search β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β
ββββββββββββΌβββββββββββ
β Google Gemini API β
β Flash (LLM) + β
β Embedding-001 (RAG)β
βββββββββββββββββββββββ
Every message is first passed through a structured-output Gemini classifier that deterministically routes it to one of five intent categories:
rag_query β search pharmaceutical PDFs
interaction_check β check drug-drug interactions
card_generation β generate patient dosage card
patient_management β CRUD on patient records
general β open conversation
The agent executes a Reason β Act β Observe loop powered by LangGraph's StateGraph:
User Message
β
[THINK] "I need to check the interaction between these two drugs"
β
[ACT] calls check_interactions("Atorvastatin", "Azithromycin")
β
[OBSERVE] receives DDI data from pgvector RAG retrieval
β
[THINK] "I now have enough context to answer"
β
[RESPOND] streams severity-rated response to user
PDF Upload
β
pdf-parse (text extraction)
β
RecursiveCharacterTextSplitter (chunk: 1000 / overlap: 200)
β
gemini-embedding-001 (768-dimensional vectors)
β
pgvector HNSW index (cosine similarity)
β
Top-5 semantically similar chunks β injected as LLM context
| Layer | Technology | Purpose |
|---|---|---|
| Frontend | React 18, TypeScript, Vite, Tailwind CSS | SPA with real-time streaming UI |
| Backend | Hono, Node.js 20 LTS, TypeScript | Lightweight REST API server |
| AI Orchestration | LangGraph 0.2, LangChain 0.3 | Stateful agentic graph execution |
| LLM | Google Gemini Flash | Natural language generation + tool-calling |
| Embeddings | Google Gemini Embedding-001 | 768-dim semantic text vectors |
| Vector Store | PostgreSQL + pgvector (HNSW) | Sub-100ms approximate nearest-neighbour search |
| ORM | Drizzle ORM | Type-safe SQL with zero code generation |
| Auth | JWT + bcrypt | Stateless sessions, hashed passwords |
| PDF Parsing | pdf-parse | Text extraction from pharmaceutical documents |
| Streaming | Server-Sent Events (SSE) | Real-time token-by-token response delivery |
| Infrastructure | Docker Compose | One-command database provisioning |
The system was evaluated across 30 novel test queries spanning all intent categories:
| Metric | Result |
|---|---|
| π― Intent Classification Accuracy | 100% (30/30 queries) |
| π RAG Retrieval Quality Score | 100% (60/60 weighted points) |
| π Dosage Card Consistency | 100% (5/5 fully BNF-consistent) |
| β Unit Tests Passing | 15/15 |
| β Integration Tests Passing | 7/7 |
- Node.js 20 LTS
- pnpm (
npm install -g pnpm) - Docker Desktop
- Google API Key (Gemini)
# 1. Clone the repository
git clone https://github.com/SofiaLoukisa/medassist-langgraph-agentic-ai-dissertation.git
cd medassist-langgraph-agentic-ai-dissertation
# 2. Start the database
docker-compose up -d
# 3. Install all dependencies
pnpm install
# 4. Configure environment
cp backend/.env.example backend/.env
# Fill in: DATABASE_URL, GOOGLE_API_KEY, JWT_SECRET
# 5. Run migrations
cd backend && pnpm drizzle-kit migrate
# 6. Start backend (port 3000)
cd backend && pnpm dev
# 7. Start frontend (port 5173)
cd frontend && pnpm devOpen http://localhost:5173, register an account, upload pharmaceutical PDFs and start chatting.
DATABASE_URL=postgresql://medassist:medassist_dev@localhost:5432/medassist
GOOGLE_API_KEY=your_google_api_key_here
JWT_SECRET=your_secure_random_secret_heremedassist/
βββ assets/ # Screenshots for README
βββ frontend/ # React SPA
β βββ src/
β βββ pages/ # Route-level components
β βββ components/ # Reusable UI components
β
βββ backend/ # Hono API server
βββ src/
βββ agent/ # LangGraph agent
β βββ graph.ts # StateGraph definition
β βββ state.ts # AgentState schema
β βββ nodes/ # router + toolAgent
β βββ tools/ # 10 LangChain tools
βββ db/ # Drizzle schema + migrations
βββ auth/ # JWT authentication
βββ chat/ # Chat service + SSE streaming
βββ patient/ # Patient CRUD
βββ pdf/ # PDF ingestion pipeline
βββ medicine/ # Dosage card generation
- Institution: University of York Europe Campus, Athens Tech
- Degree: BSc Computer Science with Honours
- Module: Individual Project Dissertation
- Supervisor: Dr. Odysseas Efremidis
- Academic Year: 2025β2026
- RQ1: How effectively can a graph-based agentic architecture produce clinically appropriate pharmaceutical responses?
- RQ2: How does RAG over user-uploaded documents reduce hallucination compared to ungrounded LLM responses?
- RQ3: What architectural and safety constraints must be satisfied before clinical deployment?
MedAssist is a research prototype developed for academic purposes. It is not intended for real clinical use without independent validation, regulatory compliance review and integration with authoritative pharmaceutical databases.
Sofia Loukisa
Student ID: CSY23106
Stage: 3












