🧠 MindMirror — Because Your Mind Deserves to Be Heard
💡 Inspiration
Mental health is the silent crisis of our generation. Over 1 billion people worldwide live with a mental health condition, yet 75% never receive treatment — not because they don't want help, but because therapy is expensive, stigmatized, or simply unavailable.
I wanted to build something that fills that gap. Not a replacement for therapy, but a daily emotional companion that listens without judgment, helps you understand your own patterns, and gently guides you using real, evidence-based psychology — Cognitive Behavioral Therapy (CBT).
Most wellness apps show you today's mood. MindMirror shows you your emotional story over time.
🔍 The Problem
- Therapy costs $100–$300 per session — unaffordable for most students
- Generic chatbot wellness apps feel scripted and hollow
- People don't recognize their own emotional patterns and triggers
- There's a massive gap between "I feel bad" and "I understand why I feel bad"
✅ The Solution
MindMirror is a full-stack AI web application that combines:
- 📓 Daily voice or text journaling with real-time emotion detection
- 🤖 CBT-informed AI companion powered by Ollama
- 📊 Emotional Map Dashboard — a 30-day visualization of your mental wellness
- 🔍 Cognitive Distortion Detection — identifies patterns like catastrophizing, all-or-nothing thinking, and emotional reasoning
- 🚨 Smart Alerts — detects 3+ consecutive days of low sentiment and sends a gentle nudge to seek support
🧠 How the CBT AI Works
The AI follows a strict 5-Step CBT Framework on every interaction:
Step 1 — Identify cognitive distortions in the user's language
Step 2 — Validate the emotion before any reframing
Step 3 — Reframe gently using Socratic questioning
Step 4 — Ground with breathing or mindfulness techniques if needed
Step 5 — Close with warmth and one small, actionable step
Example distortions detected:
Catastrophizing → "I know everything will fall apart" All-or-nothing → "I always fail at everything" Mind reading → "They must hate me" Emotional reasoning → "I feel worthless so I must be"
🛠️ How I Built It
Key Technical Decisions
- Ollama — powers the CBT companion with a deeply engineered system prompt that injects user's emotional history as context
- distilroberta-base (HuggingFace) — classifies 7 emotions per journal entry: joy, sadness, anger, fear, disgust, surprise, neutral
- Supabase — stores journal entries, chat history, emotional patterns, and weekly insights with PostgreSQL
- OpenAI Whisper — transcribes voice journal entries to text
- Server-Sent Events (SSE) — streams AI responses in real time for a natural conversation feel
- Recharts + D3.js — renders the emotional map dashboard with sentiment timelines, radar charts, and mood heatmaps
📊 Features at a Glance
| Feature | Description |
|---|---|
| 📓 Journal | Voice or text entry with instant emotion analysis |
| 🤖 AI Chat | CBT-informed streaming conversation with context memory |
| 📈 Sentiment Timeline | 30-day line chart of emotional scores |
| 🕸️ Emotion Radar | Weekly radar chart of all 7 detected emotions |
| 🗓️ Mood Heatmap | GitHub-style calendar of daily emotional scores |
| 🔍 Pattern Detection | Auto-detected triggers, cycles, and growth moments |
| 💡 Weekly Insight | AI-generated weekly CBT recommendation |
| 🚨 Gentle Alerts | Nudge when 3+ days of declining mental wellness detected |
🚧 Challenges I Faced
1. Context Memory Without Hallucination
Getting LLM to remember past emotional history without making up details
required careful prompt engineering — injecting structured summaries from the
database rather than raw chat logs.
2. Emotion Detection Accuracy
Single-model sentiment wasn't nuanced enough. I combined a dedicated
emotion classification model with keyword-based cognitive distortion detection
for layered accuracy.
3. Streaming + State Management
Implementing SSE streaming responses while keeping the chat state synchronized
across React required careful handling of ReadableStream and useState hooks.
4. Not Crossing the Line
The hardest challenge was designing an AI that is genuinely helpful for mental
wellness without ever diagnosing, prescribing, or replacing professional care.
Every response is engineered to validate, reframe, and refer.
📚 What I Learned
- How to engineer production-grade CBT-informed LLM system prompts
- Emotional NLP using transformer-based models beyond basic sentiment
- Longitudinal data pattern detection across time-series emotional data
- The importance of ethical guardrails when building health-adjacent AI tools
🚀 What's Next
- 📱 React Native mobile app for on-the-go journaling
- 🔗 Optional therapist dashboard — share insights with your actual therapist
- 🌍 Multi-language support for global accessibility
- 🧬 Personalized CBT exercise library based on detected distortion patterns
⚠️ Disclaimer
MindMirror is not a medical device and does not provide clinical diagnosis or treatment. It is a wellness support tool. Users experiencing serious mental health concerns are always encouraged to seek professional help.
Crisis resources: If you or someone you know is in crisis, please contact a local mental health helpline immediately.
Built With
- d3.js
- docker
- fastapi
- huggingface-transformers
- next.js
- ollama
- openai-whisper
- postgresql
- python
- recharts
- server-sent
- supabase
- tailwind-css
- typescript

Log in or sign up for Devpost to join the conversation.