Why Offline-First?
Field sales representatives work where reliable internet doesn’t exist: in warehouses, basements, rural areas, factory floors. An app that doesn’t work with poor connectivity won’t be used — no matter how good the features.
Offline-first means: the app works fully without an internet connection. Synchronization happens automatically once connectivity is available.
Architecture Decisions
Local Database
The central decision: which database runs on the device?
- SQLite / Room (Android) / Core Data (iOS): Proven, performant, full SQL queries. Ideal for structured data with complex relations.
- Realm / WatermelonDB: Reactive, object-oriented, good change-tracking support.
For a field sales platform with 70+ data domains and SAP integration, SQLite is the more robust choice: proven, performant, and with full SQL support.
Sync Strategy
Delta sync is the standard: only changed records are transmitted, not the entire dataset.
Three sync directions:
- Server → Client (Pull): Master data, price lists, route plans
- Client → Server (Push): Orders, visit reports, photos
- Bidirectional: Customer data updated in the field
Conflict Resolution
What happens when two people modify the same record offline?
- Last-Write-Wins: Simple but data loss is possible. Acceptable for non-critical fields.
- Field-Level Merge: Merge changes at the field level. More complex but lossless.
- Manual Conflict Resolution: The user decides. Only practical for a few critical fields.
In practice, a hybrid approach works best: field-level merge as default, last-write-wins for metadata, manual resolution for price changes.
Design Patterns
Optimistic UI
Actions are immediately saved in the local database and reflected in the UI — without waiting for server confirmation. Failed syncs are collected in a retry queue.
Queue-Based Sync
All write operations land in a persistent queue. A background service processes the queue as soon as connectivity is available. Idempotent operations prevent duplicates.
Chunked Initial Sync
The first sync (onboarding) can take several minutes with 70+ data domains. Solution: prioritized chunks. The most important data (today’s route, top customers) loads first.
SAP Integration
Field sales platforms in FMCG must talk to SAP. Typical integration points:
- SAP SD: Orders, customers, pricing conditions
- SAP MM: Inventory, material data
- SAP BW: Reporting data, KPIs
Integration runs through a middleware layer that transforms SAP IDocs or OData services into the app’s data model. Direct SAP calls from the mobile device is an anti-pattern.
Lessons Learned
- Test offline first: If the app works offline, it works online. The reverse isn’t true.
- Sync monitoring is mandatory: A dashboard showing which devices last synced and when.
- Watch data volume: 70 data domains × thousands of customers = several hundred MB. Budget for storage and sync duration.
- Sync photos separately: Images are large and non-critical for immediate processing. Use a separate queue with lower priority.
- Rollback strategy: What happens when a sync fails? Local data must never be lost.
Conclusion
Offline-first is not a feature but an architectural decision that affects the entire system design. The investment pays off: field sales apps that work reliably offline see significantly higher adoption and data quality.