DEV Community

Andriy Rukhlyadko
Andriy Rukhlyadko

Posted on

How I Built a Mental Health App Grounded in Real Psychology (Not Just Vibes)

[Most mental health apps feel generic. Calming music, breathing exercises, maybe a mood tracker. I wanted something different — an app where the AI actually understands why you feel the way you feel, not just that you do.
So I built Mental Detox — an AI-powered emotional journal with three specialized assistants: anxiety, daily stress, and sleep. Here's what I learned.
The Psychology Stack
Before writing a single line of code, I mapped out the evidence base:

CBT (Cognitive Behavioral Therapy) — identifying and reframing distorted thoughts
DBT (Dialectical Behavior Therapy) — emotional regulation and distress tolerance
Pennebaker's Expressive Writing — 40+ years of research showing that structured journaling reduces cortisol and improves psychological wellbeing
Stanley & Brown Safety Planning — crisis protocol, not just a hotline number
Cognitive Shuffle (Dr. Luc Beaudoin) — a science-backed technique to fall asleep faster by disrupting pre-sleep rumination

Each AI assistant module is built around these frameworks, not around "feeling good."
The Tech Stack

Frontend: React + Vite + Capacitor (iOS & Android from one codebase)
Backend: Node.js + Express on Render
Database: Firebase Firestore
AI: GPT-4o as the conversational core
Subscriptions: RevenueCat
Languages supported: English, Ukrainian, French, German, Spanish, Japanese

The Hardest Part
Not the code. The prompts.
Writing a system prompt that handles a user in crisis, switches languages mid-conversation, applies the right psychological technique for the right moment, and still feels like a warm human — that took months of iteration.
The crisis protocol alone went through a dozen rewrites. It now includes verified hotlines for Canada, USA, and Ukraine, with logic that activates only when genuinely needed — not at the first mention of feeling "stressed."
What I'd Do Differently
Ship faster and talk to users earlier. I spent too long perfecting features nobody asked for. The burnout test page I built as a static SEO landing page outside the React SPA? That came from actually listening to what people searched for.
Where It Stands Now
Mental Detox is live on iOS, Android, and web. Active users, zero paid subscriptions so far — which is the honest reality of early-stage consumer apps.
If you're building in the mental health space or want to talk about AI prompt architecture for sensitive use cases, I'm happy to connect.
](https://mental-detox.app)

Top comments (0)