The Problem We Set Out to Solve
Pakistan has a mental health crisis hiding in plain sight. 240 million people. Fewer than 400 psychiatrists. The stigma around seeking help is enormous — and even for those who want help, access to affordable, confidential mental health support is nearly impossible outside of a handful of major cities.
Globally, AI-powered mental health tools were emerging — apps like Wysa, Woebot, and BetterHelp were proving that people would engage with digital mental health support. But every single one of them was built for Western audiences: English-first, culturally detached, priced in USD, and built around healthcare systems that don't exist in Pakistan.
Why AI at the Core — Not Bolted On
When we started designing ZehnOra in early 2025, we made one foundational decision that shaped everything: AI would be infrastructure, not a feature. This meant:
- GPT-4o for safety-critical interactions — crisis detection, emotional support conversations, and therapy-style AI companion. We don't compromise on model quality where user safety is at stake.
- GPT-4o-mini for high-volume structured tasks — journal summarisation, mood tagging, session summaries, homework suggestions. Cost-controlled without sacrificing quality where it matters.
- AI hardcoded into the session flow — not an optional toggle, but the connective tissue that makes the platform intelligent.
The result: every interaction on ZehnOra is contextually aware. When a client journals about sleep anxiety on Tuesday, their practitioner sees an AI-generated summary before Thursday's session. The AI remembers. The platform learns. That's what "AI-first" actually means in practice.
The Architecture We Chose — and Why
ZehnOra is built on Next.js 15 with TypeScript, Prisma ORM, MySQL, BullMQ job queues, Upstash Redis, and Twilio for video. The full stack in one sentence: a Next.js monorepo that handles everything from the user dashboard to the therapist console to the admin risk feed.
The critical technical decision was using jose over jsonwebtoken — jsonwebtoken is incompatible with Next.js 15's edge runtime. We discovered this the hard way at 2am and it cost us six hours. The lesson: always verify library edge runtime compatibility before committing to it in a production Next.js 15 project.
The Feature We're Most Proud Of: Crisis Intervention
The S3.8 Active Crisis Escalation system is the feature that matters most — and the one we spent the most time getting right. When our AI companion detects crisis language in a conversation, it doesn't just flag it. It triggers a layered response:
- Immediate in-app crisis resources surface (Umang helpline, Rozan Counselling)
- The assigned practitioner receives a real-time notification
- The conversation is flagged in the admin safety dashboard
- Follow-up protocols are triggered automatically
We use Claude's Constitutional AI specifically for crisis detection — not GPT-4o. Claude's safety training makes it measurably better at identifying distress signals in ambiguous language. When a life may depend on it, you choose the model trained hardest on harmlessness.
What We Learned Building at This Speed
42 sprints in 25 working days is an unusual pace for a production platform handling sensitive mental health data. The lessons were hard-won:
- Architecture decisions compound. Every shortcut taken in sprint 3 became technical debt by sprint 20. We paid particular attention to schema design from day one — 68 tables, cleanly normalised, with proper foreign keys and indexes.
- Test with real personas from the start. We seeded the database with 30 real test users across all roles before writing our first line of feature code. This caught integration bugs that unit tests miss.
- The payment gateway is never simple in Pakistan. Safepay is excellent — but the live merchant approval process took weeks. Plan for it.
- AI cost caps are non-negotiable. We implemented hard usage limits per tier from day one. "Unlimited AI" at GPT-4o pricing is financially catastrophic at scale.
What's Next for ZehnOra
The React Native mobile app is in active development — Android first, targeting Pakistan's dominant mobile platform. Beyond that: the wellness suite (meditation bot, habit tracking, sleep aids), white-label deployment to hospitals and NGOs, and eventually Urdu-language AI models fine-tuned specifically for Pakistani mental health context.
ZehnOra is the first product ARM Creative Solutions has shipped. It won't be the last. But it is the one that matters most — because getting mental health support right in Pakistan could change millions of lives. That's a responsibility we take seriously with every line of code we write.