Technical Guide December 16, 2024 5 min read

FieldSales: Offline-First Architecture for 45,000 Field Representatives

How we built our FieldSales platform with offline-first design for areas without network coverage — synchronization, conflict resolution, and lessons learned.

Deka Technology
Software Engineering
FieldSalesoffline-firstmobilesynchronization

Offline-first is not an architectural preference — for enterprise mobile applications deployed in environments with unreliable connectivity, it is an operational necessity. Field sales, logistics, inspections, healthcare, and any workflow where users operate in areas with poor or no mobile signal demands an architecture that treats the network as unavailable by default. This article covers the core patterns, conflict resolution strategies, and hard-won lessons that define robust offline-first enterprise applications.

When Offline-First Is Essential

Not every mobile app needs offline-first architecture. The investment in local storage, sync engines, and conflict resolution is significant. Offline-first is essential — not optional — when:

  • Users operate in locations with unreliable connectivity (retail stores, warehouses, rural areas, underground facilities)
  • Each user session involves multiple data-entry steps that cannot tolerate mid-workflow connectivity loss
  • Failed submissions have real business cost (lost orders, missed inspections, compliance gaps)
  • The user population is large enough (thousands of devices) that even rare connectivity failures produce daily support tickets

If all four conditions apply, offline-first is not a feature — it is an architectural requirement. Any architecture that requires a server round-trip for core operations is fundamentally incompatible with these work patterns.

Data Partitioning Strategies

The first design decision is how to partition data between server and device. Two categories emerge in virtually every enterprise offline-first application:

  • Reference data (customer master, product catalog, pricing, promotions): read-only on the device, downloaded from the server during scheduled sync windows. Each device maintains only the subset relevant to its assigned territory or role — typically a few thousand records, not the full enterprise dataset.
  • Transactional data (orders, visit reports, inspection records, photos): created locally on the device, queued for upload, and synced to the server when connectivity is available.

This partition is not arbitrary. Reference data is server-authoritative and never conflicts. Transactional data is device-authoritative at creation time and may require conflict resolution only in edge cases. Mixing these categories — allowing both server and device to modify the same records — creates conflict resolution complexity that is rarely justified.

Conflict Resolution Patterns

Conflict resolution is the hardest problem in offline-first design. Three patterns cover the vast majority of enterprise use cases:

  1. Last-Write-Wins (LWW) — The most recent write (by timestamp) overwrites earlier values. Simple to implement but lossy. Appropriate for point-in-time observations (visit reports, status updates) where the latest value is definitionally correct.
  2. Append-only / event sourcing — Writes are never in conflict because each is a unique event (identified by device ID + timestamp). Orders, inspection submissions, and audit logs naturally fit this pattern. No data is ever overwritten; the server aggregates events into current state.
  3. CRDTs (Conflict-free Replicated Data Types) — Mathematical structures that guarantee convergence without coordination. Counters, sets, and maps can be implemented as CRDTs. Powerful but complex; justified only when concurrent edits to the same entity are frequent and data loss is unacceptable.

Stay ahead in enterprise tech.

Get our latest insights — no spam, unsubscribe anytime.

The most important principle in offline-first conflict resolution: choose the strategy per entity type, not globally. Orders can be append-only while visit reports use LWW and inventory counts use a CRDT counter — all within the same application.

Sync Engine Design

The sync engine is the core infrastructure component. A well-designed sync engine has four characteristics:

  • Outbox pattern for uploads — Every transactional write goes to a local outbox table, not directly to a network queue. A background worker polls the outbox when online, batches pending records into compressed payloads, and submits to the sync API. The server acknowledges each record individually; partially successful batches are handled gracefully with exponential backoff for failures.
  • Delta sync for downloads — The server computes diffs based on a client-provided last_sync_token against a server-side change log. Only changed records are transmitted. In a well-partitioned system, a typical delta payload after a full business day is 15-25 KB — trivial even on 2G connections.
  • Battery and network awareness — Sync workers must respect device constraints. Use platform-native job schedulers (Android WorkManager, iOS BGTaskScheduler) with battery-not-low and network-type constraints. Aggressive sync polling is the fastest way to generate user complaints.
  • Idempotent operations — Every sync operation must be safely retryable. Network timeouts after the server has processed but before the client receives acknowledgment are not edge cases at scale — they are daily occurrences across thousands of devices.

Testing Offline Scenarios

Offline behavior cannot be tested manually at scale. The testing strategy should include:

  • Network-off integration tests — CI/CD pipelines should include tests that simulate extended offline periods (4-8 hours) followed by sync, validating data integrity end-to-end
  • Conflict injection tests — Deliberately create conflicting writes and verify that the resolution strategy produces correct results for each entity type
  • Schema migration tests — Test migrations against databases with months of accumulated local data. App updates in the field encounter data states that clean test databases never produce.
  • Storage pressure tests — Simulate devices with constrained storage (some enterprise-grade Android devices ship with 8-16 GB, of which the OS consumes half) and verify that pruning policies keep the app functional

Performance Benchmarks to Target

For enterprise offline-first applications at scale (10,000+ devices), these benchmarks represent production-proven targets:

  • Full initial sync (first install): under 15 seconds on 4G, under 5 MB total payload
  • Daily delta sync: under 30 KB average payload, completing in under 2 seconds
  • Local write latency: under 50ms for any single transaction (the user should never perceive storage delay)
  • Sync success rate: 99.5%+ of outbox records acknowledged within 4 hours of first connectivity
  • Zero data loss: no acknowledged-but-not-synced or synced-but-not-acknowledged records over any 30-day window

In production offline-first platforms across FMCG, logistics, and field service domains, these benchmarks are achievable with the patterns described above, and falling short on any of them will generate operational pain at scale.

FieldSalesoffline-firstmobilesynchronizationFlutterenterprise
Share

Want to learn more about this topic?

First consultation is free — no strings attached.

Talk to our experts
All articles
Related Articles
Technical Guide

DekaFlow: How We Built an Enterprise BPM Platform with Camunda

The architecture decisions behind DekaFlow — our Camunda-based BPM platform for process automation in enterprise environments.

Technical Guide

.NET Legacy Modernization: How We Gradually Replace Monolithic Systems

Our proven approach to gradually modernizing .NET monoliths — Strangler Fig pattern, domain-driven design, and zero-downtime migration.

Technical Guide

API-First for B2B Platforms: Architecture Decisions Behind DekaFlow

How we designed DekaFlow as an API-first platform — OpenAPI specification, versioning, rate limiting, and developer experience.

Let's build something that works.

First consultation is free.

Get in Touch