Project Info
Inspiration
We were inspired by the challenge faced by elderly citizens, like our grandparents, who live alone and for whom small changes in health vitals can go unnoticed — even when they are early warning signs of serious complications. Given that 65 million Americans wear a smartwatch that collects heart rate, sleep, and activity data, we wanted to create a personal assistant tool that can take actions based on health trends. Healthcare is slow, and by the time someone notices a problem or books an appointment, it’s often too late for effective intervention. This inspired us to create an autonomous way to facilitate doctor and patient interactions for elderly citizens. What It Does CareSync gives every patient an autonomous AI care agent, exposed as a secure API endpoint, that monitors their health and coordinates care on their behalf. For Patients, Your Agent Ingests real Apple Watch data via an iOS + WatchOS app connected to HealthKit (9 data types including steps, heart rate, sleep stages, workouts, and irregular rhythm events). Detects anomalies automatically using a 28-day rolling baseline (mean ± std), flagging events like resting heart rate spikes and sleep drops with a 0–100 severity score. Makes autonomous decisions through a Secretary Agent using Claude's Agent SDK that weighs severity, urgency, and medical context by querying PubMed and FDA sources and escalates to a doctor’s receptionist agent. Books appointments through agent-to-agent negotiation via a 3-turn propose/counter/confirm protocol, with Ed25519 cryptographic signatures on every message. Communicates through HeyGen streaming avatars in 12+ languages (Deepgram STT + ElevenLabs TTS), allowing a Mandarin-speaking grandmother to have face-to-face conversations with her AI doctor. For Doctors, Your Agent Receives patient escalations and triages them through a LangGraph state machine using Claude. Checks Google Calendar availability and proposes appointment slots. Proposes and books appointments with full clinical context. The Platform Provides A registry where every person has a canonical API endpoint (/u/:handle). Ed25519 cryptographic signatures on every agent-to-agent request with replay protection. Policy engine support for caller whitelists, scope-based permissions, and payment gating. Full execution traces showing exactly what agents did and why. CareSync is a multi-agent orchestration and healthcare platform where each person becomes an agent endpoint. We transform static wearable health data into actionable outcomes with structured summaries, risk modeling, and scheduling. This reduces missed appointments, preventable deterioration, administrative stress, and care delays. How We Built It Architecture Monorepo with three main layers: Next.js 14 frontend (deployed on Vercel) Python Doctor Agent microservice (FastAPI) Shared type system (@people/shared) that keeps both sides synchronized through Pydantic models and Zod schemas Web Platform (Next.js 14) React 18 TailwindCSS Clerk authentication Supabase via Prisma The centerpiece is a "Secretary Agent,” an LLM orchestrator using Claude Sonnet 4.5 or GPT-4o with function-calling to: Analyze anomalies Triage patients Schedule appointments Generate health summaries Doctor Agent (FastAPI + LangGraph) A state machine modeling triage as a multi-turn workflow: receive alert → classify severity → ask follow-ups → decide action → dispatch Claude handles clinical reasoning in a multi-tool loop where it: Checks for life-threatening conditions Classifies severity on a four-tier scale Determines appointment type Checks real Google Calendar availability HeyGen Streaming Interface Instead of notifications, patients can interact with real-time streaming agents (Deepgram STT + ElevenLabs TTS) that explain anomalies and walk through next steps in 12+ languages. Claude’s reasoning outputs feed into HeyGen’s API for personalized, conversational explanations. Agent-to-Agent Communication Ed25519 cryptographic signatures on every request Canonically serialized JSON (sorted keys) Signed and verified with nonce-based replay protection 5-minute timestamp windows Policy engine validates permissions before execution Pipeline Biometric data arrives → 28-day personal baseline computed (mean ± std). Patient agent calculates anomaly score (0–100) and flags concerns. Claude evaluates anomaly, decides escalation, and drafts clinic messages. Doctor agent runs multi-turn intake, checks availability, and books appointments. Full trace persisted: alert, decision, triage outcome, calendar event. Challenges We Ran Into Incorporating multi-agent orchestration and negotiation amongst agents. A singular LLM endpoint became a bottleneck during early development. Google Calendar configuration issues: the bot created events on an invisible calendar due to hallucinated state; we learned we must explicitly specify the correct Google Calendar each time. After booking confirmation, appointments sometimes did not appear or double-booked. Our first trace system only logged "triage: ok" instead of a full traceback, limiting interpretability. Time constraints prevented building full tracing infrastructure like Langfuse. The AI makes decisions inside its own internal loop, so we had to hook into every step to capture reasoning, tool calls, and responses. Context management was difficult due to frequent pivots in use case and workflow. Accomplishments We’re Proud Of We built CareSync because our grandparents deserve the same quality of monitoring that a hospital ICU provides — but from the comfort of their home, in their own language, through a face they can trust. We built an end-to-end pipeline that actually works: A simulated Apple Watch anomaly goes in → a real Google Calendar appointment comes out. The patient agent detects the problem. The doctor agent triages it across multiple turns. A real event with clinical context is proposed and booked on the doctor's calendar. We built platform infrastructure for a healthcare agent ecosystem. The “People API” concept includes a registry, policy engine, capability discovery, and permission model. Another developer could register an agent today, define capabilities, set access policies, and plug into the network. We bridged the gap between passive data and active intervention — turning watch data into a doctor’s appointment through anomaly detection, clinical reasoning, scheduling negotiation, and calendar integration in a multi-turn agent reasoning framework. What’s Next for People API Multi-doctor routing: match patients to the right specialist based on triage outcome, availability, insurance, and location. Patient consent controls: granular settings for what your agent can share, with whom, and under what conditions. HIPAA compliance: privacy and security for clinical deployment. Tech Stack Frontend Next.js 14 (App Router) React TailwindCSS Backend Next.js API Routes FastAPI (Python) LangGraph Database Supabase PostgreSQL via Prisma Auth Clerk LLMs Anthropic Claude Sonnet (primary) OpenAI GPT-4o-mini Agent Framework Claude Agent SDK with MCP tool server Voice & Streaming Deepgram (STT) ElevenLabs (TTS) HeyGen (streaming avatar) Mobile Swift / SwiftUI HealthKit WatchOS Crypto Ed25519 (tweetnacl) for agent-to-agent signing Clinical Data Sources PubMed (NCBI) openFDA AHA / CDC / WHO guidelines Google Calendar API Deployment & Infrastructure Vercel pnpm workspaces (monorepo) Zod schemas Pydantic v2 Canonical JSON serialization
CareSync — AI-Powered Elderly Care Platform
TreeHacks 2026
CareSync is an end-to-end healthcare platform where AI agents autonomously monitor patient health, detect anomalies, triage alerts, consult patients via a talking avatar, and book appointments — all with full observability and cryptographic trust.
Architecture
/
apps/web/ Next.js 14 (App Router) — Dashboard + Patient UI + API
apps/api/ Python FastAPI — Doctor Agent backend
ios/ iOS + Apple Watch app (HealthKit integration)
packages/shared/ Shared TypeScript types, Zod schemas, LLM abstraction
mcp-server/ Model Context Protocol server for healthcare tools
Doctor_Agent_for_TreeHacks/ Doctor Agent (scheduling, triage, calendar)
Quick Start
pnpm install
cd apps/web && npx prisma db push && cd ../..
pnpm dev
Open http://localhost:3000.
The database auto-seeds on first API request with users (pari, alex, dr_smith) and 30 days of health metrics.
Demo Flow
1. Watch Trigger
Tap "Trigger Alert" on the Apple Watch. Haptic feedback confirms. Synthetic health data (low sleep, high resting HR, irregular heart rhythm) uploads to the backend via POST /api/health-data.
2. Clinical Dashboard — Anomaly Detection
On the Clinical Dashboard (/dashboard/anomaly), the anomaly appears in real-time with:
- Severity score (0–100)
- Flags:
SLEEP_DROP,RHR_SPIKE,STEPS_DROP,SYMPTOM_SPIKE - Agent's autonomous triage decision and urgency level
- Live patient metrics (auto-refreshes every 30s)
3. Trace Inspection
Click into any alert to view the full chain:
- Anomaly Detection — flag detection and scoring from wearable data
- Secretary Agent Reasoning — LLM-powered analysis with tool-calling
- PubMed Evidence Lookup — clinical studies and guidelines from NCBI
- Triage Decision — intake questions, urgency scoring, escalation
- Appointment Booking — slot negotiation and calendar integration
Each step is logged with actor, event type, timestamp, and full data payload.
4. Patient Voice Consultation
At /patient/call, the patient speaks with Dr. Smith — a HeyGen streaming avatar:
- Context-aware greeting referencing the specific anomaly (elevated HR, low sleep)
- Real-time voice conversation via Deepgram STT + HeyGen TTS
- AI doctor responses generated by Claude with the full health context
- Live transcript and clinical entity extraction (symptoms, medications, allergies)
- Red flag detection and automated triage actions
- 12-language support
5. Appointment Booking
The patient's agent and doctor's agent negotiate appointment slots autonomously:
- Scheduler Agent checks Google Calendar availability
- Doctor Agent proposes slots from the doctor's calendar
- Patient Agent accepts and confirms
- Booking appears on Google Calendar and in the patient's appointments view at
/patient/appointments
Environment Variables
Copy .env.example to .env.local:
cp apps/web/.env.example apps/web/.env.local
| Variable | Required | Description |
|---|---|---|
ANTHROPIC_API_KEY | Yes | Claude LLM for agent reasoning, voice responses, entity extraction |
OPENAI_API_KEY | No | Alternative LLM provider (GPT-4o-mini) |
HEYGEN_API_KEY | Yes | Streaming avatar for Dr. Smith voice consultations |
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY | Yes | Clerk authentication |
CLERK_SECRET_KEY | Yes | Clerk server-side auth |
SUPABASE_URL | Yes | Supabase project URL for health data storage |
SUPABASE_SERVICE_ROLE_KEY | Yes | Supabase service role key |
DATABASE_URL | Yes | Postgres connection string (Supabase) |
GOOGLE_CLIENT_ID | No | Google Calendar OAuth |
GOOGLE_CLIENT_SECRET | No | Google Calendar OAuth |
NEXT_PUBLIC_BASE_URL | No | Defaults to http://localhost:3000 |
Deploy to Vercel
- Push to GitHub
- Import in vercel.com/new
- Set root directory to
apps/web - Add environment variables (see table above)
- Deploy — the build runs
prisma generate && next build
Key API Endpoints
| Endpoint | Method | Description |
|---|---|---|
/api/health-data | POST | Receive health data from iOS/Watch, run anomaly detection |
/api/trigger | POST | Secretary Agent — route health triggers to sub-tools |
/api/anomaly/live | GET | Live patient metrics for the clinical dashboard |
/api/anomaly/history | GET | Alert history with filtering and pagination |
/api/voice/respond | POST | Generate doctor responses + extract clinical entities |
/api/heygen/token | POST | Create HeyGen streaming session tokens |
/api/calendar/events | GET | Fetch calendar events for a patient |
/api/patient/agent | POST | Patient agent stub (receives slot proposals from Doctor Agent) |
/api/demo/trace/:traceId | GET | Retrieve full trace for inspection |
Secretary Agent
The Secretary Agent is an LLM-powered orchestrator that receives health triggers and autonomously chains tools:
analyze_anomaly— evaluates health anomaly severity and urgencylookup_clinical_evidence— searches PubMed and clinical guidelinestriage_patient— runs intake questions, books appointment if neededget_health_summary— retrieves 30-day health trendsschedule_appointment— finds available slots and books via Google Calendarnotify_doctor_agent— alerts the Doctor Agent for scheduling negotiation
Supports both Anthropic (Claude) and OpenAI (GPT-4o) with automatic fallback.
iOS / Apple Watch App
- HealthKit Integration — reads steps, heart rate, sleep, active energy, workouts, health events
- Trigger Alert — sends synthetic anomaly data to the backend for pipeline testing
- Haptic Feedback — success/failure haptics on the Watch
- Auto-Sync — periodic health data uploads
Tech Stack
- Monorepo: pnpm workspaces
- Web: Next.js 14 (App Router), React 18, TypeScript, Tailwind CSS
- Auth: Clerk
- DB: Supabase (Postgres) + Prisma ORM
- LLM: Anthropic Claude (Messages API + Agent SDK), OpenAI GPT-4o
- Voice: HeyGen Streaming Avatar, Deepgram STT, ElevenLabs TTS
- iOS: Swift, SwiftUI, HealthKit, WatchKit
- Signing: Ed25519 via tweetnacl
- Clinical: PubMed E-utilities, AHA/CDC/WHO guidelines
- Calendar: Google Calendar API (OAuth 2.0)
- Schemas: Zod
Analysis
View
Metric
- 30
- 13
- 8
- 4
- 4
- 3
- 2
Figures cover GitHub contributors during the hackathon window. A co-authored commit counts in full for each author, so per-member totals add up to more than the whole-team figures.
Technology
- AnthropicIn code
- CSSIn code
- FastAPIIn code
- JavaScriptIn code
- LangChainIn code
- Next.jsIn code
- OpenAIIn code
- PythonIn code
- ReactIn code
- SQLIn code
- SupabaseIn code
- SwiftIn code
- Tailwind CSSIn code
- TypeScriptIn code
- PostgreSQLClaimed
- VercelClaimed
14 of 16 appear in the indexed code. 2 claimed on Devpost could not be matched to code, which may simply mean the tool leaves no trace in the repository.
AI coding agents
- Claude CodeConfig · Commits
- CursorConfig · Commits
Detected from committed agent config files and commit authorship. Absence of a signal is not proof an agent was unused.
Codebase size
Source size
1.3 MB
Source files
248
Counts recognized source files only; vendored directories, binaries and lockfiles are excluded, so this is smaller than the repository on disk.
Repository
SpartaKushK/treehacks2026
285 files · 2.5 MB · @ 6973280
Structure
Interface
72 files · 25%Screens, components and styles rendered to the user.
API & routing
76 files · 27%Request entry points: routes, handlers and controllers.
Application logic
80 files · 28%Domain rules, services and shared utilities.
+2 moreBackground jobs
1 file · 0%Work run outside a request: tasks, workers and schedules.
Data & schema
10 files · 4%Schema definitions, migrations and data access.
Supporting
Layers are inferred from where files sit in the tree, not from reading the code. A project that names its directories unconventionally will read oddly here — open the file browser to check anything the diagram implies.
Languages
- TypeScript60%
- Python14%
- YAML11%
- Markdown8%
- Swift3%
- CSS2%
- Other (2)1%
Share of indexed source by file size. Binary and vendored files are excluded.
Dependencies
apps/web/package.json
npm · 41- @anthropic-ai/claude-agent-sdk
- @clerk/nextjs
- @heygen/streaming-avatar
- @people/shared
- @prisma/client
- @radix-ui/react-avatar
- @radix-ui/react-dialog
- @radix-ui/react-label
- @radix-ui/react-progress
- @radix-ui/react-radio-group
- @radix-ui/react-separator
- @radix-ui/react-slot
- @radix-ui/react-switch
- @radix-ui/react-tabs
- @supabase/supabase-js
- @types/qrcode
- class-variance-authority
- clsx
- +23 more
Doctor_Agent_for_TreeHacks/requirements.txt
pypi · 14- anthropic
- fastapi
- google-api-python-client
- google-auth-httplib2
- google-auth-oauthlib
- httpx
- langchain
- langchain-core
- langgraph
- modal
- pydantic
- python-dotenv
- sendgrid
- uvicorn[standard]
apps/api/pyproject.toml
pypi · 9- anthropic
- fastapi[standard]
- httpx
- openai
- pydantic-settings
- pyjwt[crypto]
- pynacl
- supabase
- uvicorn[standard]
mcp-server/package.json
npm · 6- @modelcontextprotocol/sdk
- poke
- zod
- +3 more
packages/shared/package.json
npm · 2- zod
- +1 more
Declared in the repository’s manifests at the indexed commit. A declared package is not proof it is used, and runtime dependencies are listed first.
This project’s features have not been analysed yet.
Export this project's context (description, README, evidence, key source files) to chat with an AI agent elsewhere.