Inspiration

Medication errors injure 1.5 million people annually in the US — most caused by dangerous drug combinations that no single doctor catches because they only see part of a patient's prescription history. Existing drug interaction checkers are static lookup tables: they can only flag combinations they've explicitly seen before. We wanted to build something that reasons from first principles — the way a pharmacist actually thinks. When we discovered Jac's walker model, we realized the human body is naturally a graph: organs, enzymes, and drugs as nodes, metabolic pathways as edges. That insight became MediGraph.

What it does

MediGraph lets anyone scan their current medications for dangerous interactions before their next doctor's visit. Add your medications, and two AI agents automatically analyze your personal metabolic graph — detecting conflicts structurally, proposing safer alternatives, adjusting doses for your kidney function, and explaining everything in plain English. One button downloads a PDF you can hand to your doctor. No medical training required.


How we built it

MediGraph is built entirely in Jac and is graph-native from the ground up — not a Python app with Jac bolted on.

The patient's body is modeled as a first-class Jac graph: Drug nodes connect via MetabolizedBy edges to Enzyme nodes (CYP3A4, CYP2D6, CYP2C9, etc.), which connect to Organ nodes (Liver, Heart, Kidney). This structure mirrors real biochemistry.

Conflict detection uses a pure Jac walker — no LLM. The ConflictWalker traverses each drug's enzyme pathway and detects structural competition: two drugs sharing an enzyme where one is an inhibitor is a conflict, regardless of any lookup table.

Two agents handle the response: PharmacistAgent runs a ReAct loop — reading the patient graph, choosing from five deterministic tools (fetch FDA label, find alternatives, compute dose adjustment, escalate, done), dispatching, and looping until resolved. SafetyCritic is an independent agent that audits every finding afterward and issues a verdict. Both agents use byLLM typed functions — the return type signature is the prompt, no prompt engineering required.

Every reasoning step, evidence node, and recommendation is stored as a persistent graph node, making the agent's reasoning replayable and auditable. The consumer frontend is React + Tailwind, with the full agentic stack visible behind a single "Show advanced AI review" toggle so the app works for patients and impresses developers simultaneously.


Challenges we ran into

Designing the graph so that conflict detection required zero LLM calls was harder than it sounds. The temptation is to ask the LLM "do these two drugs interact?" — but that makes the system a black box and breaks when the LLM hallucinates. We had to encode enough biochemical structure (enzyme nodes, inhibitor flags, organ pathway edges) that the walker could detect conflicts purely from topology. Getting that seed graph right — 15 drugs, 6 enzymes, 5 organs, all correctly wired — took most of day one.

The second challenge was the consumer reframe. The underlying system speaks pharmacology. Making it speak to a 68-year-old patient without dumbing it down or losing clinical accuracy required careful prompt design for the byLLM ClinicalExplanation type — specifically getting the summary field to avoid CYP codes while keeping the mechanism field technically precise for the expandable clinical details section.


Accomplishments that we're proud of

Conflict detection that provably requires zero LLM calls — you can disconnect the API key and the walker still finds the Clarithromycin + Simvastatin CYP3A4 conflict correctly. That's the thing we're most proud of technically. It means the system's core safety function is deterministic, auditable, and explainable — which matters enormously in healthcare.

The two-agent architecture where PharmacistAgent and SafetyCritic are genuinely independent — different graph traversal paths, different tool access, different LLM calls — rather than one agent pretending to check its own work.

And honestly: shipping a full-stack consumer health app with a live graph visualization, PDF export, FDA integration, and multi-agent reasoning in under 48 hours, entirely in a language we learned during the hackathon.


What we learned

Jac's walker model is not just syntactic sugar over a graph library — it fundamentally changes how you design systems. In Python you ask "what function should I call?" In Jac you ask "where should this agent go?" That spatial thinking unlocked the architecture. The moment we stopped thinking about the drug interaction problem as a lookup task and started thinking about it as a traversal problem, everything clicked.

We also learned that byLLM's typed return pattern is genuinely powerful. Writing explain_interaction(...) -> ClinicalExplanation by llm() and having Jac infer the prompt from the type signature eliminated an entire layer of prompt engineering and made the LLM output structurally reliable.


What's next for MediGraph

Patient-specific pharmacogenomics — CYP enzyme polymorphisms vary by genetics, and a patient who is a poor CYP2D6 metabolizer faces very different risks than an extensive metabolizer. Adding genotype nodes to the graph would make conflict detection truly personalized.

Prescription photo scan — OCR a prescription label, auto-populate the graph. This removes the last friction point for non-technical users.

EHR integration via FHIR — pull a patient's medication list directly from their health record so they never have to enter drugs manually.

Multi-patient mode for caregivers — parents managing children's medications, adult children managing elderly parents' regimens.

Built With

Share this project:

Updates