DEV Community

Roshni Mishra
Roshni Mishra

Posted on Originally published at caregraph-ai.vercel.app

Building CareGraph AI: Autonomous Multilingual Voice & Knowledge Graph Healthcare Triage with FalkorDB

Building CareGraph AI: Autonomous Multilingual Voice & Knowledge Graph Healthcare Triage with FalkorDB

Can a graph database save lives during medical emergencies? Here is how we replaced hallucinating LLMs with a 0.31ms 5-hop FalkorDB traversal to connect voice symptoms directly to verified ICU beds and doctors across India.


๐Ÿšจ The Emergency Triage Crisis in India

In acute medical crises โ€” myocardial infarctions (heart attacks), hypoxic pneumonia, acute stroke โ€” every second counts. In India, emergency medical triage currently suffers from two fatal bottlenecks:

  1. Passive, Hallucinating Chatbots: Traditional LLM chatbots guess medical advice probabilistically. In an emergency, a hallucinated drug recommendation or delayed triage is catastrophic.
  2. Disconnected Hospital Resources: A patient or paramedic spends precious minutes making frantic phone calls to check which hospital has an ICU oxygen bed and an attending specialist on duty.

We asked: What if an autonomous voice assistant could listen to patient symptoms in pure Hindi or English, and instantly traverse a deterministic clinical knowledge graph to identify life-threatening conditions, check drug contraindications, allocate live ICU beds, and auto-dispatch ambulance CAD alerts in under a second?

Enter CareGraph AI.


๐Ÿ—๏ธ System Architecture

CareGraph AI unites FalkorDB, LiveKit WebRTC, Murf Falcon TTS, and Twilio PSTN into a closed-loop emergency triage system:

Patient Speaks (Hindi/English)
          โ”‚
          โ–ผ
Live Voice Intake (Deepgram Nova-2 + Murf Falcon <250ms)
          โ”‚  writes session + detected symptoms live
          โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚            FalkorDB Graph Memory Engine                โ”‚
โ”‚                                                        โ”‚
โ”‚  (:Patient)-[:HAD_SESSION]->(:AgentSession)            โ”‚
โ”‚  (:Patient)-[:EXHIBITS]->(:Symptom)                    โ”‚
โ”‚  (:Symptom)-[:INDICATES]->(:Condition)                 โ”‚
โ”‚  (:Patient)-[:ALLERGIC_TO]->(:Drug)                    โ”‚
โ”‚  (:Condition)-[:CONTRAINDICATES]->(:Drug)              โ”‚
โ”‚  (:Hospital)-[:EMPLOYS]->(:Doctor)                     โ”‚
โ”‚  (:Hospital)-[:HAS_BED]->(:Bed)                        โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
          โ”‚                                  โ”‚
          โ”‚ High-Risk Event                  โ”‚ 24 Hours Later
          โ–ผ                                  โ–ผ
Emergency CAD Dispatcher (Twilio)     Recovery Follow-up Engine
Automated PSTN call to Hospital       Outbound Adherence Call
Graph Mutation: SET bed.is_available=false
Enter fullscreen mode Exit fullscreen mode

๐Ÿ•ธ๏ธ The Graph Data Model in FalkorDB

We structured healthcare as a connected property graph in FalkorDB:

Nodes:

  • (:Patient {id, name, age, phone, blood_group})
  • (:Symptom {id, name, severity, name_hi})
  • (:Condition {id, name, risk_level, required_specialty})
  • (:Drug {id, name})
  • (:Hospital {id, name, phone, city, lat, long})
  • (:Doctor {id, name, specialty, available})
  • (:Bed {id, type, is_available})
  • (:AgentSession {id, timestamp, status})

Relationships:

  • (:Patient)-[:EXHIBITS {since_days}]->(:Symptom)
  • (:Symptom)-[:INDICATES {probability}]->(:Condition)
  • (:Patient)-[:ALLERGIC_TO]->(:Drug)
  • (:Condition)-[:CONTRAINDICATES]->(:Drug)
  • (:Hospital)-[:EMPLOYS]->(:Doctor)
  • (:Hospital)-[:HAS_BED]->(:Bed)
  • (:Patient)-[:HAD_SESSION]->(:AgentSession)-[:DETECTED]->(:Symptom)

