Lucid — AI-Powered Dementia Monitoring & Companion Platform

The Problem (By the Numbers)

  • 55 million people worldwide live with dementia
  • 20% of dementia patients experience sundowning syndrome — late-day agitation and confusion that is the single most exhausting challenge caregivers face
  • The warning signs show up in voice patterns 20-40 minutes before the crisis peaks
  • Lucid windows (brief moments of unusual clarity) last only 5-20 minutes and are almost always missed
  • 0 products on the market currently predict sundowning before it happens or detect lucid windows in real time

Every existing tool waits for the crisis to start. Lucid acts before it does.


Our Story

One of our team members grew up next door to an elderly woman who had dementia. He was in 3rd grade when he first noticed something was off. Every evening she would get really confused and agitated and scared. He didn't understand what was happening at the time, but it stuck with him.

He also remembered these moments where she would suddenly seem totally fine. Like herself again. And those moments would just pass and nobody really knew what to do with them or even noticed them half the time.

Years later when he learned about sundowning and lucid windows in dementia patients he immediately recognized what he had witnessed as a kid. The confusion getting worse in the evenings. The random moments of clarity. It was exactly the same thing.

So we asked ourselves — what if there was something that could warn you BEFORE the bad moment hits? And also catch the good moments so families don't miss them?

That's Lucid.


What Lucid Does

Lucid runs three parallel layers simultaneously from a single browser tab — continuous passive audio monitoring, daily cognitive assessment games, and an AI voice companion — all coordinated through a real-time caregiver dashboard.

Layer 1 — Daily Detection Engine

Patients complete two short daily tasks that feel like games:

  • Word Recall: 5 words displayed briefly, then recalled after a distractor game. Gemini scores accuracy and sequence memory.
  • Clock Drawing: Patient draws a clock on a canvas. Gemini Vision scores face completeness, number placement, hand presence, and time accuracy.

An 8-week rolling baseline tracks each patient's personal cognitive trajectory — compared against themselves, not population averages. That distinction actually matters clinically.

Layer 2 — AI Voice Companion

The companion initiates morning check-ins, delivers medication reminders conversationally, and activates Reminiscence Mode when a lucid window is detected. Family members can clone their own voice during onboarding so the patient hears someone familiar — not a generic assistant. Reminiscence Mode shows a full-screen photo carousel with AI-narrated captions, auto-advancing every 45 seconds.

Layer 3 — Continuous Ambient Monitoring

Every 15 seconds, a rolling audio clip is captured from the patient's room and sent to Gemini 1.5 Pro. No wearable, no button — fully passive. Gemini classifies the audio into one of four states:

LUCID           → elevated clarity, great time for family engagement
STABLE          → baseline normal, keep listening
EARLY_DECLINE   → warning signals detected, sundowning approaching
INTERVENTION    → active confusion or distress, respond now

A false-positive guard requires 3 consecutive matching classifications before any state change is committed. The only exception is INTERVENTION at >85% confidence, which fires immediately.

Layer 4 — Caregiver Command Center

A real-time dashboard that updates within 3 seconds of any state change via Server-Sent Events:

  • Real-Time State Panel — large pulsing colored dot, confidence %, time in state
  • Sundowning Countdown — when EARLY_DECLINE is detected, a timer estimates minutes to predicted peak
  • Lucid Window Timer — when LUCID is detected, a countdown shows how long the window has been active with a one-click button to push the Reminiscence carousel to the patient's tablet
  • 6-Hour Cognitive Timeline — color-coded area chart of state history
  • Weekly PDF Export — a clinical handoff report formatted for doctor visits

How We Built It

Tech Stack

Layer Technology Purpose
Framework Next.js 16 (App Router) Server components, API routes, Vercel hosting
Language TypeScript 5 Full type safety client and server
Styling Tailwind CSS 3 Utility-first, consistent tokens
Charts Recharts 2 Composable React charts
Audio Capture MediaRecorder API (browser native) 15-second audio chunks, no library needed
Real-Time SSE / EventSource (browser native) Vercel-compatible, auto-reconnect
AI Analysis Gemini 1.5 Pro via Vertex AI Multimodal audio + vision classification
Database Firestore (Firebase) Real-time onSnapshot, schemaless
Voice Synthesis ElevenLabs + SpeechSynthesis fallback Cloned family voice, emotional delivery
SMS Alerts Twilio Caregiver escalation chain
PDF Generation @react-pdf/renderer 4 Clinical handoff reports
Hosting Vercel Serverless functions + CDN

Data Flow

Patient Tablet (Browser)
  │
  ├── MediaRecorder → 15s audio chunk → POST /api/analyze-audio
  │     └── Gemini 1.5 Pro → cognitive state classification
  │           └── State Machine → Firestore write
  │                 ├── LUCID → ElevenLabs voice + Twilio SMS to family
  │                 ├── EARLY_DECLINE → calm mode + sundowning countdown
  │                 └── INTERVENTION → ElevenLabs voice + Twilio escalation
  │
  └── Firestore onSnapshot (client)
        └── cognitiveState/current → Reminiscence Mode trigger

Caregiver Dashboard (Browser)
  └── SSE /api/alerts/stream → real-time alert feed (< 3 second latency)

Onboarding

A 4-step wizard personalizes everything before monitoring begins:

  1. Basics — name, age, language, routine
  2. Biography — spouse, children, career, key memories (used by companion for personalized conversation)
  3. Contacts — escalation chain with up to 3 family members for Twilio SMS routing
  4. Voice Setup — 5-minute baseline recording analyzed by Gemini for speech profile + optional 30-second family voice clone via ElevenLabs Instant Clone

Challenges We Faced

False alarms almost killed the product. Early on the system was firing constantly because a single noisy audio chunk would trip the classifier. The fix was the 3-chunk consensus requirement — the system now needs 45 seconds of agreement before transitioning state. That one change made everything usable.

Lucid window latency was brutal. These windows only last 5-20 minutes. The entire pipeline from audio capture to ElevenLabs voice playback had to stay under 20 seconds or the whole feature was pointless. We got there by pre-generating intervention scripts at onboarding rather than synthesizing on demand.

Day one cold start. The prediction engine gets smarter over time but on day one there's zero history. The solution was the 5-minute baseline recording during onboarding — Gemini processes it to extract speech rate, pause frequency, vocabulary range, and emotional tone so the system has a real reference point from the first session.

Framing alerts responsibly. We had to be really deliberate about how alerts are worded. Lucid is not a diagnostic tool. Every alert says "signals detected, estimated X minutes" not "patient is declining." That's not just ethical — it's more accurate about what the system actually knows.


What We Learned

We learned that sometimes the most important thing technology can do is just tell the right person the right thing at the right moment. Lucid is not a doctor. It just helps caregivers be in the right place when it matters.

We also learned that families don't only want to prevent the bad moments. They really just don't want to miss the good ones.


What's Next

Phase 1 — Security & Compliance Transitioning to Firebase Auth and establishing GCP Business Associate Agreements for HIPAA compliance.

Phase 2 — Data Integrity Deploying audio preprocessing and noise gates to improve Gemini classification accuracy. Archiving raw audio in Firebase Storage.

Phase 3 — Performance Infrastructure Integrating Redis/Upstash for robust API rate limiting and transitioning the longitudinal engine from mock data to real baseline accumulation after Day 14.


Built With

Next.js TypeScript Tailwind CSS Vercel Gemini 1.5 Pro Google Cloud Vertex AI Firestore Firebase ElevenLabs Twilio WebRTC MediaRecorder API Server-Sent Events Recharts @react-pdf/renderer

Built With

Share this project:

Updates