TL;DR Built the complete backend and AI system for Viaduco, a mental health iOS app. Engineered a Finite State Machine to orchestrate LLM conversations following strict CBT protocols—solving the challenge of balancing clinical rigor with natural dialogue. Deployed on AWS with Terraform, FastAPI, and Langfuse for LLMOps.

Mental health apps face a fundamental dilemma: simple LLM wrappers risk harmful responses, while rigid questionnaires kill user engagement. Viaduco needed an AI that could provide evidence-based CBT support through natural conversation—maintaining therapeutic integrity without sacrificing the human touch.

As the sole backend and AI engineer, I architected and built the entire server infrastructure from scratch. The iOS app is a thin client—all intelligence lives in my backend system.

Viaduco app screenshot 1 Viaduco app screenshot 2 Viaduco app screenshot 3 Viaduco app screenshot 4 Viaduco app screenshot 5 Viaduco app screenshot 6

The core innovation: I engineered a Finite State Machine (FSM) that orchestrates LLM conversations through psychological protocols. Each state represents a therapeutic objective with its own context, guardrails, and success criteria. The FSM ensures we follow CBT protocols strictly while the LLM makes each interaction feel personalized and alive.

I implemented dual-layer guardrails—protecting users from harmful content while constraining the AI to therapeutic boundaries. This isn’t just prompt engineering; it’s systematic safety with moderation checks (toxicity, crisis detection) and validation checks (keeping users on therapeutic track).

The technical stack: FastAPI on AWS App Runner for auto-scaling containers, PostgreSQL RDS with separated schemas for PII and session data, Infrastructure as Code via Terraform, and Langfuse for LLM observability and prompt management. The architecture ensures complete data anonymization—personal identifiers never touch behavioral data.

The result: Viaduco launched successfully on the App Store, delivering 24/7 mental health support that feels human but operates with clinical precision. We solved the core challenge—finding the sweet spot between a free-flowing chat and a rigid protocol. Users get personalized support, therapists trust the clinical framework, and the system scales infinitely.