AiAdvisors
Back to case studies
//Case studies

Mental-health app for therapists.

A REST backend for a therapists' mental-health app. What began as a migration from a Telegram bot to a Flutter app grew into a full clinical platform — 40+ workflows and 30+ endpoints in production, with a therapeutic AI core, RAG per therapy method, multimodal input and case conceptualizations.

Industry
Mental health / mobile app
Timeline
2026
Outcome
40+ workflows · 30+ REST endpoints in production

The problem

A therapeutic AI assistant had outgrown its beginnings as a Telegram bot. To become a product therapists could trust with patient work, it needed a real mobile app (Flutter) and a backend built to the standards a clinical tool demands: secure authentication, a proper patient model, conversation history that holds up, careful file handling, and an AI core that can be reasoned about and maintained rather than treated as a black box.

What I built

A complete REST backend on n8n + Supabase — more than 40 workflows and 30 endpoints in production, all built and run in the agentic model:

  • A full API surface, not a prototype — the account lifecycle (registration, login, token refresh, password reset, deletion), a patient register, therapy "approaches" and their tools, chat threads and messages, and document/PDF export. Each endpoint is its own workflow — independently deployable and versioned.
  • Reusable JWT auth as shared middleware — a single authentication subworkflow validates the token on every protected endpoint, so security logic lives in one place instead of being copy-pasted across the API.
  • A therapeutic chat core with a routing layer — every incoming message is first classified and routed (which mode, which tool), then handled by a therapeutic agent with conversation memory. Answers are grounded in retrieval and written back to the patient's record.
  • RAG per therapy method — therapists add their own reference material through a guided form that tags each document to a specific therapeutic approach; the content is chunked, embedded and stored in a vector database, so the assistant responds in the context of the method actually in use.
  • Multimodal input — voice notes, images and PDFs are all accepted. Audio is transcribed (Whisper), images are read by a vision model, PDFs are parsed — each with size guards and graceful failure, never a silent drop.
  • Case conceptualizations on demand — the backend synthesizes a structured clinical conceptualization from a patient's full conversation history and saves it to their record, turning scattered sessions into a usable summary.
  • Model-agnostic by design — the AI steps run across several providers, each chosen per task and swappable, so the product isn't locked to one vendor or one price curve.
  • Engineering discipline you can audit — every workflow carries its status (reviewed, tested, documented), errors flow through one standardized pattern, data access follows the database's own row-level security, and the whole platform is backed up automatically.

The outcome

A production deployment delivered on time and with no critical bugs — and one that grew far beyond its starting point. What launched as a backend for a chat assistant became a full clinical platform of 40+ workflows, taking on new capabilities — conceptualizations, trials, multimodal input — without rewrites along the way. The reusable patterns built here, the shared JWT middleware, a standard data-access layer, file processors, are proof that the agentic build model can produce software held to professional, clinical-grade standards.

//Contact

Let's talk about AI in your business

Book a free strategic consultation and discover what AI can do for your company.

or write: romuald@aiadvisors.pl · +48 695 263 884