Prototype
The context
In retail, a connection outage can compromise the operation of a till that depends on the cloud. I developed a working prototype of a multi-tenant SaaS platform to explore a solution: combining central management with local recording of sales when the network is unavailable.
The challenge
Continuing to work offline also requires consistent synchronisation when the connection returns. If a terminal records a sale while the availability of the same product is changed from the central dashboard, simply overwriting the stock risks erasing one of the changes.
The point is not just to recover the connection, but to preserve the meaning of the operations performed on different systems and to apply explicit rules for concurrent changes.
The solution described
The solution uses a Vue/Nuxt frontend, a Go backend and PostgreSQL. For sales operations, synchronisation transmits events and changes rather than just overwriting the final state of the stock.
Local data in the browser. IndexedDB holds the data needed for the intended operation and the sales recorded while the network is absent. When the connection is available, the terminal updates its data from the central system. During the offline period the local copy cannot reflect remote updates not yet received.
Locally generated identifiers. New operations receive identifiers without waiting for a server response. This allows them to be recorded offline and recognised during synchronisation. Local ID generation, on its own, does not prove the absence of duplicates in processing.
Operation queue. The terminal records a movement such as “two pieces sold”, rather than just reporting “stock is now ten”. When the network is restored, the backend processes the operations through PostgreSQL transactions. Additive changes can thus be combined without replacing the whole value with an out-of-date local copy.
Conflicts on master data. For data that can be edited from several sources, optimistic concurrency control is used. When an out-of-date version is detected, the conflict is made visible and handled through a guided path. The rule for choice and reconciliation must be defined for each type of data.
The operational value
Continuity in the intended offline functions. The terminal can record sales locally during a network outage. The continuity of electronic payments, peripherals and fiscal services depends on their respective integrations and is not demonstrated by the offline-first architecture alone.
Reconciliation of operations. Sending movements avoids the specific risk of overwriting sales with an obsolete local stock figure. Overall correctness also depends on the rules on movements, any absolute inventory adjustments and the handling of errors and resubmissions.
Service evolution. The multi-tenant design and the backend described as stateless are oriented towards the growth of the platform. Serving thousands of simultaneous points of sale is a design target: the actual capacity of the prototype has not been measured with a documented load test.