Inspiration
Every year, thousands of patients are discharged from hospitals with pages of instructions they barely understand. The first 30 days after discharge are the most dangerous, medication errors, missed follow-ups, and unrecognized symptom escalation account for a staggering number of preventable readmissions. We asked: what if a patient could just talk to something that remembers everything their doctor said, watches their vitals, and knows when to call for help?
CareAnchor was born from that question an always-on clinical companion that bridges the gap between hospital and home.
What it does
CareAnchor is an autonomous post-discharge clinical assistant that patients interact with through natural-language chat. It does three things no existing solution does together:
Persistent clinical memory: Every conversation refines a structured recovery profile (pain trends, medications, vitals, symptoms) that persists across sessions. Patients never have to repeat themselves. Real-time safety monitoring: A dual-layer rule engine evaluates vital signs against configurable clinical thresholds and scans free-text for 12 critical symptom patterns (chest pain, breathing difficulty, suicidal ideation, stroke symptoms, etc.). When thresholds are crossed, the agent shifts from supportive coaching to urgent escalation mode. Human-in-the-loop interrupts: A finite state machine manages safety interrupts with escalation states, cooldown-based notification rate limiting, and webhook integration to alert care teams when a patient needs human attention.
How we built it
Backend (Python / FastAPI / LangGraph): The agent pipeline is a LangGraph StateGraph with three orchestration nodes, clinical data extraction (structured JSON via Qwen), memory update (deep merge into persistent profile), and safety evaluation, followed by conditional response generation with streaming tokens. Safety uses a Severity enum (INFO/WARN/CRITICAL) with configurable thresholds for 6 vital signs and 12 regex-based symptom keyword rules, producing a composite risk score on a 0–10 scale. An InterruptController state machine manages the lifecycle: NORMAL → PENDING_ACKNOWLEDGMENT → ACKNOWLEDGED/ESCALATED → RESOLVED. Persistence uses SQLite via aiosqlite with WAL mode. LLM inference uses Alibaba Cloud DashScope (Qwen-Max for responses, Qwen-Plus for extraction) through an OpenAI-compatible client.
Frontend (React 19 / TanStack Start / Vite): File-based routing with TanStack Router, real-time WebSocket streaming via a custom useAgentChat hook. Split-panel UI: chat interface on the left, live clinical memory viewer on the right showing vitals, medications, symptoms, and safety events as the agent extracts them. File attachment support (images, PDFs, Word docs) with base64 encoding and server-side analysis. Built with the shadcn/ui component pattern (Radix primitives + Tailwind CSS v4).
Deployment: Targeting Alibaba Cloud ECS with Docker Compose, runtime verification endpoint, and alibaba_cloud_config.py for hackathon deployment proof. Supabase handles authentication.
Challenges we ran into
Windows file locking on routeTree.gen.ts: Two TanStack plugins tried to write the same file simultaneously, causing EPERM errors. Solved by removing the redundant TanStackRouterVite plugin and relying on tanstackStart for route generation. SSR + Supabase auth: The Supabase client requires window/localStorage but TanStack Start defaults to SSR. Solved by adding ssr: false to auth-protected routes. Plugin order sensitivity: TanStack Router requires being listed before React Refresh plugins in Vite config. The error messages were cryptic but the fix was straightforward once identified. No PostgreSQL on the dev machine: Switched the entire persistence layer from async PostgreSQL (asyncpg) to SQLite (aiosqlite) with zero schema changes, keeping the production PostgreSQL path intact for deployment. Supabase email confirmation: mailer_autoconfirm was disabled, requiring a full email confirmation flow. Built a complete sign-up screen with confirmation state handling.
Accomplishments that we're proud of
122 automated tests passing across safety evaluation, interrupt state management, clinical tools, graph orchestration, and response generation, covering edge cases like compound risk scoring, multi-severity vitals, and state machine transitions. Two-phase agent execution, Separating orchestration (extraction → memory → safety) from response generation (streaming tokens), enabling real-time progress events before the LLM even starts generating. Severity-tiered clinical responses, The agent's behavior and prompts change based on detected severity: supportive coaching for normal vitals, monitoring recommendations for warnings, and urgent emergency instructions for critical thresholds. Production-ready architecture on a hackathon timeline, LangGraph for auditable agent flows, WebSocket streaming for responsive UX, and clean separation between clinical logic, safety rules, and conversation.
What we learned
LangGraph's astream() pattern: Building a multi-node agent pipeline with structured state and conditional branching taught us how to think about AI workflows as graphs rather than function chains. Safety-critical AI design: Implementing the interrupt system showed us that medical AI isn't just about the LLM; it's about the guardrails around it. The state machine, rate limiting, and severity escalation are what make it safe to deploy. TanStack Start's evolving API: We learned that full-stack React frameworks move fast. Plugin APIs change between versions, and documentation lags behind. Reading error messages carefully saved us hours. The power of persistent memory: A chatbot that remembers is fundamentally different from one that doesn't. The clinical memory viewer updating in real-time as the agent extracts facts made the value immediately visible.
What's next for Care Anchor
Voice interface: Hands-free check-ins for patients with limited mobility, using speech-to-text and text-to-speech. Care team dashboard: A clinician-facing web portal showing patient risk scores, vitals trends, and safety event history. Medication interaction checking: Cross-referencing extracted medications against known interaction databases. EHR integration: FHIR-based integration with hospital electronic health records for seamless data flow. Multi-patient scaling: Moving from single-session SQLite to PostgreSQL with proper multi-tenant isolation for production deployment. FDA pathway exploration: Understanding regulatory requirements for clinical decision support software.
Built With
- aiosqlite
- alibaba-cloud
- docker
- fastapi
- httpx
- langchain
- langgraph
- llm
- openai-api
- pydantic
- python
- qwen
- radix-ui
- react
- recharts
- shadcn-ui
- sqlite
- supabase
- tailwindcss
- tanstack-router
- tanstack-start
- typescript
- vite
- websocket
Log in or sign up for Devpost to join the conversation.