โšก The Core Decision Engine: 5-Hop Cypher Traversal

Instead of asking an LLM to guess which hospital has a bed, CareGraph AI executes this exact 5-hop Cypher traversal in FalkorDB:

MATCH (p:Patient {id: $patient_id})-[e:EXHIBITS]->(s:Symptom)-[i:INDICATES]->(c:Condition)
WHERE c.risk_level IN ['High', 'Critical']
OPTIONAL MATCH (p)-[:ALLERGIC_TO]->(d:Drug)<-[:CONTRAINDICATES]-(c)
MATCH (h:Hospital)-[:EMPLOYS]->(doc:Doctor {specialty: c.required_specialty, available: true}),
      (h)-[:HAS_BED]->(b:Bed {type: 'ICU_Oxygen', is_available: true})
RETURN p.name AS PatientName, 
       c.name AS SuspectedCondition, 
       c.risk_level AS RiskLevel,
       collect(DISTINCT d.name) AS KnownAllergiesToAvoid,
       h.name AS TargetHospital, 
       h.phone AS HospitalContact,
       doc.name AS AssignedDoctor, 
       count(b) AS AvailableBeds
ORDER BY AvailableBeds DESC
LIMIT 1;
Enter fullscreen mode Exit fullscreen mode

Why This Is Revolutionary:

  • Zero Hallucination: The diagnosis and hospital recommendation are backed by verified graph edges, not probabilistic next-token predictions.
  • Sub-Millisecond Execution: On FalkorDB, this 5-hop multi-hospital traversal benchmarked at 0.31 ms!
  • Patient Safety Check: OPTIONAL MATCH (p)-[:ALLERGIC_TO]->(d)<-[:CONTRAINDICATES]-(c) automatically checks if the patient has known drug allergies (e.g., Penicillin) before emergency drugs are administered.

๐Ÿš‘ Automated Hospital CAD Dispatch & Real-Time Bed Locking

When a critical condition (like STEMI heart attack or stroke) is verified, the system triggers the Emergency Dispatch CAD:

  1. Auto-dials the hospital emergency desk via Twilio PSTN: > "Emergency Alert from CareGraph AI: Patient Rajesh Kumar (52, Acute Coronary Syndrome) is en route. Reserve ICU_Oxygen bed for Dr. Ananya Sharma."
  2. Mutates the FalkorDB state live:
   MATCH (b:Bed {id: $bed_id})
   SET b.is_available = false;
   CREATE (b)-[:RESERVED_FOR {timestamp: timestamp()}]->(p);
Enter fullscreen mode Exit fullscreen mode
  1. The right-hand visualizer reflects the reserved bed with a red lock badge in real time.

โฑ๏ธ 24-Hour Autonomous Recovery Follow-Up

Patient care does not end at hospital admission. CareGraph AI runs a scheduled Cypher query:

MATCH (p:Patient)-[:HAD_SESSION]->(s:AgentSession)
WHERE s.timestamp < timestamp() - 86400 AND s.followup_status IS NULL
RETURN p.name, p.phone, s.id, s.timestamp;
Enter fullscreen mode Exit fullscreen mode

It automatically dials the patient for a post-discharge adherence check-in, asking in Hindi/English about symptom recurrence, and stores the recovery status (RECOVERING / STABLE) back into FalkorDB.


๐Ÿ“Š Performance Benchmarks

Metric Traditional LLM RAG FalkorDB Knowledge Graph
Reasoning Latency 2,500 โ€“ 4,800 ms 0.31 ms (99.9% faster)
Medical Hallucination Risk High (probabilistic text) Zero (deterministic Cypher)
State Mutation Speed Requires multi-DB sync Instant in-memory graph lock
Bilingual Voice Latency > 3 seconds < 250 ms (conversational)

๐Ÿ”— Try It Live


๐Ÿ’ก What We Learned & Why FalkorDB Won

Building CareGraph AI proved that Graph Databases are the missing link in Healthcare AI. While LLMs are great for conversational interfaces, clinical decisions require the mathematical certainty of graph traversals. FalkorDBโ€™s raw speed and intuitive Cypher syntax made sub-second healthcare triage a reality.

Built for the FalkorDB Hackathon on WeMakeDevs.

Top comments (0)