Skip to main content

Trial & Onboarding Flow

A server-created 14-day trial and a skippable five-step profile flow.

Trial creationโ€‹

createUser in acesense-auth-function/user/index.ts seeds the user from templates/user-template.json, then writes:

  • top-level plan: "trial"
  • top-level and nested trialEndsAt timestamps, 14 days after account creation
  • a trial limits block (10 analyses, 30 video minutes, one coach link)
  • zeroed usage/performance counters

Upload authorization is server-side. requestUploadPath requires durable AI consent, treats an active trial as the premium entitlement, applies the monthly cap, and then reserves the daily/concurrent quota atomically.

Quota plan keyDaily uploadsConcurrent uploads
free / trial51
pro503
team2005

Verified Stripe, App Store, and Google Play events mirror tier (free, premium, ultimate) and a tier-specific limits block. syncTierToPlan preserves compatibility with legacy plan readers.

Onboardingโ€‹

lib/features/auth/onboarding_screen.dart currently has five screens:

  1. Choose one or more tennis goals.
  2. Choose NTRP level and dominant hand.
  3. Choose direct or encouraging coach voice.
  4. Capture a rally through the real upload flow, or skip it.
  5. Review the reveal screen and start training.

The flow can be skipped. On completion or skip, the client writes profile choices using saveUserProfile() and saveOnboardingStep() and routes home. It does not currently call completeOnboarding(), and the router does not gate the main app on onboarding.completed.

:::warning Do not rely on onboarding for authorization Onboarding fields are client-editable profile state. Entitlement, usage, trial, and account-status fields are server-owned and protected by Firestore rules. :::

Persisted fieldsโ€‹

FieldWriter
ntrpLevel, handednessFlutter saveUserProfile()
onboarding.goalsFlutter saveOnboardingStep()
onboarding.coachVoiceFlutter saveOnboardingStep()
onboarding.stepFlutter saveOnboardingStep()
plan, trialEndsAt, limitscreateUser / billing functions

Verificationโ€‹

cd acesense-frontend
flutter test test/unit/services/firestore_service_test.dart
flutter test test/unit/routing/redirect_test.dart

cd ../acesense-auth-function
pnpm test -- __tests__/user-template.test.ts __tests__/quota.test.ts