App Architecture

Service layer, progressive sync, authentication, and cross-platform in-app purchases

High-Level Architecture

Flutter App
UI + Services
HTTPS
Supabase
Auth + Edge Functions
Validate
App Stores
Apple + Google
Device Storage
Encrypted audio + JSONs

Core Services (Singletons)

GeneralSettingsService
Copies bundled assets to internal storage on first run. Always reads fresh from disk (no caching).
SyncService
Orchestrates content sync. Tests internet speed (min 1.5 Mbps), builds checksum payload, sends handshake.
ProgressiveSyncOrchestrator
Multi-phase sync: analyze → storage check → download courses → update system JSONs.
SupabaseService
Authentication, session management, local session caching for offline.
UserProvider
ChangeNotifier for user state. Auto-login, session persistence, offline mode.
InAppPurchaseService
Cross-platform IAP. Google Play Billing + Apple StoreKit with backend validation.

Sync Handshake Flow

1
Speed test — measure internet speed; skip sync if below 1.5 Mbps
2
Build payload — MD5 checksums of all local JSON files
3
HandshakePOST /functions/v1/handshake
4
Receive manifest — server returns list of updates needed
5
Progressive download — courses, then system JSONs, with progress tracking

Authentication

MethodDetails
Email / PasswordStandard Supabase auth
Google Sign-InOAuth via Supabase, deep link callback
Magic LinksUsed for device removal confirmation
Offline ModeCached local session → HomeScreen without network

Deep links: lucidflow://app (mobile) | Uri.base.origin (web)

In-App Purchases

PlatformProduct ID FormatExample
AndroidLowercase course codeh01enb
iOSBundle prefix + lowercaseme.hypnoelp.app.h01enb
1
User selects subscription, course, custom audio, or AI credits
2
Native purchase via Google Play / App Store
3
Receipt sent to /functions/v1/validate_purchase
4
Backend validates → course added → sync triggered

Content Updaters

AdsUpdater
ads.json
BackgroundsUpdater
background.json
CoreSegmentsUpdater
core_segments.json
CourseUpdater
Audio, workbooks, icons
FaqsUpdater
FAQs.json
ShopUpdater
shop.json

Platform Configuration

PlatformKey SettingValue
AndroidMin SDK23 (Android 6.0)
AndroidNDK29.0.13599879
iOSBundle IDme.hypnoelp.app
iOSDeep linklucidflow://
WebAllowed routessignup-success, reset-password, auth/callback
Detailed docs: Core Services | Sync System | Auth & IAP | Platform Config
Back to Hypnoelp App