Case Study
Velvet AI Companion
An AI emotional companion platform with an 8-archetype matching engine, behavioral progression, session isolation, and a full Android build submitted to Google Play closed testing.
What It Is
Velvet is an AI companion platform where users are matched to one of 8 distinct archetypes based on preference, gender, and identity inputs. Each archetype has a specific behavioral profile, STAGE_INSTRUCTIONS for personality progression, and conversation context injected into every OpenAI call.
The platform is live on web and submitted to Google Play as a Capacitor-wrapped Android app. It has a full test suite, session isolation for concurrent users, and a progression engine that deepens the companion's behavior at 8, 20, and 40 message thresholds.
The Engineering
8-Archetype Matching Engine
Users complete a matching flow that collects preferences, identity inputs, and communication style signals. The engine routes each user to one of 8 archetypes and loads the appropriate STAGE_INSTRUCTIONS, companion name, and behavioral context. Preferences include identity and gender expansion options.
Session Isolation
Every user session is scoped to an httpOnly cookie. Conversation history, session state, and resets are all per-user — no shared global state. 18/18 isolation tests confirm that resetting one user's session has zero effect on any other active session.
Behavioral Progression System
The companion's personality depth increases at 3 thresholds: 8, 20, and 40 messages. STAGE_INSTRUCTIONS are injected into the system prompt at each threshold, shifting tone from warm and exploratory to more personal and emotionally attuned. 78 behavior tests cover the full progression arc.
Android Build via Capacitor
The Next.js web app is wrapped as a native Android app using Capacitor. The AAB build (2.85MB) was submitted to Google Play closed testing. A VBS wrapper was written to run scheduled background tasks without visible terminal windows.
Hard Problems Solved
Session reset wiping all users
The reset endpoint was clearing a global state object instead of scoping to the requesting user's session token. During concurrent QA testing, one tester's reset wiped every active session. Fix: scoped reset to the httpOnly cookie — fully isolated per user.
22 quality tests for conversation safety
The OpenAI responses needed to stay within character and not break companion voice under edge cases. Built a 22-test quality suite covering response boundaries, character consistency, and stage transition accuracy.
Back button exiting the app on Android
The Android back button was sending users out of the app entirely instead of navigating within the companion flow. Documented as BUG-01 before Play Store submission. Session trap fix was built and committed (not yet deployed at time of submission) to be resolved before public release.
Current State
Live at emotional-companion-pi.vercel.app. Android AAB in Google Play closed testing. 78/78 behavior tests passing, 22/22 quality tests passing. Session isolation verified.