A pharmacy transaction happens at the counter, not in the cloud. A customer has arrived, a medicine needs to be found, and the sale needs to be recorded. If the application requires an uninterrupted connection before it can do that work, network availability becomes part of every transaction.
Buwigs Pharma takes a different architectural direction. Its backend is a local FastAPI sidecar with SQLite storage for inventory and sales, paired with a separate cloud backend. This article looks at that implementation and what it means for the people who operate and maintain it.
Local work and remote work have different responsibilities
Local storage is not simply a faster cache of a remote service. In this architecture, the installed database is an important operational asset. It records work on the pharmacy machine, so application upgrades must preserve it instead of replacing it with the rest of the installation.
The project documents an outbox worker with configurable batch sizes, intervals and timeouts. Moving this work into a separate process gives synchronization its own lifecycle. A slow remote endpoint should not force the interface to treat every local interaction as a network request.
Decisions that matter
Make local storage the foundation
The backend is an offline-first FastAPI sidecar using a local SQLite database. Local inventory and sales can be stored on the pharmacy machine.
The local database must be persisted and backed up independently of application deployments.
Move synchronization into an outbox worker
A separate worker sends outbox events in configurable batches. This separates local transactions from the timing of a remote service.
Retry behavior and remote event handling need careful coordination.
Make schema upgrades explicit
Alembic migrations and configurable startup migration behavior support updating an installed database.
Deployments must preserve the database file and handle failed upgrades safely.
How it fits together
The key steps make the boundaries of the product easier to see:
- A pharmacy records inventory or sales work against its local database.
- The outbox worker sends queued events to the configured remote endpoint in batches.
- Operators preserve the local database and apply schema migrations when upgrading the installation.
A practical walkthrough
Consider a pharmacy recording several sales while the connection is unavailable. Those local operations should not be confused with the later work of sending events to the remote service. When connectivity returns, the synchronization process needs a clear way to distinguish work that has been sent from work that still needs attention.
This example illustrates the operational questions raised by an outbox design; it is not a claim that every recovery scenario has been verified. A useful review follows a local transaction, interrupts the remote connection, restarts the worker and checks the resulting local and remote records. The operator also needs to know which database file contains the authoritative local work before an installation is upgraded or moved to another machine.
Questions worth asking
- What can staff continue doing when the remote service is unreachable?
- How is synchronization progress distinguished from local transaction success?
- Can the installed database be recovered independently of the application files?
What we take from it
Offline-first architecture moves complexity rather than removing it. A cloud service can be restarted without losing a local transaction, but recovery now depends on the installed database, its backups and the behavior of synchronization.
The useful design question is therefore more specific than whether an application supports offline mode. Which operations are local, what needs to reach the cloud, and how will staff recover if an installed machine fails? Those boundaries shape the product as much as its screens do.