SpeakTrue

SpeakTrue Repository: Ultimate Engineering Bible

Last updated: 2026-06-29

This document is the one-stop onboarding and operations reference for this repository for engineers joining the project or taking ownership of a specific feature area.

It is written to answer:

1) Start here before editing anything

  1. README.md
  2. docs/architecture/overview.md
  3. docs/contracts/native-speech-parity-anchor.md
  4. docs/contracts/speech-workflow-contract.md
  5. The surface inventory for the files you plan to touch:
    • docs/reference/ios-file-inventory.md
    • docs/reference/android-file-inventory.md
    • docs/reference/web-file-inventory.md
  6. Backend function behavior map:
    • docs/reference/backend-functions-detailed-map.md
    • docs/reference/backend-functions-deep-dive.md
  7. Deployment/runbook checks in docs/ops/* (especially migration and release gates)

If you are changing behavior across surfaces, do not proceed until all relevant inventories and contracts above are open.

2) System map and architectural boundaries

3) Golden docs and source-of-truth files

For any behavioral edit, these files are the canonical sources:

4) iOS app: complete surface map and edit guidance

4.1 iOS architecture map

4.2 iOS config/deploy-sensitive files

4.3 iOS change recipe (minimum required edits)

If you change Edit at minimum
TTS model/voice defaults, playback mode ios/SpeakTrue/TTSViewModel.swift, ios/SpeakTrue/TextToSpeechView.swift, ios/SpeakTrue/AIProxyService.swift, plus backend models-list, voices-list, tts-generate if payload changes
STT/STS flow behavior ios/SpeakTrue/STTViewModel.swift, ios/SpeakTrue/STSViewModel.swift, ios/SpeakTrue/SpeechToSpeechView.swift, RealtimeSTTService.swift, LiveVoiceSTSService.swift, plus backend stt-transcribe, sts-* as needed
Soundboard flow ios/SpeakTrue/SoundboardViewModel.swift, SoundboardCacheManager.swift, SoundboardCacheIndex.swift, plus backend soundboard-save-generated, soundboard-delete, clip-order-batch
Voice-clone flow ios/SpeakTrue/VoiceCloneViewModel.swift, AIDataSharingAgreementService.swift, AIDataSharingConsent* files
Settings/consent/quotas ios/SpeakTrue/UserSettings.swift, UserSettingsSyncService.swift, SettingsView.swift, SettingsTabView.swift

4.4 iOS per-file ownership references

5) Android app: complete surface map and edit guidance

5.1 Android architecture map

5.2 Android change recipe

If you change Edit at minimum
TTS models/voices/presets features/tts/data/*, features/tts/presentation/TTSViewModel.kt, features/tts/ui/TTSScreen.kt, backend functions voices-list, models-list, tts-generate, style-presets if contract changes
STT/STS flow features/stt/*, features/sts/*, backend functions stt-transcribe, sts-near-realtime-session, sts-realtime-session, sts-realtime-finalize, sts-live-voice-tts-session
Soundboard reorder / cache features/soundboard/data/*, features/soundboard/presentation/SoundboardViewModel.kt, features/soundboard/ui/SoundboardScreen.kt and backend soundboard-delete, soundboard-save-generated, clip-order-batch
Settings or agreement change features/settings/data/*, features/settings/presentation/*, features/settings/ui/*, features/agreement/*, backend user-settings-get, user-settings-update, quota-status if usage semantics changed
Billing/entitlement behavior billing-sensitive checks in core + feature screens plus backend billing functions

5.3 Android per-file ownership references

5.4 Android build/runtime sensitivity

6) Web surface map

6.1 Marketing static site (web/marketing)

Runbook: docs/ops/CLOUDFLARE_PAGES_DEPLOY.md

6.2 Legacy web runtime (web/python-web-app)

6.3 Web change recipe

If you change Edit at minimum
STT/sts/tts service behavior in web parity surface web/python-web-app/src/routes/stt.py, src/routes/tts.py, relevant src/services/*, plus compatibility seam docs in src/legacy_runtime_adapter.py and src/services/storage_provider.py
Soundboard behavior web/python-web-app/src/routes/soundboard.py, src/services/soundboard_service.py, JS audio cards/interaction JS
User settings web/python-web-app/src/routes/settings.py, src/services/user_settings_service.py, templates and JS that renders user state
Waitlist/onboarding entrypoints web/python-web-app/src/routes/voice_clone.py, src/routes/tts.py, src/services/ compatibility seam, web/marketing form scripts

6.4 Web per-file ownership references

7) Backend + SQL + migrations: what each function and migration layer does

7.1 Edge function map (critical)

Route Surface Files What it does
/account-delete auth/account lifecycle backend/supabase/functions/account-delete/* Deletes user account and server-owned resources using auth-gated contract checks.
/billing-apple-sync billing billing-apple-sync/* Sync Apple transactions into entitlement state transitions.
/billing-apple-notifications billing billing-apple-notifications/* Processes webhook payloads and applies entitlement mutation policy.
/billing-google-play-sync billing billing-google-play-sync/* Validates Play payloads and applies entitlement state updates.
/billing-stripe-webhook billing billing-stripe-webhook/* Stripe signature validation + event dispatch + persistence + policy mapping.
/bug-report-submit support bug-report-submit/* Records bug reports.
/byok-resolve, /byok-upsert settings/provider security byok-*/* BYOK config query and write APIs.
/clip-order-batch soundboard clip-order-batch/* Applies batch ordering changes with ownership checks.
/language-recommend STT/STS language-recommend/* Suggests/returns language recommendation payload.
/models-list TTS models-list/* Model catalog with policy filtering.
/voices-list TTS voices-list/* Voice catalog with entitlement/private access filtering.
/pronunciation-dictionary generation quality pronunciation-dictionary/* Pronunciation CRUD + validation.
/quota-status usage gating quota-status/* Returns quota and usage state used by clients.
/soundboard-save-generated soundboard soundboard-save-generated/* Persists generated clip metadata, bucket/key mapping, idempotence behavior.
/soundboard-delete soundboard soundboard-delete/* Deletes one or more soundboard clips with storage cleanup semantics.
/soundboard-clip-ingest migration placeholder directory scaffold Not yet implemented (routing should remain guarded until handler exists).
/stt-transcribe STT stt-transcribe/* Non-streaming transcribe request validation + capture + provider call + response normalization.
/sts-live-voice-tts-session STS sts-live-voice-tts-session/* Starts live STS voice-to-speech session contract.
/sts-near-realtime-session STS sts-near-realtime-session/* Boots near-realtime STS session context for finalization.
/sts-realtime-session STS sts-realtime-session/* Starts active real-time STS session and returns provider contract.
/sts-realtime-finalize STS sts-realtime-finalize/* Merges transcript/artifacts, finalizes metadata and artifact contract.
/sts-live-interpreter-session live interpreter scaffold index.ts only Scaffold function only.
/sts-live-interpreter-tts-session live interpreter scaffold index.ts only Scaffold function only.
/style-presets settings style-presets/* Read/update style preset data and defaults.
/tts-generate TTS tts-generate/* Core TTS validation, policy, pronunciation, provider invocation, response contract.
/user-settings-get settings user-settings-get/* Fetches settings with migration-safe defaults.
/user-settings-update settings user-settings-update/* Patch-update settings with validation and normalized response.
/voice-clone-preflight voice clone voice-clone-preflight/* Readiness and validation pass before clone creation.
/voice-clone-create voice clone voice-clone-create/* Create clone, apply provider call, persist metadata, return result.
/voice-clone-delete voice clone voice-clone-delete/* Delete user clone and provider references.
/waitlist-signup marketing ops waitlist-signup/* Stores waitlist contacts and deduplicates identity keys.

7.2 Shared backend helper modules to inspect for almost any backend edit

backend/supabase/functions/_shared/cors.ts, _shared/auth-context.ts, _shared/types.ts, _shared/usage.ts, _shared/quotas.ts, _shared/entitlements.ts, _shared/billing-entitlement-policy.ts, _shared/private-voice-access.ts, _shared/byok.ts, _shared/subscription-gating-config.ts

7.3 Backend migration inventory overview

backend/supabase/migrations includes schema/core setup through production-alignment updates:

When schema shape changes, always create/modify migration SQL and keep function contract tests and client callsite payload tests in sync.

8) Feature change matrix (what to edit across surfaces)

8.1 TTS / Voices / Models

8.2 STT / STS

8.3 Soundboard

8.4 Voice clone

8.5 Settings, quotas, agreements

8.6 Billing / entitlements

9) Deployment and verification map

9.1 Backend gates

9.2 Android gates

9.3 iOS gates

9.4 Web gates

10) Incident and support operations

When an engineer receives a behavior regression report, this is the quickest triage sequence:

  1. Identify surface from report (iOS/Android/Web/Backend).
  2. Identify changed API/function in backend map or route in web runtime.
  3. Check matching function handler and tests.
  4. Check corresponding caller files in iOS/Android inventory row.
  5. Confirm if migration touched and compare to backend/supabase/migrations and migration docs in docs/ops/MIGRATION_REGRESSION_GATES.md.
  6. Re-run focused local gate(s) before root-cause changes.

11) One-line command matrix (quick reference)

12) Canonical references

Use this as your canonical map index: