DocHub
Singleton service layer — GeneralSettingsService, SyncService, SupabaseService, UserProvider

Core Services

All services use the singleton pattern:

final service = GeneralSettingsService();

GeneralSettingsService

  • Manages first-run initialization
  • Copies bundled assets from AppData/ to device internal storage (JSONs, Audio, HTML, Icons)
  • Always reads fresh data from files at runtime — no in-memory caching
  • Source: lib/services/general_settings_service.dart

SyncService

  • Orchestrates content sync with the server
  • Performs internet speed test before syncing (minimum 1.5 Mbps)
  • Builds handshake payload with MD5 checksums of all local JSON files
  • Endpoint: /functions/v1/handshake
  • Source: lib/services/sync_service.dart

ProgressiveSyncOrchestrator

Coordinates multi-phase sync after the handshake:

  1. Analyze — determine what needs updating
  2. Storage check — verify available device storage
  3. Download courses — via CourseDownloader with progress tracking
  4. Update system JSONs — via specialized updaters

Content Updaters

Updater JSON file Purpose
AdsUpdater ads.json Advertisement content
BackgroundsUpdater background.json Background music
CoreSegmentsUpdater core_segments.json Core audio segments
CourseUpdater courses Audio, workbooks, icons
FaqsUpdater FAQs.json Help content
ShopUpdater shop.json Store listings

SupabaseService

  • Handles authentication (email/password, Google Sign-In, magic links)
  • Session management with local caching for offline support
  • Source: lib/services/supabase_service.dart

UserProvider (ChangeNotifier)

  • Primary state manager for user authentication
  • Auto-login on app start
  • Session persistence
  • Offline mode management
  • Source: lib/providers/user_provider.dart