Zero Cloud Backend, Full Local Voice Immersion#
Most web apps mirror every feature behind hosted database tables and metered API gateways. In Phase 3 of SpeakOn, we integrated the entire language tutor workspace (aldeon.app/speakon/* and speakon.aldeon.app) inside aldeon/app (develop) with zero api.*.ts endpoints and zero server-side fetches to localhost.
Every page renders cleanly on the server for SEO and accessibility, while authenticated voice turns, Ollama model discovery, history, streaks, and mobile QR pairing communicate strictly from the learner's browser directly to their local 127.0.0.1:8000 FastAPI orchestrator.
Typed Browser Client & Safe React Router 7 Hydration#
- OpenAPI Type Generation (
schema.d.ts): Runningopenapi-typescriptagainstspeakon-services/openapi.jsonkeeps request payloads and responses synchronized with FastAPI without hand-maintained DTOs. Becausealdeon/apprunstypescript@7.0.2, generating the declaration file isolatestypescript@5.8.3insidespeakon:typesso both OpenAPI codegen and native TypeScript 7 typechecking succeed cleanly. - Rotating Refresh Sessions & Authenticated WAV Playback (
api/client.ts): Wrappingopenapi-fetchwith single-flightPOST /api/auth/refreshrecovery prevents concurrent 401 storms, whilefetchAudioBlobUrl()attaches Bearer credentials cleanly so private WAV tutor clips play back without exposing tokens in query parameters. - Strict SSR Safety (
SpeakOnContext.tsx): Server renders never touchlocalStorageduringuseState(...)initialization; persisted server URLs and rotating session tokens hydrate safely insideuseEffect.
Push-to-Talk & 16 kHz AudioWorklet Hands-Free Streaming#
The SpeakOn workspace supports two complementary low-latency capture paths:
- Push-to-Talk (
lib/pttRecorder.ts): Captures compressed browser audio viaMediaRecorder, renders real-time microphone RMS waveform bars fromAnalyserNode, and posts multipart audio directly toPOST /api/sessions/{id}/turn. - Hands-Free WebSocket (
public/speakon-pcm-worklet.js&lib/voiceWs.ts): Loads anAudioWorkletProcessorthat resamples browser audio to16000 HzmonoInt16Arrayin512-sample (1024-byte) frames matching Silero VAD's exact server frame size. Incoming WAV chunks queue seamlessly inside WebAudio (WebAudioPlaybackQueue), while hitting Interrupt / Stop Audio sends{ type: 'cancel' }and clears active audio immediately for natural barge-in.
Multilingual UI, Mandarin Pinyin & Security Guardrails#
- Two-Tier Language Picker: Features English, Spanish, and Mandarin Chinese upfront, groups Portuguese, German, Italian, and French under collapsible All Languages, and adds a dedicated Mandarin tone-colored Pinyin / Hanzi toggle alongside collapsible grammar corrections and word confidence breakdowns.
- Browser Permissions & Subdomain Routing (
vercel.json): Adds thespeakon.aldeon.app308 redirect rules and scopesPermissions-Policy: camera=(), microphone=(self), geolocation=()strictly to/speakonand/speakon/(.*)while leaving global camera/mic locked down elsewhere. - No
innerHTML, No Passwords: Mobile QR codes generated viaPOST /api/pairing/startrender strictly through an image element bound to theqr_svg_data_uridata URI, and password inputs are banned and asserted absent inspeakon.test.ts.
Verification, Bundle Budgets, and Live Integration Smoke#
- Typecheck, Lint & Tests:
bun run checkpassedreact-router typegen && tsc,biome lintacross 582 files, and 225 / 225bun testunit, AST i18n-parity, SEO/GEO, and SSR safety checks. - SSR & Performance Budget:
bun run verify:ssrverified client bundle security rules and 218 production SSR renders cleanly;bun run perf:budget:strictkeptSpeakOnLandingPageat188.9 KBgzipped JS (budget220 KB) and44.4 KBgzipped CSS (budget45 KB). - Live E2E & DNS Gate 3: Verified live
OPTIONSCORS + Private Network Access preflight (https://aldeon.app -> http://127.0.0.1:8012), live HTTP 200 renders across all 7 workspace/onboarding routes, Mailpit passwordless OTP authentication, and realen,es, andzhturns producing valid audio and tone-marked Pinyin—plus verifiedspeakon.aldeon.appwildcard resolution with intact Resend MX/SPF/DKIM records.
Next up in Phase 4: building the native mobile client in speakon/mobile/ using Expo Prebuild (CNG), expo-sqlite offline cache, USB adb reverse, and LAN QR pairing.
