Operations
Build configuration
Environment URLs (API_BASE_URL, BOOKING_BASE_URL) are injected at build time via --dart-define-from-file:
config/dev.example.json:
Build scripts
The scripts handle flutter clean, flutter pub get, build_runner, and flutter build apk with the correct --dart-define-from-file.
Cloud sync pipeline
Upload flow
Key files:
lib/core/sync/cloud_sync_worker.dart— main worker looplib/core/sync/cloud_sync_collector.dart— outbox reading and coalescinglib/core/sync/cloud_sync_client.dart— Dio HTTP wrapperlib/core/sync/cloud_sync_scheduler.dart— 30-second periodic triggerlib/core/sync/cloud_sync_backoff.dart— exponential backoff with jitter
Restore flow
lib/core/sync/cloud_restore_applier.dart— upserts rows, resolves conflictslib/core/sync/restore_gate.dart— gates restore to protect live data- Paginated, cursor-based:
GET /v1/restore/rows
Booking sync
A separate outbox for online booking requests:
lib/core/sync/booking/booking_outbox_worker.dartlib/core/sync/booking/booking_intent_applier.dartlib/core/sync/booking/booking_quarantine_store.dart
Account management
lib/core/sync/accounts_client.dart— cloud account APIlib/core/sync/accounts_session.dart— session managementlib/core/sync/accounts_models.dart— DTOs
Device roster
lib/core/sync/roster_service.dart— periodic cloud pull of device rosterlib/core/sync/roster_store.dart— local roster cachelib/core/sync/secondary_roster_refresher.dart— Secondary-specific roster updates
Heartbeat
lib/core/sync/heartbeat_scheduler.dart— Primary telemetry to cloud
Config sync
lib/core/sync/config/— cloud feature flags, booking slug, config client/worker/store
Credential store
lib/core/sync/secure_credential_store.dart— encrypted cloud credentials
Observability
lib/core/observability/ (~19 files):
Design principles: batched, idempotent, backoff-aware, never blocking.
Push notifications
lib/core/push/ (Primary only):
push_service.dart— thinFirebaseMessagingwrapper; foreground/in-app only, no background isolatebooking_push_controller.dart— routes incoming FCM data messages to app logicpush_register_client.dart— registers the FCM token with the cloud API
Every Firebase call is guarded so failures never throw. Starts/stops subscriptions on role transitions.
Cloud sync mock server
tool/cloud_sync_mock_server.dart (3.7 KB) — a local mock for testing the sync pipeline without a real cloud backend.
Device-to-device handover
When a Primary goes down, Secondaries can promote themselves:
primary_locator.dart— subnet scan to find remaining devicescandidate_verifier.dart— verifies a candidate is legitimate- Settings UI provides manual promotion controls
Backup & restore
Built into the Settings feature. Backs up the full Drift database and can restore it. The cloud restore pipeline handles cross-device restore.
Android foreground service
flutter_foreground_task keeps the Primary's Shelf server alive in the background. Critical for the multi-device architecture — if the Primary's server stops, all Secondaries lose connectivity.
Localization
lib/l10n/:
app_en.arb(134 KB) — English translationsapp_zh.arb(98 KB) — Chinese translations- Generated via
l10n.yamlconfiguration
Platform target
- Android only — the app is designed for landscape tablets (1280×800)
- No iOS or web support in the current configuration