Replication is a fundamental idea in collaborative editing systems

Replication is a fundamental idea in collaborative editing systems

Sub-problem 1: Source of Truth

Offline-mode support is unachievable if we don’t keep a local copy of the data that the client can operate on while offline.

The basic idea is that we let the server maintain the source of truth for the conversation thread and we make a copy (replica) of that conversation thread on each client.

Each client operates on their replica based on events from the server or the user but only the server is allowed to make updates to the source of truth.

The clients collaborate on making changes to the source of truth by sending update requests to the server and syncing server states with their respective replica states.

Does the source of truth need to exist on the server? Not necessarily. In decentralized systems where there is no single authority to determine the final state that every client needs to be on. All replicas can reach eventual consistency using techniques that are widely deployed in distributed systems like massive-multiplayer-online-games and peer-to-peer applications. It would be interesting to see how distributed computing techniques can be applied to web applications so that our data is not owned by a centralized authority like OkCupid (the premise of the Web 3 movement).

But in our Web 2 world, we have a server that is the gatekeeper for communications between two users as we see in this example.

When Alice and Bob first open their chat app, their replicas are populated by the source of truth from the server via an API request. Continue reading