Overview
Vocab Vault uses Capacitor Preferences for all local data storage, enabling offline-first functionality across web, iOS, and Android. All user progress, achievements, and spaced repetition data persist locally on the device.Storage Technology
Capacitor Preferences
- Web:
localStorage - iOS:
UserDefaults - Android:
SharedPreferences
Storage Keys
All data is stored under six primary keys:/src/hooks/useProgress.ts:30-35
Data Structures
Progress Data (Classic Mode)
Key:vocabVaultProgress
Structure:
Streak Data
Key:vocabVaultStreak
Structure:
/src/hooks/useProgress.ts:25-28
ELI5 Mode
Key:vocabVaultEli5Mode
Structure: Boolean
Example:
Achievements
Key:vocabVaultAchievements
Structure: Array of achievement IDs
Example:
ACHIEVEMENTS array.
User Statistics
Key:vocabVaultStats
Structure:
/src/hooks/useProgress.ts:68-71
SRS Data (Spaced Repetition)
Key:vocabVaultSRS
Structure:
/src/lib/sm2.ts:24-27
Storage Operations
Reading Data
/src/hooks/useProgress.ts:54-75
Writing Data
/src/hooks/useProgress.ts:143
Removing Data
/src/hooks/useProgress.ts:293-297
Safe JSON Parsing
The app uses asafeJsonParse utility to handle corrupted or missing data gracefully:
/src/hooks/useProgress.ts:56
Data Loading Flow
- Mount:
useProgresshook initializes - Load: All six storage keys are read in parallel
- Parse: JSON strings are parsed with fallback defaults
- Set State: React state is updated with loaded data
- Mark Loaded:
isLoadedflag set totrue
/src/hooks/useProgress.ts:52-83
Write-Through Cache Pattern
The app uses a write-through cache pattern:- Update React state immediately (optimistic UI)
- Persist to Preferences asynchronously
- No confirmation needed (fire-and-forget)
/src/hooks/useProgress.ts:140-147
Storage Limits
Capacitor Preferences has generous limits:- Web (localStorage): ~5-10 MB per domain
- iOS (UserDefaults): No practical limit
- Android (SharedPreferences): No practical limit
Privacy & Security
- No server: All data stays on device
- No analytics: No tracking or telemetry
- No sync: Data never leaves the device
- No accounts: No authentication or cloud storage
Reset Functionality
Users can reset all progress, which clears all six storage keys:/src/hooks/useProgress.ts:286-298
Migration Strategy
Theversion field in SRSData supports future schema migrations: