Inspiration
A daily voice ritual is the kind of product where inference cost is the business model. Most AI apps pay per user, once — a daily ritual means per-user inference that repeats every day, forever. That constraint became the product idea: an app that doesn't have an AI feature with a paywall bolted on, but an architecture where the billing tier is the inference lane. The subscription decision and the infrastructure decision are the same decision.
What it does
Future Selves is a daily voice ritual. You open the app, give today one word, and your future self leaves you a voicemail: a short transmission about the choice you're circling, a cliffhanger for tomorrow, and one specific thing to do today. Do it for thirty days and the archive becomes a portrait of who you're becoming — and of the selves you didn't become.
The two lanes:
- Free —
PREFER_ON_DEVICE, Gemini Nano via Chrome's Prompt API: ~zero marginal cost, works offline, nothing leaves the machine. - Awakened —
PREFER_IN_CLOUD,gemini-3.8-flash: better prose, and unlocks the live-voice conversation where you can speak back to your future self.
One SDK, one call site (getGenerativeModel(ai, { mode })), two lanes, and response.inferenceSource tells the user which one served them — persisted on the row and shown as a pill: "On your device" or "Firebase." Tap the pill and you get the session's inference log: every request, the lane that actually served it, the model, the latency, and whether App Check, the Prompt API and the origin trial are in place. The claim is checkable, per request, not a line in a README.
How we built it
Everything generative goes through Firebase AI Logic. Nothing else is called.
apps/default/lib/firebase-ai.ts— one hybrid model factory for both text features (daily transmission, weekly synthesis), with JSON-schema constrained decoding on both sides (responseMimeTypein cloud,responseConstrainton-device) so the same parser handles either lane.apps/default/lib/firebase-tts.ts— OS speech synthesis for the free tier (which keeps the free ritual genuinely free), Gemini TTS (gemini-3.8-flash-tts) for Awakened.apps/default/lib/firebase-live.ts— Gemini Live API: Awakened users can speak back to their future self, with the cast's voice and live transcription. This is the feature the paywall actually sells.apps/default/lib/firebase-image.ts— cast portraits via Nano Banana.apps/default/lib/firebase.ts— app init + App Check. Production web is registered on reCAPTCHA Enterprise (Fraud Defense) and the app verifiably reaches the cloud lane on the public URL, not just the debug token path.
Design decisions worth calling out:
- The tier gate is a single boolean threaded into one function. There is no second code path for premium — the same call site takes a different
mode. That's why the paywall can be flipped live without a release, and why the free tier's cost profile is a structural property rather than a promise. - Degradation is designed, not accidental.
PREFER_*falls back silently, so a fallback that fired would look like success. The inference log exists precisely so a fallback is visible — to the user and to me. - On-device cold starts are announced. Gemini Nano is a large one-time download;
hooks/use-ondevice-readiness.tsprobesLanguageModel.availability()and streamsdownloadprogressinto the app's existing readiness UI. A hidden download is a hang. - No other AI provider is reachable in this build. I audited every call site; the pre-existing Anthropic/ElevenLabs avatar and voicemail paths are gated off in firebase mode rather than left dormant-but-live.
Design evidence, if the judges want receipts: docs/design.md is the design system written as rules (positioning, type, the letter, consequence, wait states, motion budget) with an explicit 1–2-changes-per-pass protocol; docs/craft-pass.md is the diff history against those rules, including one where the shipped code violated the spec (a 12.6-second typewriter reveal) and was measured and removed; docs/design-research.md records the comparable products whose mechanics were studied and what was deliberately not copied. The arrival surface the video shows — the generated letter, its byline, the lane line during the wait, the per-request inference panel — is the output of those documents, not a coat of paint over them.
Challenges we ran into
- The on-device lane is Chrome-desktop-only in the JS SDK. Firebase's Android/iOS on-device adapters are native (Kotlin/Swift), so a React Native app cannot reach them without writing an Expo module that wraps
firebase-ai-ondevice. I chose to submit Web only rather than ship a hybrid claim I couldn't stand behind on two platforms — the rules prefer an outstanding single-platform app to a shaky multi-platform one, and a native bridge is the documented fast follow. - Flags don't work off localhost. The Prompt API needs an Origin-Trial token on a real origin; without it
LanguageModelis undefined andPREFER_ON_DEVICEsilently becomes cloud-only. Diagnosing that silent fallback is what produced the environment block in the lane panel. - Structured output across two very different models. Nano wants a
responseConstraint; Gemini wantsresponseMimeType: application/json. Keeping one parser meant constraining both sides and testing the repair path on real malformed output. - Chrome's model download is invisible to the SDK. The first on-device request can block for minutes. Pre-warming and announcing it was the difference between "on-device AI" and "the app is broken."
- The backend had 153 TypeScript errors, and they were hiding bugs. Two root causes — an
...(authTables as any)spread that collapsed the schema's data model, and a duplicateconvexinstall — meantctx.dbwas untyped everywhere. Fixing them took the count to zero and surfaced eight real defects, two of them in this submission's own path:getStatereturned a field its validator didn't declare, and the entitlement fields (tier,voicemailCredits) never reached the client at all, so the premium gate comparedundefined. The write-up isdocs/typecheck.md.
Accomplishments that we're proud of
- The hybrid claim is verifiable, not asserted. Every generation persists the SDK-reported
inferenceSource; the lane pill and the per-request inference log show the lane that actually served, the model, and the latency. Offline in DevTools, the free ritual still completes — proof, not marketing. - The type-safety restoration: 153 → 0 TypeScript errors, eight latent bugs fixed, two of them squarely in this submission's own path (
docs/typecheck.md). - The deploy repair nobody planned for. Production turned out to be a paused deployment owned by a different account — and a paused deployment still accepts pushes, so earlier "verified" deploys were false greens. Production was rebuilt end to end: schema + 12 components, 370 rows across 20 tables imported and verified table-by-table, 11 env vars copied including a PEM private key reconstructed and proved against the deployment's own
JWKS, the RevenueCat webhook moved and re-tested to 200.docs/deploying.mdis the record. - The design convergence pass. A pre-commit guard (
scripts/verify-design-register.mjs) now enforces the lintable part of the design spec on every commit — the census of violations went 420 → 195, with every surface a judge touches fully clean, and the spec can no longer regress behind the passes. - The craft passes themselves, held to the one-surface-one-or-two-changes protocol: the letter as one typography, the arrival reveal rebuilt from 12.6s to ~1.1s, the wait line naming the inference lane, the day closing in the letter's voice with one line kept for the morning — which the next letter answers as its epigraph.
What we learned
- Silent fallback is the central UX problem of hybrid inference:
PREFER_*makes degradation invisible, so the instrumentation is the feature. - Origin trials, not flags, gate the Prompt API in production — the localhost loop teaches you the wrong thing.
- Constraining two very different models into one parser means constraining both sides and testing the repair path on real malformed output, not fixtures.
- A design spec without enforcement decays: the ratchet (block new violations in touched files, burn down the census) converged the codebase faster than any craft pass.
What's next for Future Selves
- Android + iOS beyond the JS SDK: a thin Expo module bridging
firebase-ai-ondevice(Android) and Apple Foundation Models (iOS) so on-device inference stays inside the AI Logic surface — App Check attested andinferenceSource-reporting. - Remote Config driving the tier→model map, so model churn and paywall experiments don't need a release.
- Firestore offline persistence for the ritual journal, so a check-in survives a cold offline day.
Built With
- app-check
- chrome-prompt-api
- convex
- expo.io
- firebase
- firebase-ai-logic
- gemini-nano
- react-native
- typescript