Back to Home

Case Study

Mental Health Coach

At the end of the day, you just need someone to talk to. Safety-first mental health coaching web app with LangGraph multi-agent orchestration for coaching, therapist discovery, and appointment booking.

Solo Developer
Jan 2025 – ongoing
Next.js
TypeScript
Tailwind CSS
FastAPI
PostgreSQL
pgvector
LangGraph
Docker
LangSmith
Stripe
Google OAuth

Visuals

Mental Health Coach screenshot 1
Mental Health Coach screenshot 2

Problem

Mental health support has a significant access gap. Therapy is expensive, wait times are long, and there is no structured way for people to practice coping skills between sessions. Existing apps either feel clinical and impersonal or lack safety guardrails, which makes them risky for vulnerable users.

Solution

Built a multi-agent coaching system using LangGraph that routes conversations between a coaching agent (RAG-backed with pgvector), a therapist discovery agent (via OpenStreetMap), and a booking agent for appointment emails. A dedicated SafetyGate layer runs before every response, detecting crisis language and returning emergency resources before any AI output is shown.

Impact

  • Tiered crisis detection with Swedish emergency number integration: 100% safety test pass rate across 20+ scenarios
  • Structured JSON logging with correlation IDs and LangSmith tracing for full observability of every LLM call
  • Rate limiting, exponential backoff retries, and 30s LLM timeout for production-grade resilience
  • Session-based conversation continuity so context is preserved across turns

What I Learned

  • LangGraph's stateful graph model is significantly better than linear chains for multi-turn conversations. The explicit state machine makes routing logic debuggable and testable
  • Safety gates need to run before routing, not after. Edge cases showed the router itself could be jailbroken without this ordering
  • pgvector in PostgreSQL eliminated a separate vector DB dependency; at this scale it was the right trade-off over a dedicated service like Pinecone