Skip to content
Aarya2004Public

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Tavril

On-device pharmacokinetic digital twin for medication safety. YC x Google DeepMind x Cactus Voice Agents Hackathon — April 18-19, 2026.

Voice in → Gemma 4 understands → function calls route → PK engine computes → time-aware risk + visualization out. Everything runs locally on the phone; cloud is only a fallback when on-device confidence is low.

Tavril is an educational wellness simulation, not a medical device. It models drug/food/supplement interactions using general pharmacology. It does not diagnose, treat, cure, or prescribe. Every alert directs the user to confirm with their prescriber.

Architecture

┌──────────────────────────────────────────────────────────────┐
│  React Native + Expo (iOS / Android)                         │
│                                                              │
│    Voice ──► Cactus STT (Parakeet) ──► Gemma 4 E2B (INT4)    │
│                                          │                   │
│                                          ▼                   │
│                                 Function calls:              │
│                                  • extract_health_entities   │
│                                  • update_health_profile     │
│                                  • check_interactions        │
│                                  • calibrate_severity        │
│                                  • generate_response         │
│                                          │                   │
│    TTS ◄─────── spoken answer  ◄─────────┘                   │
└──────────────────────────────────────────────────────────────┘
               │
               ▼  (fallback / validation only)
┌──────────────────────────────────────────────────────────────┐
│  Python backend (FastAPI)                                    │
│   • PK engine (one/two-compartment, CYP/PGx modulation)      │
│   • RAD causal risk attribution                              │
│   • Interaction + food database                              │
└──────────────────────────────────────────────────────────────┘

Repository layout

Path What's in it
App.tsx, index.ts Mobile app entry
src/ React Native screens, hooks, components, on-device tools
src/lib/pk/ Pharmacokinetic simulation (TypeScript)
src/lib/cactus/ Cactus SDK integration + hybrid routing
src/lib/database/ Local interaction/food database
python-backend/ FastAPI service — PK engine, RAD, PDTC, interaction DB
cactus-clinical-router/ Tool-calling router for the Cactus Python SDK
data/ Interaction corpus (DailyMed + curated food/drug data)
tests/, python-backend/tests/, validation/ Test suites + benchmark harness
legal/ Privacy policy, terms, medical disclaimer, HealthKit disclosure
patches/ Local patches applied to cactus-react-native
HACKATHON_DOCS.md Cactus/Expo API reference used during the build

Getting started

Mobile app (iOS recommended)

npm install
cp .env.example .env   # fill in optional API keys

# Dev build on a physical iPhone (Cactus needs a real device)
npx expo prebuild
npx expo run:ios --device

# Or in Expo Go (no Cactus, limited)
npx expo start

The Gemma 4 E2B model (~1 GB, INT4) is downloaded on first launch. Keep the phone plugged in for the initial fetch.

If you want cloud fallback for out-of-database questions, create a local .env with:

EXPO_PUBLIC_GEMINI_API_KEY=your_key_here

No secrets are committed in this repository.

Python backend

cd python-backend
python3.11 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
uvicorn api:app --reload --port 8000
# http://localhost:8000/docs

Tests

npm test                 # TS/JS
pytest                   # Python

Environment variables

All keys are optional — the app works fully offline with on-device inference. Keys unlock cloud fallbacks and premium TTS.

Variable Used for
EXPO_PUBLIC_GEMINI_API_KEY Cloud fallback when on-device confidence is below threshold
EXPO_PUBLIC_OPENAI_API_KEY Higher-quality TTS via OpenAI (optional)

See .env.example.

Hardware notes

  • Tested on iPhone 13 (4 GB RAM). Close other apps during demo.
  • INT4 quantization is mandatory at this memory budget.
  • Pre-download the model before any live demo.

Demo flow

The strongest live demo path is the Advocate screen:

  1. Tap to speak.
  2. Say: I take atorvastatin every night. I had grapefruit juice today. What happens if I also take acetaminophen for a headache?
  3. Tap again to stop.

Expected output:

  • on-device Gemma audio transcription
  • local PK computation
  • concentration curves with highlighted peak timing
  • PK ledger showing compute time, AUC0-12h, peak risk timing, and safe window
  • mitigation view comparing the requested path to the safer option

Secondary prompt:

  • I take sertraline 50 milligrams every morning. My doctor just prescribed tramadol for back pain.

License

Code in this repository is provided for hackathon-submission review. Drug interaction data is derived from public DailyMed / DrugBank sources; check respective upstream licenses before redistribution.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages