HomeCase studiesOffline-First Language Learning App with FSRS Spaced...

Case study · Barcelona, Spain

Offline-First Language Learning App with FSRS Spaced Repetition and Speech Scoring

Interactive Speech & Spaced-Repetition Learning

Language learners frequently study during commutes or flights where cellular connectivity drops mid-lesson, yet speech evaluation and long-term mastery tracking require server-side audio models and cross-device consistency. We engineered a cross-platform language learning application using Flutter for iOS, Android, and Web alongside a Python FastAPI backend and PostgreSQL. Local SQLite stores downloaded audio packs and FSRS spaced-repetition states offline, synchronizing seamlessly via idempotent event logs whenever connectivity returns.

Industry
Interactive Speech & Spaced-Repetition Learning
Solution
A cross-platform mobile and web language learning system built with Flutter, Python, and PostgreSQL, pairing offline-first FSRS memory scheduling with asynchronous pronunciation feedback.
Platforms
Cross-platform · Web & API
Stack
Flutter · Dart · Python · FastAPI · PostgreSQL · SQLite
Location
Barcelona, Spain · delivered remotely
Role
Engineering, with the team behind for mobile and QA

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.

01 — Questions

asked about this kind of project

How does the app resolve spaced-repetition conflicts if a learner studies offline on a phone and later opens the web client?

Rather than overwriting whole deck snapshots, each client appends immutable review events tagged with a client UUID, card ID, and device timestamp. The Python sync endpoint replays unapplied events against the canonical PostgreSQL FSRS state deterministically so no study streak or review history is lost.

Why embed SQLite inside Flutter instead of relying purely on HTTP caching?

Language drills require instant audio playback and zero-latency card transitions even inside subways or airplanes. Storing normalized curriculum tables and FSRS parameters in Drift/SQLite lets the UI query and reschedule hundreds of flashcards locally without network round-trips.

How do you keep audio downloads small enough for learners on metered mobile plans?

Curriculum build pipelines encode native-speaker prompts into low-bitrate Opus containers grouped into incremental unit packs with SHA-256 manifests. Clients only fetch delta packs for newly unlocked units and verify checksums before removing older cached assets.

How does the Python backend score spoken pronunciation without blocking mobile recording UI?

The Flutter client performs lightweight local silence trimming and uploads compressed audio asynchronously to FastAPI, which enqueues an acoustic forced-alignment job on Redis. While learners advance to the next prompt or wait briefly, workers return syllable-level stress and phoneme confidence scores.

Can linguists update grammar hints or audio prompts without forcing an app store release?

Yes. Lesson structures, phonetic transcriptions, and audio manifest pointers are served as versioned JSON curriculum bundles from PostgreSQL via CDN, allowing editorial teams to ship corrections immediately.

03 — Similar project?

describe what is different about yours

Build yours.

Tell me what exists, what you need and the deadline. Fixed price for a defined scope, or $55/day (8–9 hours work) with a written plan first.

Solitaire Corporate Park, Makarba, Ahmedabad, Gujarat 380015, India · IST (UTC+5:30) · --:-- IST · Mon–Fri 09:00–18:00 IST · US & EU overlap daily

No newsletter, no CRM. Just a reply.