Building a commerce platform is not a UI problem. It is a data consistency problem. ePocket manages orders, inventory, customers, vendors, and financials simultaneously — and every one of those domains can change at any second from multiple channels at once.
Here is how we built it to stay coherent under that pressure.
The Core Problem
Traditional retail software treats inventory as a number. It is not. Inventory is a ledger. Every unit that moves — a sale, a return, a transfer between branches, a damaged write-off — needs to be recorded as an event, not as an update to a single value. If you update a number, you lose history. If you update a number from two places at once, you get race conditions.
ePocket uses an event-sourced inventory model. Every stock movement is appended to an immutable ledger. Current stock levels are derived from that ledger in real time. This means any branch manager can see exactly why stock is at a given level, not just what the level is.
Service Boundaries
We split ePocket into five core service domains: Catalog (products, variants, pricing), Inventory (stock, movement ledger, locations), Orders (checkout, fulfillment, returns), Customers (profiles, loyalty, segments), and Finance (billing, reporting, tax). Each domain owns its data. Cross-domain queries go through an API contract, never direct database joins.
Real-Time Sync
The hardest part of multi-channel retail is keeping stock counts consistent when an order can arrive from a website, a POS terminal, or a mobile app simultaneously. We use a queue-based reservation system: when an order comes in, stock is reserved immediately (in milliseconds) and then confirmed or released based on payment outcome. No overselling, no blocking.
What We Learned
The biggest lesson was to resist the temptation to optimize prematurely. We built the event ledger first and derived the read models from it. This meant the first version was slightly slower to query — but it was correct. We optimized once we had real usage data. Correctness first, performance second. Every time we inverted that order on previous projects, we regretted it.