Engineering BlueprintReact RouterTypeScriptExpoSkiaSQLiteFSRSMandarinSpeakOn

SpeakOn Phase 6: Mandarin Studio on Web & Mobile, Skia Calligraphy, and Offline SQLite Packs

Shipping Mandarin Studio across React Router 7 Web (6 SSR routes, lazy hanzi-writer, 192.3 KB gz landing JS) and Expo Mobile (60fps Skia calligraphy canvas…

Célio Vieira475 words3 min read

Key Takeaways (TL;DR)

Summary
  • Two Clients, One Local-First Mandarin Curriculum — In Phase 6 of SpeakOn, we brought the backend engines built in Phase 5 (Celio1878/speakon-services) to learners across…
  • Zero-Backend Web Studio Inside React Router 7 (aldeon/app) — Staying faithful to Aldeon's strict client-only web boundary, all six new routes under /speakon/studio* (Hub…
  • Native Skia Calligraphy & expo-sqlite Airplane-Mode Learning (speakon/mobile) — On mobile, learning cannot stall when cellular or Wi-Fi drops:
  • Verification Highlights — On Celio1878/speakon-mobile, strict tsc --noEmit reported 0 errors, Bun tests passed 14 / 14 (131 expectations across 5 suites, backed by real…

Two Clients, One Local-First Mandarin Curriculum#

In Phase 6 of SpeakOn, we brought the backend engines built in Phase 5 (Celio1878/speakon-services) to learners across both Web (Celio1878/aldeon.app, commit 51c4d5a on develop) and Mobile (Celio1878/speakon-mobile, commit 3ca90fa on develop)—with bilingual English / Brazilian Portuguese guidance, Simplified / Traditional switching, tone-colored Pinyin, and progressive Pinyin fade-out (full -> hover -> hanzi).

Both apps share identical deterministic stroke-matching math (strokeMatcher.ts) and state-machine transitions (pinyinFade.ts), plus seamless two-way handoffs: any CJK turn in Talk opens directly inside Dissect or Write, and any practiced phrase in Studio launches directly into a live voice turn (?practice=...).

Zero-Backend Web Studio Inside React Router 7 (aldeon/app)#

Staying faithful to Aldeon's strict client-only web boundary, all six new routes under /speakon/studio* (Hub, Foundations, Write, Read, Lab, and Review) talk exclusively to the user's configured local desktop orchestrator (http://127.0.0.1:8000):

  • Bundle Budget Discipline: Adding interactive calligraphy can easily bloat landing chunks. Importing hanzi-writer@3.7.3 (MIT) dynamically inside client-only interaction handlers and routing charDataLoader straight to /api/mandarin/chars/{char} kept the landing JS bundle at 192.3 KB gz (strict budget 220 KB) and CSS at 44.7 KB gz (budget 45 KB).
  • SSR & Check Suite: All 230 production SSR renders passed cleanly, Biome checked 592 files with zero warnings, and the Web unit suite expanded to 227 pass / 0 fail (2,311 assertions across 21 files).

Native Skia Calligraphy & expo-sqlite Airplane-Mode Learning (speakon/mobile)#

On mobile, learning cannot stall when cellular or Wi-Fi drops:

  • 60fps Skia Tianzige Canvas (SkiaHanziCanvas.tsx): Built on @shopify/react-native-skia (Canvas, Path, Skia) and PanResponder—locking parent ScrollView pan interference during active finger strokes via onDrawStateChange—supporting guided, ghost, and blank stroke-order quizzes with expo-haptics pulse feedback plus freehand DTW character lookup.
  • WAL Co-Residency Without Lock Contention: Initializing a single createExpoSqliteDriver() connection shared cleanly between MobileOfflineCache (sync_meta, cached turns) and MandarinOfflineStore (local ts-fsrs cards, review logs, writing attempts, queued AI prompts, and cached AI results) eliminates dual-writer WAL contention.
  • Verified SHA-256 Offline Pack Installer (mandarinPack.ts): Downloads starter (~2.7 MB) or full (~105 MB) SQLite packs via File.downloadFileAsync, verifies SHA-256 using expo-crypto before touching live storage, atomically replaces SQLite.defaultDatabaseDirectory/mandarin_pack.sqlite, and falls back to an embedded Apache-2.0 starter curriculum until synced.
  • Deterministic Offline ts-fsrs@6.0.1 Queue & Delta Sync: Ratings (Again/Hard/Good/Easy) reschedule cards immediately offline via ts-fsrs (enable_fuzz: false), queue review logs, writing accuracy scores, and AI dissect/nuance/compose prompts cleanly, and flush idempotently over POST /api/mandarin/sync when desktop connectivity returns.

Verification Highlights#

On Celio1878/speakon-mobile, strict tsc --noEmit reported 0 errors, Bun tests passed 14 / 14 (131 expectations across 5 suites, backed by real bun:sqlite), iOS and Android expo prebuild --no-install --clean exited cleanly, and Android Gradle built the full debug APK (754 actionable tasks, 189 MB app-debug.apk) with prebuilt native Skia binaries linked—all while keeping generated android/ and ios/ directories out of pure CNG Git history and scanning 0 secrets via gitleaks.

Célio Vieira

Célio Vieira

Founder & Architect

Engineering applied AI systems, distributed cloud platforms, and the Aldeon umbrella venture ecosystem.

Related Technical Dispatches

View all 90