Skip to content

About

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

ย 

History

18 Commits

Folders and files

Repository files navigation

๐Ÿฉบ Dr. Aria โ€” AI-Powered Healthcare Triage Assistant

Help patients reach the right care โ€” before they reach the waiting room.

A conversational medical-triage assistant that interviews a patient about their symptoms, asks adaptive clarifying questions, classifies urgency into five care tiers, and produces a structured, provider-ready clinical summary โ€” grounded in a real Retrieval-Augmented Generation (RAG) pipeline over an Indian clinical-guideline corpus.

๐Ÿ”— Live demo: https://dr-aria-glx5.onrender.com ย ยทย  (free-tier host โ€” the first load after idle may take ~30โ€“60s to wake)

โš ๏ธ Educational project only. Not a medical device and not a substitute for professional medical care. In a real emergency in India, call 108 (ambulance) or 112.


๐Ÿ“‹ The brief

Problem. Patients cannot self-triage accurately. A well-designed assistant can direct patients to the right care level โ€” emergency now ยท A&E today ยท GP urgent ยท GP routine ยท self-care โ€” reducing inappropriate utilisation and improving outcomes.

What we had to build: a conversational triage assistant โ€” symptom intake โ†’ adaptive clarifying questions โ†’ urgency assessment โ†’ care-pathway recommendation โ†’ a structured patient summary for the provider.

โœ… Core features required โ€” and where we implemented them

# Required feature How Dr. Aria delivers it Lives in
1 Symptom Intake Conversational collection of complaint, onset, duration, severity, associated symptoms & history โ€” with a structured data model (PATIENT_SUMMARY JSON) underneath the chat SYSTEM_PROMPT, ChatTab
2 Adaptive Questioning A four-phase interview โ€” Intake โ†’ Profiling โ†’ History โ†’ Assessment โ€” that picks the next-most-informative question from the current symptom profile PHASES, phase logic
3 Urgency Stratification Exactly the five required tiers: ๐Ÿ”ด EMERGENCY ยท ๐ŸŸ  HOSPITAL NOW (A&E today) ยท ๐ŸŸก DOCTOR URGENT ยท ๐ŸŸข CLINIC ROUTINE ยท ๐Ÿ”ต SELF-CARE URGENCY map
4 Care Pathway Guidance Every tier carries a specific action; each summary lists the recommended action, what to tell the provider, and red-flag symptoms to watch for URGENCY.action, summary fields
5 Patient Summary A structured, provider-ready card: presenting complaint, timeline, severity, associated symptoms, history, urgency, action, red flags, confidence & a reasoning trace โ€” with one-click Copy for Provider SummaryTab
6 Safety Guardrails Hard-coded emergency patterns (chest+arm/jaw pain, stroke FAST, thunderclap headache, breathing failure โ€ฆ) that override the assessment โ€” and fire client-side, before the LLM is even called emergencyPatterns

๐ŸŽฏ Success metrics

Success metric (from the brief) How we meet it
All emergency cases classified as emergency Two independent layers โ€” deterministic client-side patterns and an EMERGENCY tier in the model's own assessment
Adaptive questioning narrows to the most relevant questions Phase-aware prompting drives clinically-targeted follow-ups instead of a fixed script
Guardrails override the assessment for all emergency patterns Guardrails run before the API call and force the emergency banner regardless of model output โ€” they can't be "talked out of it"
Patient summary has all fields & is clinically coherent An enforced PATIENT_SUMMARY JSON schema with every required field + a reasoning trace
Differentiates similar complaints, different urgency e.g. chest pain radiating to the arm โ†’ ๐Ÿ”ด EMERGENCY vs musculoskeletal shoulder/arm pain โ†’ routine; thunderclap headache โ†’ emergency vs typical migraine โ†’ primary care

๐ŸŒถ๏ธ Beyond the brief โ€” what we added

The brief defined the baseline. These are the things we built on top of it.

1. Hyperlocalised to Bengaluru, India ๐Ÿ‡ฎ๐Ÿ‡ณ

