AI-powered health education for children β transforming dense medical files into bite-sized, personalized video episodes that kids actually want to watch.
- Children diagnosed with conditions like asthma, ear infections, or leukemia are scared and confused
- Medical discharge papers are written for adults β kids can't understand them
- Parents are overwhelmed and forget 40β80% of what doctors tell them
- There's no engaging, age-appropriate way for kids to learn about their own health
MedFlix takes a child's real medical data and turns it into a 7-episode animated health show β personalized to their name, diagnosis, medications, and care team. Kids also get a real-time AI Health Buddy they can talk to, collectible battle cards for completing episodes, and picture-based quizzes to reinforce learning.
graph TB
subgraph "π¨ββοΈ Doctor Portal"
DOC[Doctor Selects Patient]
CREATE[Create Health Episodes]
SEND[Send to Patient Portal]
end
subgraph "π Patient Data Layer"
PD[(Patient Profiles<br/>Lily Β· Noah Β· Zara)]
DIAG[Diagnosis + Medications<br/>+ Care Team + Goals]
end
subgraph "π¬ Clinical Data Pipeline"
FDA[OpenFDA API<br/>Drug Labels & Safety]
DM[DailyMed API<br/>NLM Clinical Data]
GATHER[gatherClinicalData<br/>Parallel Fetch + Cache]
end
subgraph "π§ AI Context Engine"
PPLX[Perplexity Sonar AI<br/>LLM Context Layer]
CTX[contextEngine.js<br/>Build Episode Context]
SCRIPTS[episodeScripts.js<br/>7 Hardcoded Builders<br/>per Condition]
end
subgraph "π¬ Video Generation Pipeline"
PROMPT[heygenPrompt.js<br/>Scene-by-Scene Directives]
HEYGEN[HeyGen Video API<br/>Structured Avatar Video]
POLL[Async Status Polling<br/>Background Generation]
VIDEO[(Generated Videos<br/>Per Episode)]
end
subgraph "π£οΈ Real-Time AI Avatar"
LA_TOKEN[LiveAvatar Token API<br/>Session + Avatar Config]
LA_SESSION[LiveAvatar Session<br/>FULL Interactive Mode]
LIVEKIT[LiveKit WebRTC<br/>Audio/Video Streams]
LLM[LiveAvatar LLM<br/>Patient Context Injected]
end
subgraph "π Medication Reminders"
POKE[Poke SDK<br/>Model Context Protocol]
MCP[MCP Server<br/>Tools + Resources]
REMIND[Medication Schedules<br/>+ Reminders]
end
subgraph "π§ Patient Portal"
LOGIN[Kid Login<br/>Emoji Avatar Selection]
PLAN[Recovery Plan<br/>7-Episode Adventure]
CARDS[Battle Card Collection<br/>Quiz + Rewards]
LIVE[Live Health Buddy<br/>Voice Conversation]
MEDS[Medication Reminders<br/>Daily Schedule]
AI_CHAT[AI Assistant<br/>Text Q&A]
end
DOC --> PD
PD --> DIAG
CREATE --> DIAG
DIAG --> GATHER
GATHER --> FDA
GATHER --> DM
FDA --> CTX
DM --> CTX
DIAG --> CTX
CTX --> PPLX
PPLX --> CTX
CTX --> SCRIPTS
SCRIPTS --> PROMPT
PROMPT --> HEYGEN
HEYGEN --> POLL
POLL --> VIDEO
VIDEO --> PLAN
SEND --> PLAN
DIAG --> LLM
LA_TOKEN --> LA_SESSION
LA_SESSION --> LIVEKIT
LIVEKIT --> LLM
LLM --> LIVE
POKE --> MCP
MCP --> REMIND
REMIND --> MEDS
LOGIN --> PLAN
PLAN --> CARDS
LIVE --> LIVEKIT
sequenceDiagram
participant Doc as π¨ββοΈ Doctor
participant FE as React Frontend
participant BE as Express Backend
participant FDA as OpenFDA API
participant DM as DailyMed API
participant PPLX as Perplexity Sonar
participant HG as HeyGen API
Doc->>FE: Select patient + episode
FE->>BE: POST /api/context/build
BE->>FDA: GET drug labels (parallel)
BE->>DM: GET clinical data (parallel)
FDA-->>BE: Drug safety, indications, warnings
DM-->>BE: Dosage, interactions, contraindications
BE->>PPLX: Build context layer<br/>(clinical data + patient info)
PPLX-->>BE: Enriched medical context
BE->>BE: episodeScripts.js<br/>Build scenes (6-8 per episode)<br/>Script + Visual per scene
BE-->>FE: Episode context + scenes
FE->>BE: POST /api/heygen/video-agent
BE->>HG: Create video (script + visuals)
HG-->>BE: video_id (async)
loop Poll every 5s
FE->>BE: GET /api/heygen/status/:id
BE->>HG: Check video status
HG-->>BE: pending / completed + URL
end
HG-->>FE: Video URL ready
FE->>FE: Display in Recovery Plan
sequenceDiagram
participant Kid as π§ Child
participant FE as React + LiveKit
participant BE as Express Backend
participant LA as LiveAvatar API
participant LK as LiveKit Server
participant LLM as Avatar LLM
Kid->>FE: Click "Start Call"
FE->>BE: POST /api/liveavatar/stop-all
BE->>LA: Close stale sessions
FE->>BE: POST /api/liveavatar/token
BE->>LA: Create session (avatar, voice, quality, language)
LA-->>BE: Session token + LiveKit URL
BE-->>FE: Token + URL
FE->>BE: POST /api/liveavatar/start
BE->>LA: Start session
LA-->>BE: Session active
FE->>LK: Connect WebRTC room
LK-->>FE: Audio/Video tracks attached
FE->>LLM: Inject patient context prompt<br/>(name, age, diagnosis, meds, goals)
LLM-->>FE: Initial greeting<br/>"Hi Lily! I'm your Health Buddy!"
loop Conversation
Kid->>FE: Speaks (microphone)
FE->>LK: Audio stream
LK->>LLM: user.transcription
FE->>LLM: Forward with patient context
LLM-->>FE: avatar.speak_response
FE->>Kid: Avatar speaks + captions
end
graph LR
subgraph "Episode 1: Hi There!"
E1[Welcome + Meet Health Buddy]
end
subgraph "Episode 2: What's Happening?"
E2[Condition Explanation<br/>Age-Appropriate]
end
subgraph "Episode 3: Super Medicine!"
E3[Each Med = Superpower<br/>How-To + Fun Facts]
end
subgraph "Episode 4: What's Next?"
E4[Treatment Timeline<br/>Day-by-Day Expectations]
end
subgraph "Episode 5: Healthy Habits!"
E5[Diet + Exercise + Sleep<br/>Daily Routines]
end
subgraph "Episode 6: Uh Oh Moments!"
E6[Warning Signs<br/>When to Tell a Grown-Up]
end
subgraph "Episode 7: You Did It!"
E7[Celebration + Recap<br/>Health Hero Certificate]
end
E1 --> E2 --> E3 --> E4 --> E5 --> E6 --> E7
E1 -.- C1[π¦Έ Captain Welcome]
E2 -.- C2[π¦ Dr. Owl]
E3 -.- C3[π‘οΈ Super Shield]
E4 -.- C4[π’ Time Turtle]
E5 -.- C5[π¦ Veggie Fox]
E6 -.- C6[π¦
Alert Eagle]
E7 -.- C7[β Star Champion]
Each episode unlocks a collectible Battle Card + picture-based quiz.
| Condition | Patient | Age | Key Medications |
|---|---|---|---|
| Childhood Asthma | Lily Chen | 4 | Albuterol (rescue), Flovent (daily controller) |
| Ear Infection (Otitis Media) | Noah Martinez | 3 | Amoxicillin (antibiotic), Children's Tylenol |
| Acute Lymphoblastic Leukemia | Zara Thompson | 10 | Vincristine (chemo), Prednisone, Ondansetron |
| Layer | Technology | Purpose |
|---|---|---|
| Frontend | React 18, Vite, Tailwind CSS | Kid-friendly responsive UI |
| Backend | Node.js, Express.js | API orchestration server |
| Video AI | HeyGen API | Personalized avatar video generation |
| Live AI | HeyGen LiveAvatar + LiveKit | Real-time voice AI conversation |
| Context AI | Perplexity Sonar API | LLM-powered medical context layer |
| Drug Data | OpenFDA API | FDA drug labels, safety, indications |
| Clinical Data | DailyMed / NLM API | Clinical dosage, interactions |
| Reminders | Poke SDK (MCP) | Medication reminders via Model Context Protocol |
| Real-Time | LiveKit (WebRTC) | Audio/video streaming |
| Icons | Lucide React | UI iconography |
| Storage | LocalStorage | Demo-friendly client-side persistence |
# 1. Clone
git clone https://github.com/Michael-600/MedFlix.git
cd MedFlix
# 2. Install frontend
npm install
# 3. Install backend
cd server && npm install && cd ..
# 4. Configure environment
# Create server/.env with:
# HEYGEN_API_KEY=your_key
# LIVEAVATAR_API_KEY=your_key
# PERPLEXITY_API_KEY=your_key
# POKE_API_KEY=your_key
# PORT=3001
# 5. Start backend
cd server && node index.js &
# 6. Start frontend
cd .. && npm run devFrontend: http://localhost:5173 | Backend: http://localhost:3001
MedFlix/
βββ src/ # React Frontend
β βββ main.jsx # App entry point
β βββ App.jsx # Router setup
β βββ index.css # Global styles (Tailwind)
β βββ components/ # UI Components
β β βββ RecoveryPlan.jsx # 7-episode adventure view
β β βββ DayCard.jsx # Episode card + quiz + battle card
β β βββ VideoPlayer.jsx # HeyGen video playback
β β βββ LiveAvatar.jsx # Real-time AI voice conversation
β β βββ AIAssistant.jsx # Text-based Health Buddy
β β βββ CreateContent.jsx # Doctor content creation
β β βββ MedicationReminders.jsx # Poke medication tracking
β β βββ Header.jsx # Navigation
β β βββ Logo.jsx # App logo component
β βββ pages/
β β βββ Landing.jsx # Public homepage
β β βββ Login.jsx # Role selection (Doctor / Kid)
β β βββ DoctorPortal.jsx # Doctor's patient management
β β βββ PatientPortal.jsx # Kid's health adventure
β βββ contexts/
β β βββ AuthContext.jsx # useAuth() hook, localStorage persistence
β βββ data/
β β βββ patientData.js # 3 kid patient profiles
β β βββ quizData.js # Quiz questions + battle cards
β β βββ mockData.js # Defaults, medications, AI responses
β βββ utils/
β β βββ storage.js # localStorage wrapper with "medflix_" prefix
β βββ api/
β βββ clinicalDataTool.js # OpenFDA + DailyMed client
β
βββ server/ # Node.js Backend
β βββ index.js # Express API server (all routes)
β βββ contextEngine.js # Clinical data β episode context
β βββ episodeScripts.js # 7 hardcoded episode builders
β βββ heygenPrompt.js # Video generation prompt builder
β βββ perplexitySonar.js # Perplexity AI integration
β βββ clinicalSearch.js # ClinicalTrials.gov search (server-side)
β βββ openfdaClient.js # OpenFDA drug data client
β βββ dailymedClient.js # DailyMed drug label client
β βββ pokeMcp.js # Poke MCP server (stdio)
β βββ mcp/ # MCP tools for Poke agent
β βββ main.js # MCP server entry point
β βββ createServer.js # Server factory + tool registration
β βββ api.js # Shared API helpers
β βββ tools/
β βββ index.js # Tool registry
β βββ getPatientContext.js # Patient info lookup
β βββ getMedicationSchedule.js # Medication schedule lookup
β βββ searchClinicalEvidence.js # ClinicalTrials.gov search
β βββ researchMedicalTopic.js # Perplexity Sonar research
β βββ logMedicationTaken.js # Log adherence events
β βββ sendReminder.js # Send reminder via Poke
β
βββ README.md # β You are here
βββ server/README.md # Backend documentation
βββ src/README.md # Frontend documentation
Built for TreeHacks 2026 by the MedFlix team.
"Every child deserves to understand their own health β in words they can actually understand."