Delivered remotely for a business based in Barcelona, Spain. Names withheld by agreement.
Project Overview
Sustained language acquisition relies on daily short-interval recall and immediate articulation feedback—yet learners rarely sit still next to reliable broadband. Commuters review vocabulary underground, travelers practice phrases offline, and desktop learners expect their mobile streaks and memory curves to match seamlessly when they switch devices at home. Conventional cloud-tethered apps stall on spinners between flashcards or overwrite offline progress when two devices sync out of order.
To bridge mobile resilience with server-side speech intelligence, we built a cross-platform language learning application on Flutter, Python, and PostgreSQL. The Flutter client executes spaced-repetition scheduling locally over SQLite, while a Python FastAPI backend coordinates curriculum versioning, multi-device event reconciliation, and asynchronous phoneme-level pronunciation scoring.
Business Bottleneck
Prior iterations of multi-platform language tooling revealed critical friction points that drove learner drop-off:
- Fragile offline synchronization: Last-write-wins profile payloads routinely erased offline review sessions whenever a learner opened the browser portal before their phone reconnected.
- Sluggish flashcard transitions: Fetching next-card payloads over flaky mobile connections introduced noticeable pauses that broke conversational shadowing rhythm.
- Bloated media footprints: Bundling uncompressed audio inside app binaries bloated installer sizes, while streaming every clip live burned mobile data allowances.
- Unhelpful binary speech feedback: Simple pass/fail voice checks left learners guessing which vowel or consonant cluster caused misrecognition.
Architectural Strategy
We adopted an offline-first event-log architecture paired with stateless Python speech workers. Every study unit downloads as a self-contained, checksum-verified bundle comprising lesson JSON graphs and Opus audio clips indexed inside local SQLite via Drift. During drills, Flutter computes next review intervals immediately using the Free Spaced Repetition Scheduler (FSRS) algorithm without touching the network.
Every completed card review writes an append-only mutation record carrying a globally unique client event ID. When connectivity exists, background sync exchanges compact delta batches with FastAPI, which deduplicates events in PostgreSQL and returns server updates since the device's last sync cursor. Heavy acoustic analysis—forced phoneme alignment and prosody scoring—runs off the main API loop in Python worker processes fed by Redis.
Core Capabilities
- True Offline Lesson Packs: Learners download thematic units selectively, complete listening and recall drills without signal, and reclaim storage once modules finish.
- FSRS Adaptive Memory Scheduling: Tracks stability, difficulty, and retrievability per lexeme and grammar pattern to minimize redundant reviews while preventing forgetting.
- Phoneme-Level Speech Diagnostics: Captures learner recordings, aligns audio frames against expected IPA phoneme sequences, and highlights exact mispronounced syllables visually.
- Cross-Device Streak & Progress Sync: Unifies mobile and Flutter Web study timelines through monotonic sync cursors and idempotent review logs.
- Linguist Curriculum Studio: Web editorial workflows let language specialists tag cognates, attach regional audio variants, and publish versioned pack updates cleanly.
Technical Architecture
Inside the Flutter client, UI state listens reactively to Drift SQLite streams, keeping animations at steady frame rates regardless of cellular latency. When a learner records a spoken phrase, Flutter runs client-side voice-activity detection to trim leading and trailing silence, compresses the clip, and posts it to FastAPI if online—or queues the recording locally for deferred feedback when offline.
Flow: Flutter Client (Drift SQLite + FSRS Engine) → Delta Sync & Audio Upload (HTTPS) → FastAPI Gateway (Auth & Deduplication) → PostgreSQL (Canonical Review Log & Curricula) + Redis Queue → Python Speech Workers (Forced Alignment & Phoneme Scoring)
On the server, FastAPI validates JWT claims, checks client_event_id uniqueness in PostgreSQL to guarantee idempotency across retries, and replays new review logs through the shared Python FSRS module so server and client math never diverge. Speech clips enter Redis queues where GPU/CPU worker pools run acoustic alignment and store structured per-phoneme scores alongside temporary encrypted audio references.
Technology Stack
| Category | Technology detail |
|---|---|
| Cross-Platform Client | Flutter & Dart targeting iOS, Android, and responsive Web workspaces |
| Local Offline Storage | SQLite (Drift) holding lesson packs, audio blobs, and FSRS card states |
| Backend API Service | Python + FastAPI with Pydantic schemas and async multipart uploads |
| Speech & Phoneme Workers | Python Celery workers running forced-alignment and acoustic scoring |
| Primary Cloud Database | PostgreSQL storing canonical curricula, review ledgers, and user profiles |
| Queue & Ephemeral Cache | Redis for speech inference job queues and rate-limiting |
| Media & Pack Distribution | CDN-backed compressed Opus audio bundles with checksum manifests |
| Authentication & Sync | JWT refresh rotation with device-scoped sync cursors and mutation IDs |
Engineering Trade-offs & Solutions
| Engineering Challenge | Solution & Trade-off |
|---|---|
| Keeping FSRS scheduling identical between Dart clients and Python backend | Implemented a shared reference test suite of edge-case card histories validated across both Dart and Python FSRS engines; adds cross-language maintenance discipline while eliminating sync drift. |
| Resolving out-of-order reviews across phone and web sessions | Replaced snapshot overwrites with append-only review_events deduplicated by client_event_id in PostgreSQL; slightly increases storage over raw counters but preserves complete study histories. |
| Running acoustic phoneme alignment without delaying FastAPI endpoints | Offloaded waveform decoding and alignment onto Redis-backed Celery workers with short polling/SSE notification; adds slight async wait for spoken feedback while keeping API throughput high. |
| Supporting offline audio without bloating app store binaries | Shifted lesson media to on-demand Opus packs served via CDN manifests and stored in app-private storage; requires explicit pack version management in exchange for lean installs. |
Security & Reliability
Learner voice recordings represent sensitive biometric and personal data. Audio clips upload over TLS into short-retention encrypted object storage strictly scoped to processing workers and expire automatically after alignment scores persist—unless a learner explicitly opts into keeping personal playback comparisons.
Sync endpoints enforce per-device authorization tokens and bounded payload batch sizes to protect PostgreSQL from malformed replay storms. On the client, SQLite database migrations run inside transactional Drift schema upgrades with automated fallback backups so app updates never wipe a learner's local offline review queue.
Performance & Scale
Serving static curriculum manifests and Opus bundles directly from edge CDN nodes shields FastAPI and PostgreSQL from heavy media reads, leaving backend compute dedicated to delta sync and speech scoring. In PostgreSQL, partitioning review_events by time windows and maintaining materialized per-user mastery summaries prevents dashboard queries from scanning years of historical flashcards.
On mobile devices, audio pre-buffering loads the next two drill prompts into memory during active sessions, removing decode stutter on mid-range Android handsets while keeping total background memory usage modest.
Operational Outcomes
Pairing an offline-capable Flutter client with a deterministic Python and PostgreSQL sync core elevated reliability across both everyday mobile use and editorial operations:
- Zero lost offline study sessions: Idempotent event-log synchronization preserved complete recall streaks and FSRS states across flights, commutes, and multi-device switches.
- Actionable speaking practice: Syllable- and phoneme-level acoustic breakdowns helped learners pinpoint exact articulation habits rather than repeating phrases blindly.
- Rapid curriculum iteration: Linguists rolled out corrected translations, regional accents, and new thematic units via versioned CDN packs without waiting on app store review cycles.
- Lean device storage footprint: Selective Opus unit downloads and automated cleanup kept mobile storage predictable even across multi-level language tracks.