The brief was region-neutral; we localised the entire experience for Bengaluru, Karnataka:

  • Indian emergency routing โ€” 108 (free ambulance; Arogya Kavacha in Karnataka) and 112 (national ERSS), never 999/911. Mental-health distress routes to Tele-MANAS 14416.
  • Indian care-pathway language โ€” hospital casualty, OPD โ€” instead of A&E / GP.
  • An Indian guideline corpus. All nine retrievable chunks are sourced from Indian bodies โ€” AIIMS (NELS, Neurology), ICMR, MoHFW / NVBDCP (dengue), the Indian Stroke Association, RGUHS, NMHP โ€” and referenced to real Bengaluru institutions: Sri Jayadeva Institute of Cardiovascular Sciences, NIMHANS, and the Indira Gandhi Institute of Child Health.
  • Locally-salient conditions a generic assistant would miss: dengue / chikungunya warning signs (Bengaluru's post-monsoon peaks) and snakebite envenomation โ€” added both as knowledge-base entries and as hard guardrails.

2. A real, full-stack RAG pipeline โ€” not a simulation

A vector database wasn't required; we built one. A Node/Express backend embeds the query with Gemini embeddings, runs a vector search in Qdrant, and injects the top guideline chunks into the prompt. If it runs with no backend or keys, it degrades gracefully to in-browser keyword retrieval over the same corpus, so the demo never breaks.

3. Advanced RAG โ€” query rewriting ยท HyDE ยท re-ranking

Before retrieval we rewrite the conversation into a clean clinical query and generate a HyDE (hypothetical document) to embed; after over-fetching 8 candidates we LLM-re-rank them and inject the top 3. Every step degrades safely to basic retrieval if a call fails.

4. LangGraph-style state machine

The triage flow is modelled as an explicit node/edge state machine with a conditional emergency branch.

5. Multi-agent / MCP orchestration

An orchestrator delegates to specialist sub-agents โ€” a Symptom agent, an Urgency agent, and a Summary agent โ€” each owning one stage of the pipeline.

6. Short- and long-term memory

Short-term: the live context window (with a token estimate shown in AI Internals). Long-term: every session is saved to localStorage and reopenable from a chat-history sidebar.

7. Production engineering

  • Deployed as a single Render web service that serves the built frontend and the API.
  • A GitHub Actions keep-alive workflow + health-check logging keep the free-tier service warm.
  • An offline "Load sample case" failsafe plus the client-side guardrails work with zero API calls โ€” a network or quota blip never leaves a reviewer staring at a blank screen.

๐Ÿง  Architecture

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  React + Vite SPA  โ€”  4 tabs: Chat ยท Summary ยท AI Internals ยท KB    โ”‚
โ”‚   โ€ข client-side safety guardrails fire BEFORE any API call          โ”‚
โ”‚   โ€ข localStorage memory + reopenable chat-history sidebar           โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                       โ”‚  POST /api/chat  { messages, system }
                       โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  Node + Express backend  (server/)                                 โ”‚
โ”‚    1. rewrite query + HyDE          โ”€โ”€ Gemini (auxiliary model)     โ”‚
โ”‚    2. embed                          โ”€โ”€ Gemini  gemini-embedding-001 โ”‚
โ”‚    3. vector search (over-fetch 8)   โ”€โ”€ Qdrant  (cosine)            โ”‚
โ”‚    4. LLM re-rank  โ†’ top 3                                          โ”‚
โ”‚    5. inject guidelines + generate   โ”€โ”€ Gemini  gemini-2.5-flash    โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                       โ–ผ
          { text, retrieved[], rag{} }  โ†’ Chat + Knowledge Base tabs

Keys stay server-side; the browser only ever talks to our /api.


๐ŸŽ“ GenAI syllabus concepts โ†’ where they live

Concept Implementation
System prompt ยท persona SYSTEM_PROMPT โ€” the Dr. Aria identity, rules & tiers
ChatML message format system / user / assistant roles sent to Gemini
Few-shot learning worked clinical examples embedded in the system prompt
Chain-of-thought a 5-step internal reasoning protocol โ†’ reasoning_trace
Structured JSON output the enforced PATIENT_SUMMARY schema
Adaptive AI agent four-phase questioning state machine
Safety guardrails client-side emergencyPatterns, independent of the LLM
RAG Gemini embeddings + Qdrant retrieval + prompt injection
Advanced RAG query-rewrite ยท HyDE ยท LLM re-ranking
LangGraph node/edge triage state machine + emergency branch
Multi-agent / MCP Symptom ยท Urgency ยท Summary sub-agents
Memory live context window + localStorage session history
Deployment single Render service (UI + API) + keep-alive workflow

๐Ÿ› ๏ธ Tech stack

Layer Choice
Frontend React 18 ยท Vite
Backend Node.js ยท Express
LLM & embeddings Google Gemini (gemini-2.5-flash, gemini-embedding-001) โ€” free AI Studio tier
Vector DB Qdrant (Cloud free tier or local Docker)
Hosting Render (one web service)
CI GitHub Actions (keep-alive ping)

๐Ÿš€ Setup & running

npm install
cp .env.example .env        # then fill in the values below

1. Gemini key โ€” free at https://aistudio.google.com/app/apikey โ†’ set GEMINI_API_KEY in .env.

2. Qdrant โ€” either:

  • Local: docker run -p 6333:6333 qdrant/qdrant (keep QDRANT_URL=http://localhost:6333), or
  • Cloud: create a free cluster at https://cloud.qdrant.io and set QDRANT_URL + QDRANT_API_KEY.

3. Ingest the guidelines into the vector store (one-time):

npm run ingest      # embeds each guideline chunk with Gemini โ†’ upserts to Qdrant

4. Run frontend + backend together:

npm run dev:all     # web on http://localhost:5173 ยท api on http://localhost:8787

(or run npm run dev and npm run server in two terminals). Health check: http://localhost:8787/api/health

Works with zero setup

Even with no key and no Qdrant, the app stays demoable: "Load a sample case" on the welcome screen populates every tab, and typing an emergency phrase (e.g. "chest pain spreading to my arm") still fires the red banner โ€” both are fully client-side.

npm run build       # production build โ†’ dist/

๐Ÿ—‚๏ธ Project structure

src/App.jsx                       # entire frontend: 4 tabs, state, parsing, UI
src/styles.css                    # editorial "marginalia" theme
shared/knowledge.js               # Indian guideline corpus (frontend demo + backend ingest)
server/index.js                   # Express API โ€” /api/chat (RAG) + /api/health (logged)
server/gemini.js                  # Gemini chat + embeddings + auxiliary JSON calls
server/qdrant.js                  # Qdrant vector store (REST)
server/ingest.js                  # one-time embed + upsert of the corpus
.github/workflows/keep-alive.yml  # pings /api/health to beat Render cold starts
render.yaml                       # one-service deploy (UI + API)

โ˜๏ธ Deployment (Render)

One Node web service hosts both the built frontend and the API โ€” Express serves dist/ (see render.yaml). On Render: connect the repo, set GEMINI_API_KEY, QDRANT_URL, QDRANT_API_KEY as environment variables, and run npm run ingest once against the production Qdrant. Build npm install && npm run build, start node server/index.js.

A keep-alive workflow pings /api/health every ~10 min so the free-tier service doesn't cold-start during a demo (the [health] log line confirms each ping in the Render logs).


๐Ÿ‘ฅ Team & version roadmap

Built collaboratively by five of us โ€” Manav, Lavanya, Deepesh, Arnav & Himanshu โ€” across 16 incremental versions (~3 each; see the commit history for authorship).

Version What shipped
V1 Basic triage chatbot โ€” system prompt + chat UI
V2 Prompt engineering โ€” persona, few-shot, chain-of-thought, JSON output, AI Internals tab
V3 Adaptive agent โ€” multi-phase clarifying questions
V4 RAG basics โ€” guideline knowledge base + keyword retrieval
V5 Advanced RAG โ€” query rewriting, HyDE, re-ranking
V6 LangGraph โ€” node/edge state machine with an emergency branch
V7 Memory โ€” short-term context window + long-term session history
V8 Safety guardrails + the Patient Summary card
V9 Multi-agent / MCP โ€” orchestrator + Symptom/Urgency/Summary sub-agents
V10 Deployment groundwork โ€” proxy, rate-limit/cache notes, CI
V11 Real RAG โ€” Gemini chat/embeddings + Qdrant vector store
V12 Chat sidebar, history & reload persistence
V13 Editorial UI โ€” marginalia theme, custom logo, typography
V14 Render deployment โ€” single service serves UI + API
V15 "New chat" always returns to the Triage tab
V16 Render keep-alive workflow + health-check logging

โš ๏ธ Disclaimer

Dr. Aria is a student project for educational purposes only. It is not a medical device, has not been clinically validated, and must not be used for real medical decisions. In a medical emergency in India, call 108 (ambulance) or 112, or go to the nearest hospital casualty.

About

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages