Sync System
Overview
The sync system keeps local content in sync with the server using a handshake-based protocol with progressive downloading.
Handshake Flow
- Speed test — app measures internet speed; sync is skipped if below 1.5 Mbps
- Build payload — app calculates MD5 checksums of all local JSON files
- Send handshake — payload sent to
/functions/v1/handshake - Receive manifest — server responds with list of updates needed
- Progressive sync — orchestrator coordinates multi-phase updates
Handshake Endpoint
POST https://kagtryxgjwavupzlmlzv.supabase.co/functions/v1/handshake
The request payload includes checksums for all system JSONs. The server compares these against its current versions and returns a manifest of what needs updating.
Progressive Sync Phases
| Phase | Description |
|---|---|
| 1. Analyze | Compare local vs server versions |
| 2. Storage check | Verify device has enough free space |
| 3. Download courses | CourseDownloader handles large files with progress tracking |
| 4. Update system JSONs | Each updater handles its own JSON type |
System JSONs (never deleted)
These files cannot be deleted by the user or the sync process — they are always present:
ads.jsonbackground.jsoncore_segments.jsonFAQs.jsonshop.json
Data Storage
| Location | Purpose |
|---|---|
AppData/ |
Bundled assets (shipped with the APK) |
| Device internal storage | Runtime copy — GeneralSettingsService copies from AppData on first run |
Internal storage mirrors the AppData folder structure. The app always reads from internal storage at runtime.
Audio Encryption
Audio files are stored encrypted on the device. Encryption/decryption is handled by lib/utils/audio_encryption.dart.