GARAGE · CASE STUDY 03 / 05 ◄ Back to the garage All work

React Native · Express · PostgreSQL

Conversa

Rehearse real conversations with an AI partner, then practise with real people.

Built solo · 511 commits · 700+ automated tests · private repo · conversa.swiip.app

Why
Learners freeze in real conversations because they never get to rehearse them; Conversa lets them practise a scene with an AI partner first, then talk to real people at their level.
My role
Built it alone: the React Native app, the Express API on PostgreSQL, the AI scene engine with its guardrails, and the voice, corrections and level-check features.
Result
12 role-play scenes by voice or text with live corrections and a scored debrief, verified levels, a mistake book and practice partners, in 21 interface languages. 511 commits, 700+ automated tests.
  • React Native
  • Express
  • PostgreSQL
  • LLM guardrails
  • Socket.IO
  • RevenueCat
Conversa on the turntable in the garage on the home page

What I built, in one look

  1. 01Layered guardrails for AI role-play
  2. 02Corrections that cannot lie
  3. 03Quota-safe scene starts
  4. 04Voice turns with real checks
  5. 05Hardened monetization endpoints
Read how each one works ►

How it fits together

  1. React Native appFive tabs, voice or text
  2. Express 5 APIFeature modules, Zod-validated input
  3. Scene engineLocked starts, JSON turns, one debrief call
  4. GuardrailsPatterns, the model's flag, a classifier
  5. PostgreSQL + PrismaAttempts, corrections, mistake book

What it does

Conversa gets you ready for real conversations in another language. You rehearse everyday situations with an AI role-play partner, get corrected while you speak, and then practise with real learners whose levels are verified.

A scene is a short situation with goals: ordering at a café, checking in at the airport, describing symptoms to a doctor, renting a flat, getting through a job interview. You speak or type; the AI plays the barista, the receptionist or the interviewer, and it is always labelled as an AI practice partner. Corrections appear while the scene runs, a hint helps when you are stuck, and the scene ends with a scored debrief on goal, accuracy and fluency, plus the corrections worth keeping. Every correction from scenes and chats lands in a mistake book.

Language levels on profiles come from a short level check, not from what people type in. On the Partners tab you see learners grouped by how your languages fit, and you send a practice request with a topic and a first message. Partners can correct each other’s messages in the chat, and you can ask the AI coach about anything you wrote. The interface runs in 21 languages, including right-to-left Arabic, and scenes are available for 11 languages you can learn.

Key features

  • 12 AI role-play scenes in four categories (Everyday, Travel, Work, Health), by voice or text, each with goals, live corrections and hints.
  • A scored debrief at the end of every scene: goal, accuracy and fluency, what went well, and the corrections to remember.
  • A mistake book that collects corrections from scenes and chats, filtered by type (article, spelling, tense, word choice, register).
  • Verified levels from a short AI-graded level check, shown on profiles and used to group partners.
  • Practice requests with a topic and an opening message; partners correct each other in the chat, and “Ask the coach” explains any message.
  • Romanised readings (romaji, pinyin and others) under corrections for languages with a non-Latin script.
  • Safety by design: adults only, input and output filtered for sexual content, AI features behind an explicit consent, and every AI message or person can be reported or blocked.
  • Conversa Plus unlocks every scene, more turns per scene and the full debrief; the free tier plays one scene a day.

How it’s built

React Native appAI role-play scenesExpress 5 APISocket.IO chatScene engineGuardrailsDebrief & mistake bookPostgreSQL + PrismaLLM provider layer product machinery

The system has two repositories: an Expo / React Native client and a TypeScript Express 5 API on PostgreSQL through Prisma 7. The API is organised as feature modules behind /api/v1; the scene engine lives in modules/scenarios and the scenario* files in src/lib.

Each scene turn is one model call that returns JSON: the in-character reply, an optional correction, the goal criteria met so far and a safety flag. scenarioParse.ts reads that output defensively. Broken or uncertain output never produces a correction; a parse failure is retried once and then falls back to a plain reply, and every model-written text a user can see passes an output guard first. Guardrails run in layers, cheapest first (scenarioGuardrails.ts): deterministic multilingual patterns and the app-wide content filter, then the model’s own flag, then an optional classifier call that can only escalate. A sexual turn is redirected once and ends the scene the second time, and a blocked reply is replaced by a fixed out-of-character line.

Starting a scene reserves the attempt under a per-user advisory lock (scenarios.ts). The resume check, the daily quota count and the insert are one atomic step, so two parallel starts cannot both pass the free tier’s one scene a day or both pay for a model call; if the opening line fails, the reservation is deleted and no quota is used. Voice turns (modules/scenarios/voice.ts) check the real audio type and duration, reject silent recordings, and send the transcript through the same turn path as typed text. The debrief is one model call at the end. The full version is always stored and the free cut happens when it is served, so a learner who upgrades later sees the full debrief of earlier scenes (scenarioDebrief.ts).

Chat corrections are written as a separate line and never change the message itself (corrections.ts), so the history stays true and the learner sees exactly what changed. Socket.IO shares the REST session model: the handshake token is hashed and looked up the same way as a REST request. On mobile, Expo Router 6 provides file-based navigation with five tabs (Today, Scenarios, Partners, Chats, Progress), React 19 and React Native 0.81, i18next with 21 interface languages, and expo-audio for voice turns. A GitHub Actions workflow bumps versions, builds the Android bundle with Gradle and sends the iOS build through EAS to TestFlight.

Tech stack

Mobile
  • React Native 0.81
  • Expo SDK 54
  • Expo Router 6
  • React 19
  • TypeScript
  • Reanimated 4
  • expo-audio (voice turns)
  • i18next (21 interface languages, right-to-left Arabic)
Auth
  • One-time email codes (HMAC-hashed)
  • Google Sign-In (`@react-native-google-signin/google-signin`)
  • Sign in with Apple (`expo-apple-authentication`)
  • hashed session tokens
Backend
  • Node.js (ESM)
  • TypeScript
  • Express 5
  • Zod 4
  • Helmet
  • express-rate-limit
  • Multer
  • Nodemailer
AI scenes
  • one provider layer (OpenRouter, OpenAI) with a model per task
  • JSON turns parsed defensively
  • layered guardrails (multilingual patterns, the model's own flag, an optional classifier)
  • speech transcription with duration and silence checks
  • every AI message can be reported
Realtime
  • Socket.IO 4 (server and `socket.io-client`)
  • token-authenticated handshake
  • typing and live-update events
Data
  • PostgreSQL 16
  • Prisma 7 (`@prisma/adapter-pg`)
  • per-user advisory locks for quota-safe scene starts
Storage & media
  • S3 API via `@aws-sdk/client-s3` with presigned URLs
  • self-hosted MinIO
  • Sharp
  • magic-byte checks on image and audio uploads
Payments & ads
  • RevenueCat (`react-native-purchases`, webhooks, REST reconciliation)
  • Google AdMob with server-side verification of rewarded ads
Notifications
  • Expo push (`expo-notifications`, `expo-server-sdk`)
Infra
  • Docker (multi-stage, Node 24 Alpine)
  • Docker Compose
  • Caddy reverse proxy
  • shell-based watchdog
  • health and backup scripts
  • EAS Build
Testing & CI
  • Vitest and Supertest against a real PostgreSQL database (700+ tests)
  • GitHub Actions release pipeline (Gradle bundle, EAS build with TestFlight submit)

Engineering highlights

  • Layered guardrails for AI role-play. Cheap deterministic patterns first, then the model’s own flag, then an optional classifier that can only escalate; a blocked line becomes a fixed out-of-character reply, and any AI message can be reported into the same human review queue with a transcript snapshot. conversa-backend/src/lib/scenarioGuardrails.ts, conversa-backend/src/modules/scenarios/report.ts
  • Corrections that cannot lie. Model output is parsed field by field; anything uncertain is dropped rather than shown, and the learner’s own text is never rewritten in place. conversa-backend/src/lib/scenarioParse.ts, conversa-backend/src/lib/corrections.ts
  • Quota-safe scene starts. A per-user advisory lock makes the resume check, the quota count and the insert one step, and a failed opening line releases the reservation, so the free tier cannot be raced and a failed model call never costs a scene. conversa-backend/src/lib/scenarios.ts, conversa-backend/src/lib/scenarioQuota.ts
  • Voice turns with real checks. The upload’s real audio type, its duration and silence are checked before transcription, and the transcript then goes through the same turn path as text. conversa-backend/src/modules/scenarios/voice.ts, conversa-backend/src/lib/voiceChecks.ts
  • Hardened monetization endpoints. RevenueCat webhooks are checked with a constant-time secret comparison, and rewarded ads are credited only after AdMob’s ECDSA-signed server-side verification callback. conversa-backend/src/modules/webhooks/routes.ts, conversa-backend/src/lib/admobSsv.ts