AI Voice Companion for Early Cognitive Decline Detection in Elderly Adults
How It Works β’ Architecture β’ Features β’ Tech Stack β’ Getting Started β’ Structure
We live in a fast-paced world. Our generation is constantly on the move, juggling demanding careers, young families, and relentless schedules. Yet, our most quietly pervasive worry is often miles away: our aging parents.
Over 40% of seniors experience chronic loneliness, but statistics don't capture the daily guilt of an adult child who realizes it's been three days since they called home. We know AI will never replace a child's love, nor can it replace human medical care. If someone is having a genuine medical issue, human intervention is the only answer.
But what about the days in between? What about the mundane Tuesday mornings?
We built ClaraCare not as a caretaker replacement, but as a bridge, a way for our generation to keep a gentle, loving, daily pulse on our parents amidst our busy lives. A tool to ensure they never feel forgotten, and to give us the peace of mind that today, Mom is doing just fine.
ClaraCare is an AI-powered voice companion named Clara that calls elderly adults daily for warm, natural check-in conversations. Behind every call, a cognitive analysis engine silently tracks linguistic biomarkers over time β vocabulary diversity, topic coherence, repetition patterns, response latency β and alerts family members the moment something changes.
Clara doesn't feel like a medical tool. She feels like a friend calling to chat about the garden, the grandkids, or what's for lunch. But under the hood, every conversation builds a longitudinal cognitive profile that can detect decline months before traditional screening.
π Clara calls Mark every morning
β
π£οΈ They chat about his day, meals, medications
β
π§ NLP engine analyzes vocabulary, coherence, pauses, sentiment
β
π Metrics compared against Mark's personal baseline
β
π¨ Family gets alerts if patterns deviate
β
π Daily wellness digest emailed to family members
β
π Monthly cognitive health report generated as a PDF
Every conversation generates a cognitive fingerprint β a snapshot of how the patient's language patterns compare to their own baseline. ClaraCare doesn't compare against population averages; it learns each patient's normal and watches for their changes.
graph TB
subgraph "Voice Layer β Deepgram Voice Agent API"
direction LR
Phone["π Phone Call<br/>(Twilio Media Streams)"]
Listen["π€ Listen<br/>(Deepgram Nova-3)"]
Think["π§ Think<br/>(OpenAI GPT-4o-mini)"]
Speak["π Speak<br/>(Deepgram Aura-2 Thalia)"]
Phone <-->|"WebSocket<br/>mulaw 8kHz"| Listen
Listen -->|"Transcript"| Think
Think -->|"Response"| Speak
Speak -->|"Audio"| Phone
end
subgraph "Function Calling β During Live Conversation"
direction LR
FC["π οΈ Clara's Tools"]
F1["π log_medication_check"]
F2["π΅ search_nostalgia<br/>(You.com API)"]
F3["π search_realtime<br/>(You.com API)"]
F4["π¨ trigger_alert"]
F5["πΎ save_conversation"]
F6["π get_patient_context"]
FC --- F1 & F2 & F3
FC --- F4 & F5 & F6
end
subgraph "Post-Call Analysis Pipeline"
direction LR
DG["π Deepgram Text Intel<br/>(Sentiment, Topics, Intents)"]
Gemini["β¨ Gemini 3 Flash<br/>(Summary + Highlights)"]
NLP["π§ Cognitive Analyzer<br/>(spaCy + sentence-transformers)"]
Baseline["π Baseline Tracker<br/>(Rolling 30-day window)"]
DG --> NLP
Gemini --> NLP
NLP --> Baseline
end
subgraph "Intelligence Layer"
direction LR
Alerts["π¨ Alert Engine<br/>(Consecutive Trigger<br/>+ Deduplication)"]
Digest["π Wellness Pipeline<br/>(Digest + Recommendations)"]
Alerts --- Digest
end
subgraph "Data & Notifications"
direction LR
Sanity["πΎ Sanity CMS<br/>(GROQ Queries)"]
Email["π§ SMTP Notifier<br/>(aiosmtplib + Jinja2)"]
PDF["π Foxit Document Gen API<br/>(PDF Reports)"]
end
subgraph "Family Dashboard β Next.js 15 on Vercel"
direction LR
Pages["π± Dashboard Pages<br/>β’ Home & Digest<br/>β’ Conversations<br/>β’ Cognitive Trends<br/>β’ Alert Management<br/>β’ Settings"]
end
Think <-->|"Function Calls"| FC
F5 -->|"Transcript"| DG
F5 -->|"Transcript"| Gemini
F4 -->|"Real-time"| Alerts
Baseline -->|"Deviations"| Alerts
NLP -->|"Metrics"| Digest
Digest -->|"Store"| Sanity
Alerts -->|"Store"| Sanity
Alerts -->|"Instant Alert"| Email
Digest -->|"Daily Digest"| Email
Digest -->|"Monthly Report"| PDF
Sanity <-->|"REST API"| Pages
style Phone fill:#f8fafc,stroke:#3b82f6,stroke-width:2px
style Think fill:#f8fafc,stroke:#8b5cf6,stroke-width:2px
style NLP fill:#f8fafc,stroke:#10b981,stroke-width:2px
style Alerts fill:#f8fafc,stroke:#ef4444,stroke-width:2px
style Sanity fill:#f8fafc,stroke:#f59e0b,stroke-width:2px
style Pages fill:#f8fafc,stroke:#06b6d4,stroke-width:2px
sequenceDiagram
participant P as π Patient
participant T as π‘ Twilio
participant D as π€ Deepgram Voice Agent
participant G as π§ GPT-4o-mini
participant A as π Post-Call Pipeline
participant S as πΎ Sanity CMS
participant F as π¨βπ©βπ§ Family
participant PDF as π Foxit API
P->>T: Answers daily call
T->>D: WebSocket audio (mulaw 8kHz)
D->>G: Transcript β conversational AI
G->>D: Response text
D->>T: Synthesized speech (Aura-2)
T->>P: Hears Clara's voice
Note over G: Function calls during conversation:<br/>medication check, nostalgia search,<br/>alert trigger, save conversation
G->>A: save_conversation (end of call)
A->>A: Deepgram Text Intel (sentiment, topics)
A->>A: Gemini 3 Flash (summary, highlights)
A->>A: spaCy + sentence-transformers (metrics)
A->>A: Compare to personal baseline
alt Deviation Detected (2+ consecutive)
A->>S: Generate alert
S->>F: π¨ Instant email notification
end
A->>S: Save conversation + wellness digest
S->>F: π Daily summary email
A->>PDF: Generate Cognitive Report (HTML->PDF)
PDF->>F: π Monthly health report
F->>S: View dashboard & trends
Clara speaks with warmth and patience through the Deepgram Voice Agent API. She remembers what the patient talked about yesterday, asks about their garden, and gently checks if they took their medications. The conversation feels human β not clinical.
Every conversation is analyzed across 5 key linguistic dimensions using spaCy and sentence-transformers:
| Metric | What It Measures | Why It Matters |
|---|---|---|
| Vocabulary Diversity | Range of unique words used | Shrinking vocabulary is an early dementia indicator |
| Topic Coherence | How smoothly topics flow | Sudden jumps may signal confusion |
| Repetition Rate | Frequency of repeated stories/phrases | Increased repetition suggests memory difficulty |
| Word-Finding Pauses | Hesitations while searching for words | More pauses can indicate cognitive strain |
| Response Latency | Time to respond to questions | Slower processing may reflect cognitive changes |
ClaraCare builds a personal cognitive baseline from each patient's first 7+ conversations, then monitors deviations from their normal using a rolling 30-day window. No generic population benchmarks.
Alerts only fire after 2+ consecutive conversations show deviation, reducing false positives. Each alert includes:
- A warm, non-clinical description of what changed
- A specific suggested action for the family
- Severity classification (Low / Medium / High)
- Deduplication β same alert type won't fire twice until acknowledged
Families receive a formatted email digest after each call with:
- Conversation summary in warm, family-friendly language
- Mood assessment and conversation highlights
- Medication adherence tracking
- Actionable recommendations
Families can download beautiful PDF reports generated via Foxit PDF Services APIs. The reports map long-term cognitive trends and include an executive summary authored by Gemini 3 Flash.
Using the You.com Search API, Clara can find music, news, and cultural references from the patient's "golden years" (ages 15β25) to spark engaging conversations and stimulate long-term memory recall.
A Next.js 15 dashboard (deployed on Vercel) where family members can:
- View conversation history with mood indicators
- Track cognitive trends over time with interactive charts
- Manage alerts (unreviewed alerts surface first)
- Configure notification preferences and download Foxit-generated reports
| Layer | Technology | Purpose |
|---|---|---|
| Phone | Twilio Media Streams | Inbound/outbound calls via WebSocket |
| Voice Agent | Deepgram Voice Agent API | End-to-end voice pipeline (listen β think β speak) |
| STT | Deepgram Nova-3 | Speech-to-text transcription |
| Conversation AI | OpenAI GPT-4o-mini | Clara's persona, function calling, dialogue |
| TTS | Deepgram Aura-2 (Thalia) | Natural text-to-speech voice |
| Post-Call Summary | Google Gemini 3 Flash | Conversation summarization & wellness highlights |
| NLP | spaCy + sentence-transformers | Cognitive metric extraction (vocab, coherence, etc.) |
| Text Analysis | Deepgram Text Intelligence | Sentiment analysis, topic detection, intent recognition |
| Database | Sanity CMS (GROQ) | Structured content store with real-time queries |
| aiosmtplib + Jinja2 | Alert & digest email delivery | |
| Search | You.com API | Nostalgia mode & real-time information retrieval |
| PDF Reports | Foxit Document Generation API | Dynamically creates health reports for families |
| Dashboard | Next.js 15 + Tailwind CSS | Family-facing web application |
| Backend | FastAPI (Python 3.11+) | REST API & WebSocket server |
| Deployment | Docker + Kubernetes (Linode LKE) | Production backend hosting |
| Frontend Hosting | Vercel | Dashboard auto-deploy from git |
clara-care/
βββ backend/ # FastAPI backend
β βββ app/
β β βββ main.py # Application entry point & API routes
β β βββ voice/ # Voice agent layer
β β β βββ agent.py # Deepgram Voice Agent WebSocket handler
β β β βββ functions.py # 6 function call handlers (meds, nostalgia, alerts, etc.)
β β β βββ outbound.py # Initiating calls via Twilio
β β β βββ persona.py # Clara's personality prompt & greeting
β β βββ cognitive/ # Post-call cognitive analysis
β β β βββ analyzer.py # spaCy + sentence-transformers linguistic analysis
β β β βββ pipeline.py # End-to-end analysis orchestrator
β β β βββ baseline.py # Personal baseline tracking (rolling 30-day window)
β β β βββ alerts.py # Alert engine (consecutive triggers + dedup)
β β β βββ post_call_analyzer.py # Deepgram Text Intel + Gemini summary
β β βββ reports/ # PDF Generation
β β β βββ generator.py # Health report PDF generation engine
β β β βββ foxit_client.py # Integration with Foxit APIs
β β βββ nostalgia/ # You.com-powered nostalgia engine
β β βββ storage/
β β β βββ sanity.py # Sanity CMS client (GROQ queries + mutations)
β β βββ notifications/
β β βββ email.py # SMTP email sender (aiosmtplib)
β β βββ templates/ # Jinja2 email templates (digest, alerts)
β βββ scripts/ # Migration & utility scripts
β βββ tests/ # Test suite
β βββ Dockerfile
βββ dashboard/ # Next.js 15 family dashboard
β βββ src/
β βββ app/
β β βββ page.tsx # Landing page
β β βββ dashboard/ # Dashboard routes (home, history, trends, alerts)
β βββ components/ # React components (AlertCard, DigestPanel, etc.)
β βββ lib/ # API client, utilities, types
βββ studio-claracare/ # Sanity Studio (CMS admin)
β βββ schemaTypes/ # Content schemas (patient, conversation, alert, wellnessDigest)
βββ k8s/ # Kubernetes deployment manifests
βββ docs/ # Documentation
- Python 3.11+
- Node.js 18+
- Docker (for deployment)
git clone https://github.com/rajeev-chaurasia/clara-care.git
cd clara-care/backend
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txtcp .env.example .envRequired API keys:
DEEPGRAM_API_KEYβ Voice agent (STT, TTS, and conversational AI)OPENAI_API_KEYβ GPT-4o-mini for conversation (via Deepgram Voice Agent)GEMINI_API_KEYβ Post-call summarization & highlightsTWILIO_ACCOUNT_SID,TWILIO_AUTH_TOKENβ Phone callsSANITY_PROJECT_ID,SANITY_DATASET,SANITY_TOKENβ DatabaseSMTP_HOST,SMTP_PORT,SMTP_USER,SMTP_PASSWORDβ Email notificationsFOXIT_API_KEYβ PDF report generationYOUCOM_API_KEYβ Nostalgia mode & real-time search
python3 -m app.mainServer starts at http://localhost:8000. For Twilio webhooks, expose via ngrok:
ngrok http 8000cd ../dashboard
npm install
npm run devDashboard available at http://localhost:3000.
# Build & push backend
docker build --platform linux/amd64 -t your-registry/claracare-backend:latest backend/
docker push your-registry/claracare-backend:latest
# Deploy to Kubernetes
kubectl apply -f k8s/| Document | Description |
|---|---|
| Project Overview | Product vision & market fit |
| Architecture | Detailed system design |
| API Setup | Getting your API keys |
| Sanity CMS | Database schema & setup |
| You.com Integration | Search & Nostalgia APIs |
