A distributed mobile database architecture combines three normally separate concerns—a local database engine that keeps working offline, a synchronization layer that reconciles changes across intermittently connected devices, and a conflict-resolution model that decides what "correct" means when two devices edit the same data—and the design succeeds or fails mostly on the third. Mobile devices introduce constraints that classic distributed databases were not built for: frequent disconnection, high-latency and asymmetric networks, limited battery and storage, OS-level process termination, and clocks that cannot be trusted. This article describes a reference architecture that addresses those constraints, explains why each layer exists, and identifies the tradeoffs that most often cause trouble in production.
What "mobile" changes about the problem
A distributed database on fixed servers can usually assume reliable, low-latency links between nodes and a coordinator that is reachable most of the time. On mobile, none of that holds. A phone may be offline for hours, connect through a flaky cellular link, and then disappear again when the OS suspends the app. Two users may edit the same record on airplanes and merge later.
The practical consequence is that a mobile database architecture is offline-first by necessity, not preference. Reads and writes must complete against local storage without waiting on a network round trip. Synchronization becomes an asynchronous background process that must be resilient to partial failure, duplication, and reordering. That single decision cascades through every other layer of the design.
There is also an important scope distinction. A "distributed mobile database" can mean a per-device embedded database that syncs to a backend (the dominant pattern in consumer and field apps), or a peer-to-peer mesh among nearby devices with no server (seen in some field, mesh, and edge deployments). The architecture below covers the first, server-mediated case in depth and notes where the peer-to-peer variant diverges.
The reference architecture at a glance
A workable design has six layers. Each has a distinct job, and confusing their responsibilities is a common source of bugs.
| Layer | Responsibility | Typical failure if skipped |
|---|---|---|
| Local storage engine | CRUD on-device, durable, transactional | Data loss on app kill; slow UI |
| Change capture | Record what changed, not just final state | No reliable way to sync deltas |
| Sync protocol | Exchange changes with server, resume after failure | Duplicate or lost updates |
| Conflict resolution | Decide outcomes for concurrent edits | Silent overwrites; divergent replicas |
| Identity and versioning | Stable IDs, causal metadata | "Same" record created twice; lost edits |
| Security and lifecycle | Auth, encryption, schema migration | Leaked data; broken upgrades |
The remainder of the article examines each layer, why it is distinct, and the design choices that matter.
Local storage engine
The on-device store must provide ACID-ish guarantees locally so that an app can write confidently while offline. It can be a relational engine, a document store, or a key-value store with indexes; the architectural requirement is transactional durability and the ability to observe changes.
Two properties matter more than raw speed. First, every write should be committed to durable storage before the UI reports success, because mobile processes are killed without warning. Second, the engine should expose a change stream—either through triggers, a change log, or write-ahead-log inspection—so the sync layer does not have to diff the entire database to find what changed.
A key architectural decision is whether the store is the system of record for the app's reads. In offline-first designs it must be: reads go to local storage, and the network is never on the critical path of a read. Remote reads can be modeled as prefetching or replication rather than on-demand queries.
Change capture
Synchronizing final row states is a trap. If two devices both update a record and only the last-written row is transmitted, intermediate edits vanish and there is no information to resolve anything. The architecture should record operations or changesets—each mutation as an event with an identity, a timestamp or logical clock, and the previous state it observed.
This is where mobile databases diverge from traditional replication. Traditional systems often rely on the database's built-in replication log with a shared consensus protocol. That presupposes near-continuous connectivity and a coordinator. A mobile change log is instead a per-device ordered sequence that can be resumed, replayed, and merged with logs from other devices.
The change log also enables idempotent delivery: each change carries a stable ID, so the server can deduplicate a retried upload and the client can ignore a change it has already applied. Without idempotency, flaky links produce duplicated inserts and inconsistent state.
The synchronization protocol
Synchronization is the heart of the architecture and the layer most often underestimated. A practical protocol has four properties:
Resumable. The client tracks a cursor (a high-water mark of acknowledged changes) and resumes from it after disconnection. The server must accept a cursor-based pull and an append-only, idempotent push. Bidirectional. Changes flow both ways: local edits up, remote changes down. A pull-only or push-only design breaks as soon as two devices or a web console edit the same data. Incremental. Only deltas travel, not full snapshots, or a phone on a metered connection pays for the entire dataset on every sync. Eventually consistent with explicit ordering. The protocol should carry logical ordering metadata (see versioning below) even if physical delivery order is arbitrary.
A common and effective shape is a change-feed protocol: the server assigns each accepted changeset a monotonically increasing sequence number; clients pull "all changes after cursor N" and apply them locally within a transaction, then push their pending changes. The pull and push are separate, so a client can pull before pushing (to merge) or push before pulling (to reduce latency), and the sync is idempotent under either order.
Some designs collapse pull and push into a single round trip for efficiency; that is fine, provided the server can still process them independently under retry. The architectural point is that the protocol must be safe to retry at any point without duplicating effects.
Server-side responsibilities
The backend is not just a message relay. It typically maintains the authoritative change log, enforces authentication and authorization per change, applies server-side validation, and assigns global ordering. It may also run the merge logic that the client cannot be trusted with—for example, resolving conflicts in favor of a server-side invariant such as "no two active bookings for the same seat."
Keeping merge logic server-side has tradeoffs. It centralizes correctness but means a client cannot always resolve a conflict offline; it must defer and reconcile later. Many systems use a hybrid: deterministic client-side merges for convergent data (text edits, counters) and server arbitration for business-invariant data.
Identity and versioning
Two devices that both create a record while offline will both assign an identity. If identities are sequence numbers from a local auto-increment, they collide. The architecture needs globally unique IDs—UUIDs or device-prefixed composite keys—assigned at creation time on the client. This is non-negotiable in any multi-writer mobile design.
Versioning goes further. To know whether a change is concurrent with another, the system needs causal metadata. The strongest practical option for mobile is a version vector or a hybrid logical clock: it lets the merge layer determine whether one change causally follows another or whether the two are concurrent (and therefore a genuine conflict). Wall-clock timestamps are not sufficient—device clocks drift and can be set backwards—so a timestamp should be treated as a hint, not a causal guarantee.
Conflict resolution
This is the layer that decides user-visible correctness. There is no universal answer; the right model depends on the data. Three broad strategies cover most cases.
Last-writer-wins (LWW). The change with the "latest" timestamp or sequence wins. It is simple and converges, but it silently discards the loser's edit. Use it only for data where losing an update is acceptable—presence flags, soft preferences, low-stakes settings. It is a poor default for anything a user typed.
Operation-based merge / CRDTs. Conflict-free replicated data types define merge functions that are commutative and associative, so replicas converge regardless of delivery order. Counters, sets, and text sequences have well-understood CRDT formulations. A rich-text collaborative editor, for example, can use a sequence CRDT so two people typing offline both keep their characters. The cost is metadata overhead and implementation complexity; not every data shape maps cleanly to a CRDT.
Server arbitration or application-defined merge. For business logic, the system may route conflicts to a rule engine or to a human. A classic example is an inventory counter: two devices sell the last unit offline; a CRDT counter would happily go negative, so the server must reject one sale and notify the loser. The architecture should therefore allow per-entity conflict policies rather than imposing one global rule.
The distinction that matters most: convergence (all replicas reach the same state) and correctness (that state obeys business rules) are separate properties. LWW and CRDTs guarantee convergence. They do not guarantee correctness. Business-invariant data needs an arbiter.
Security, schema, and lifecycle
Three operational layers are easy to omit from a whiteboard diagram and painful to retrofit.
Authentication and authorization. Every synced change carries the identity of the user who made it, and the server must authorize each change, not just the connection. Row-level authorization matters: a replicated dataset often contains other users' data, and a client must never receive rows it is not entitled to see. Encryption at rest on the device and in transit is table stakes for regulated data.
Schema evolution. A fleet of devices will run different app and database schema versions simultaneously. Migrations must be forward-compatible: the server should tolerate older clients, and clients should handle unknown fields gracefully. Additive changes are safe; destructive ones require a coordinated rollout or version negotiation in the sync protocol.
Lifecycle and storage limits. Offline caches grow. The architecture needs a retention or compaction policy for the local change log and for downloaded datasets, plus handling for a device that has been offline so long its cursor is older than the server's retained log—at which point the client must resync from a snapshot rather than by replay.
A concrete data flow
Tracing a representative edit clarifies how the layers compose.
1: A field worker edits a record on a tablet that has no signal. The local engine commits the change transactionally and appends a changeset to the local outbox with a client UUID, a version vector, and the changed fields. 2: The UI updates from local storage immediately. No network call is attempted. 3: When connectivity returns, the sync process pushes pending changesets. The server deduplicates by change ID, validates, authorizes, assigns a global sequence number, and appends them to the authoritative log. 4: On the same or a later connection, the client pulls all changes after its cursor, including changes from other devices. It applies them locally in a transaction. Where a pull touches a record with a pending local change, the conflict policy runs—LWW for preferences, a merge function for text, server arbitration for the inventory invariant. 5: The client advances its cursor and marks acknowledged changes as delivered.
If a step fails at any point, retry is safe because both push and pull are idempotent and cursor-based.
Where peer-to-peer differs
In a mesh design with no server, the sync protocol runs device-to-device over local transports (Bluetooth, Wi-Fi Direct, local network). Most of the architecture survives: local storage, change capture, unique IDs, versioning, and CRDT merge are still required. What changes is ordering and arbitration. With no central authority, global ordering must be constructed from causal metadata delivered opportunistically, and server arbitration is replaced by application-level or eventual deterministic rules. Mesh designs also face partition healing and data-completeness problems—a device may never meet the peer holding important changes—so they are best suited to applications where eventual, locally determined convergence is acceptable.
Design guidance
The architecture has a small number of load-bearing decisions:
Make the local store the source of truth for reads, and assume disconnection rather than treating it as an error. Capture changes as immutable, idempotent, uniquely identified events—not as final row states. Use globally unique client-assigned IDs and causal version metadata, not wall-clock time, to reason about order. Design the sync protocol around resumable cursors and separate push/pull, so it is safe to retry at any point. Choose the conflict policy per entity type. LWW for low-stakes fields, CRDT-style merges for collaborative content, and server arbitration for business invariants. Treat authorization as per-change, not per-connection, and plan schema migration for a mixed-version fleet from day one.
The hardest part is rarely storage or networking; it is deciding, precisely and in advance, what "correct" means when two copies of the same data disagree. An architecture for a distributed mobile database is, at its core, an explicit answer to that question—everything else is plumbing to make the answer hold across disconnection, retry, and time.