Write Locally First
In an offline-first app, every action saves to the device and updates the screen immediately. Synchronisation happens afterwards. The user never waits on a spinner to learn whether their work was kept.
Queue Operations, Not Screens
Record each change as an operation with its own identifier. The server can then ignore a repeat, which makes retrying safe.
@Entity
data class PendingOperation(
@PrimaryKey val id: String = UUID.randomUUID().toString(), // sent as the idempotency key
val type: String,
val payload: String,
val createdAt: Long = System.currentTimeMillis(),
val attempts: Int = 0,
)Decide How Conflicts Resolve
Two people can change the same record while disconnected. Choose the rule per field with the people who do the work: latest edit wins for a note, additions merge for a photo list, and a person decides for anything involving money or safety.
Show What Has Synced
Mark records as saved on this device, sending, or confirmed. A visible, honest state prevents both duplicate entry and misplaced confidence.



