Spaced Repetition Vocabulary System: Engineering Design and Implementation
This article walks through the engineering design of an intelligent vocabulary memorization system built on spaced repetition. It covers why "learn and forget" is a scheduling problem rather than a willpower problem, how to model memory state with an ease factor and interval, how to build a scheduling engine from a priority queue, the trade-offs between simplified and standard learning modes, pluggable word list and course management, cross-platform audio playback, offline-first data synchronization, effect metrics, and a staged implementation roadmap.
1. Background: Why “Learn and Forget” Is an Engineering Problem, Not a Willpower Problem
Most vocabulary tools fail not because users lack effort, but because review timing does not match memory strength. The forgetting curve in cognitive psychology shows that retention of newly learned material decays roughly exponentially over time. Reviewing without any signal wastes time on material already mastered; reviewing too late wastes the effort of the previous session. The core of an intelligent vocabulary system is therefore not “displaying words” but delivering the right card to the right person at the right time, which is essentially a constrained scheduling problem.
A usable system must solve at least four things: quantifying memory state, predicting review time, tiering the learning pace, and keeping data consistent across multiple devices. Each is addressed below.
2. Modeling Memory State Mathematically
In engineering practice, there is no need to fit real neural mechanisms; a few interpretable parameters are enough to approximate memory strength. The most common approach maintains a combination of a “difficulty factor” and an “interval in days”:
state = { ease: 2.5, interval: 1, reps: 0, lapses: 0 }
After each review, update based on the self-rated quality q (0 to 5):
if q < 3: # treated as a lapsereps = 0interval = 1ease = max(1.3, ease - 0.2)else:reps += 1interval = 1 if reps == 1 else 6 if reps == 2 else round(interval * ease)ease = ease + (0.1 - (5 - q) * (0.08 + (5 - q) * 0.02))due_at = now + interval * day
The value of this model is that state is serializable and updates are incremental, so the scheduling position can be restored without storing the entire review history. For finer granularity, a two-factor model can split memory into “stability” and “retrievability”: the former grows slowly with successful recall, the latter decays over time, and a review pulls retrievability back above the threshold. The engineering recommendation is to get the closed loop working with a single-factor model first, then replace the algorithm core step by step while keeping the scheduler interface unchanged.
3. Scheduling Engine: From Time Polling to a Priority Queue
The scheduling layer answers one question: which cards should this session load? A naive implementation scans the whole table for due items, and latency rises noticeably once the data reaches tens of thousands of rows. The recommended structure is an in-memory min-heap backed by a persistent index:
- Build a min-heap keyed on
due_at, so the heap top is always the most urgent card; - At a fixed time each day, do one batch dequeue to generate the day’s queue and persist it;
- When the user studies new words ahead of schedule, push the new cards with “current time + short interval”;
- After the session ends, write back state and re-push into the heap.
Pseudocode sketch:
def build_session(user_id, limit=20, max_new=10):due = heap_pop_due(user_id, limit) # due reviews firstnew = pick_unseen(user_id, max_new) # capped new-word quotareturn order_by_priority(due + new) # interleave review and new
Two constraints deserve emphasis. First, the new-word quota must be capped; otherwise users pile up large numbers of unconsolidated cards in the “pleasure of learning,” and the later review queue explodes. Second, reviews take priority over new material, which is the basic discipline for long-term retention.
4. Design Trade-offs for Tiered Learning Modes
Offering “simplified” and “standard” modes for users with different levels of commitment is a common and reasonable product tiering. The difference should live in scheduling parameters, not in the interface:
| Dimension | Simplified mode | Standard mode |
|---|---|---|
| Cards per session | Few | Many |
| New-word quota | Very low | Moderate |
| Review rating | Binary (remembered/forgotten) | Multi-level self-rating |
| State update | Fixed multiplier | Adaptive ease factor |
Simplified mode lowers decision cost and suits fragmented commute time; standard mode collects finer-grained feedback signals and yields more stable long-term retention. In implementation, abstract the parameter set into a configuration object injected into the scheduler at runtime, avoiding a duplicated code path for each mode.
5. Pluggable Management of Word Lists and Courses
The word list is the content layer and must be decoupled from the scheduling layer. A sound abstraction has three levels: word list (source) → course/category (organization) → entry (smallest unit). An entry contains at least spelling, phonetic transcription, definition, example sentence, tags, and media resource references. Management features should cover:
- Import deduplication: use “normalized spelling + part of speech + definition fingerprint” as the unique key and merge duplicates;
- Course merging: preserve each entry’s state during a merge, and resolve conflicts by the most recent update time;
- Custom extensions: allow users to append private entries tagged with their source, making later individual export easy;
- Version tagging: record a version number when a word list is updated, to avoid corrupting client-side state.
6. Text-to-Speech and Cross-Platform Playback Compatibility
Human voice audio can significantly improve memory quality, but audio resources are large, so they are typically downloaded on demand and reused from a local cache. Cross-platform support is the biggest engineering pitfall: operating systems differ markedly in their support for audio devices and codecs, and calling system interfaces directly often fails silently on some platforms. The reliable approach is to abstract a playback interface and let the platform implementation decide the backend:
interface AudioPlayer { play(file) ; stop() ; onEnded(cb) }
On platforms lacking native capability, this can degrade to invoking an external player process, using the process exit code and a callback to confirm playback has ended, so the state machine does not get stuck in “playing.” For caching, the suggested strategy is “check local first, then remote, and fall back to a plain-text prompt on failure,” while naming audio files with a content hash naturally supports incremental updates and deduplication.
7. Data Synchronization and an Offline-First Architecture
Multi-device usage requires “usable offline, merged when online.” The recommended approach makes local storage the single write source: each state change generates a change event with a monotonic sequence number and a device identifier, uploads in batches once connected, and the server converges by “taking the highest sequence number per entry.” The data structure can be as simple as:
{ "word_id": "w_10231", "ease": 2.36, "interval": 15,"due_at": "2026-02-06T08:00:00Z", "seq": 842, "device": "d_03" }
For stronger semantic merging, conflict-free replicated data type ideas can be introduced, defining the merge function as “take the maximum interval and the weighted average ease,” which avoids overwrite problems caused by clock drift. At larger data volumes, object storage can hold audio and backup snapshots, a message queue can smooth synchronization traffic spikes, and logging services with monitoring alerts can track review queue backlog and synchronization failure rates.
8. Measuring Results and Closing the Iteration Loop
Without measurement there is no optimization. Four categories of metrics are worth collecting: next-day retention (the proportion still remembered at T+1), review overdue rate (the share of cards not reviewed after becoming due), average reviews per card, and queue backlog duration. A continuously rising overdue rate usually means the new-word quota is too large or the daily goal is set unreasonably; low retention may mean the ease factor decays too aggressively. Once these metrics are wired into general monitoring and alerting, algorithm parameters can shift from “guesswork” to “data-driven.”
9. Recommended Implementation Roadmap
- First implement single-factor scheduling with local storage, getting the “study - rate - re-enqueue” loop working;
- Add word list import deduplication and course management to validate whether the content-layer abstraction is sufficient;
- Complete the audio playback abstraction layer and caching to solve cross-platform compatibility;
- Introduce offline-first synchronization and conflict convergence to support multiple devices;
- Finally connect a metrics dashboard and keep tuning parameters.
Following this order yields a verifiable, usable version at each stage, rather than taking on all the risk in a single big rewrite. The difficulty of intelligent vocabulary memorization has never been the interface; it lies in translating the rules of memory into stable, measurable, and evolvable engineering constraints.
