Database isolation
Each service owns a private database. Inventory cannot reach into Financials to grab a journal entry. All data exchange happens through defined service contracts.
Distributed systems · Engineering brief 03
Build the software backbone that digitally mirrors the physical flow of goods and money through a retail business: from suppliers and purchasing to warehouse operations, checkout and accounting.
Architecture
8 services
Data ownership
Private databases
Delivery
4 phases
Review
Instructor / lead
Project vision
You are building for a retail business that buys goods from suppliers, stores them in a warehouse and sells them in physical stores. Today, spreadsheets, paper receipts and manual data entry leave inventory counts stale, payments delayed and profitability unclear.
Divide the business into strict domains. Each module is a self-contained vertical slice: domain logic, private data and a frontend for human interaction. Together they form a distributed, modular Merchandise Management System (MMS).
Architectural mandate
Independent services are an architectural constraint of this exercise. The objective is to practise domain ownership, network contracts and recovery from partial failure. Keep point-of-sale, warehouse and accounting logic within their respective services.
Each service owns a private database. Inventory cannot reach into Financials to grab a journal entry. All data exchange happens through defined service contracts.
Deploy each module on its own. A bug fix in the warehouse app must not force a redeployment of the point-of-sale system.
A Financials outage must not block receipt or sale recording. Preserve its events for recovery. Operations that require an immediate answer from an unavailable dependency must return a safe, explicit failure or pending state.
The islands communicate only over the network. Evaluate each interaction and choose the right tool for the nature of the data and the consumer.
Request / reply · JSON over HTTP
Use for frontend-facing web dashboards and mobile apps, and for general server-to-server retrieval where human readability and browser accessibility are valuable.
Typed service contracts · RPC
Use for backend calls that benefit from generated clients and typed contracts, such as stock reservation at checkout. Protocol Buffers define and serialise messages; gRPC provides the remote procedure call framework. Justify performance claims with measurements.
Asynchronous · Event bus
Publish events such as GoodsReceived and ItemSold to a central message broker. Subscribers react at their own pace. Publishers do not need to know who is listening.
In this brief, request/reply means the business operation needs an answer before proceeding. It does not require blocking a thread: gRPC supports synchronous and asynchronous APIs, as well as streaming. Brokered events serve a different purpose: Receiving confirms a durable receipt without waiting for downstream bookkeeping. See the gRPC core concepts and Protocol Buffers overview.
The modules you will build
Every module below requires a backend service, a private database and its named frontend. Follow each domain’s responsibilities and boundaries.
Module 01 · Phase 1
“Who supplies our goods, and under what terms?”
Supplier information is scattered across emails, spreadsheets and employees’ heads. There is no single place to find what a supplier sells, how long they take to deliver or their payment terms.
Procurement team and back-office administrators
A web dashboard to browse, add, edit and archive supplier records.
Module 02 · Phase 1
“What are we committing to buy, how much will it cost us, and who approved it?”
Buyers create purchase orders in spreadsheets or on paper. There is no visibility into orders, approvals or outstanding deliveries. Hallway conversations and forwarded emails create confusion and delays.
Buyers and purchasing managers at the back office
A web dashboard to create purchase orders, route them for approval and view open orders.
Module 03 · Phase 2
“Did we actually receive what we ordered, in the right quantity, and in good condition?”
At the loading dock, workers check boxes against paper lists or sign delivery notes without checking. Goods are lost, miscounted or accepted damaged, and problems surface weeks later during inventory counts.
Warehouse staff at the loading dock
A mobile/tablet app with barcode scanning to check items against a purchase order and finalise the receipt.
Module 04 · Phase 1
“How much of each product do we own, where is it physically located, and what is it worth?”
The warehouse thinks there are ten units, the store thinks there are three and the spreadsheet says zero. Customers are told items are out of stock while they sit in a backroom, or items are oversold when they do not physically exist.
Inventory managers, buyers and the finance team at the back office
A web dashboard to browse stock levels, perform stock adjustments and view inventory valuation reports.
Module 05 · Phase 2
“Where exactly do we put things, where do we find them, and how do we move them between locations?”
The warehouse is a maze of aisles, shelves and bins. Workers put boxes wherever there is space, then spend hours searching for products the inventory system says are somewhere in the building.
Warehouse pickers, forklift drivers and floor supervisors
A mobile/tablet app that directs workers to specific bins for putaway and picking.
Module 06 · Phase 3
“What did we sell, to whom, at what price, and how did they pay?”
Checkout is where money enters the business. Cashiers need accurate prices, applicable discounts and stock availability. Wrong prices or a slow system drive customers away; incorrectly recorded sales lose money and visibility.
Cashiers at retail storefronts
A fast, touch-friendly app for scanning items, applying discounts, processing payments and printing receipts.
Module 07 · Phase 3
“Does the money physically present in the store match what the sales system says it should be?”
At day end, the expected cash balance is KES 500,000, but the drawer contains KES 400,850. Without reconciliation by payment method, cashier mistakes, unrecorded movements and payment-processing discrepancies go unnoticed or unresolved.
Store managers at retail branches
A web dashboard to enter cash counts, compare expected totals and close the day’s register.
Module 08 · Phase 4
“What does the business own, what does it owe, and is it making money?”
Accountants manually re-enter goods receipts and sales into a separate system, calculate costs and record revenue. This is slow and error-prone, leaving the books weeks behind and profitability unclear.
Accounting team and back-office executives
A web dashboard for accounts payable, the general ledger and profitability reports.
The big picture
Each module owns a distinct problem. The power of the system comes from how they coordinate. Follow the goods and money through these five business conversations.
These examples use KES, a KES 10 unit cost and a KES 20 cash sale. Tax, discounts and payment fees are omitted from the arithmetic; their treatment still belongs in the implementation. The receipt example assumes accepted goods become business-owned stock and accrue a supplier obligation at receipt. GRNI means goods received not invoiced; invoice matching later transfers that balance to accounts payable. See Oracle’s receipt accrual and reconciliation documentation for an implementation of this distinction.
Scenario 1
Procurement + Vendor Management
The business goal: A buyer needs to order 100 units of Product X from a supplier.
Procurement requests approved suppliers and pricing for Product X. Vendor Management returns suppliers, lead times and current wholesale costs. After the buyer selects Supplier A, Procurement asks for current payment terms. Vendor confirms Net 30 days; Procurement freezes those terms and prices on the purchase order.
Purchase Order #1001 is approved for Supplier A. The business is committed to receiving the goods.
Receiving now expects the delivery. Financials records the purchase commitment for planning, without posting an inventory asset or trade payable merely because the PO was approved. Inventory updates quantity on order, keeping expected goods separate from stock on hand.
Scenario 2
Receiving + Procurement + Warehouse Operations + Inventory + Financials
The business goal: Verify the arriving goods, prepare them for storage and account for the receipt.
Receiving checks the supplier’s delivery note against an open, approved purchase order. Procurement returns PO #1001 and the expected items and quantities.
Workers scan the delivery. Receiving compares 95 delivered units with 100 ordered units and flags the shortage of five immediately.
Receiving accepts 95 undamaged units of Product X and records five outstanding. It durably saves GRN #500 together with the intent to publish GoodsReceived before confirming “Receipt Complete”. Subscribers finish their work independently.
Inventory adds 95 units on hand and reduces quantity on order to five. Procurement consumes the receipt to keep PO #1001 partially received until the remainder arrives or is explicitly cancelled. Warehouse Operations creates a putaway task. Financials obtains the frozen KES 10 unit cost using the PO-line reference, debits inventory assets KES 950 and credits goods received not invoiced (GRNI) KES 950. Matching the invoice later clears that accrual into accounts payable.
Scenario 3
Warehouse Operations + Inventory
The business goal: Place the 95 units at a logical, traceable location in the warehouse.
Warehouse Operations requests Product X’s dimensions, weight and sales velocity. Inventory returns the physical attributes and historical demand data.
Product X sells quickly, so Warehouse Operations directs the worker to Bin A-01 near shipping rather than deep in the warehouse.
After placement, Warehouse Operations reports the 95 units in Main Warehouse, Bin A-01. Inventory acknowledges and updates its location record so other services can find available stock.
Scenario 4
POS + Inventory + Sales Audit + Financials
The business goal: Sell one unit of Product X at Retail Store No. 3.
Assume Warehouse Operations has transferred 50 of the 95 units to Store No. 3, leaving 45 in the main warehouse. POS requests one unit at the store. Inventory atomically checks and reserves it, returning a reservation ID so another checkout cannot claim it while payment is processed.
The customer pays KES 20 in cash. POS durably records transaction T-777 and the intent to publish ItemSold, including the reservation ID. The reservation remains protected until the sale is applied or an explicit recovery outcome resolves it.
Inventory applies the sale once, deducts the reserved unit and resolves the reservation: 49 units remain at the store and 45 in the warehouse, for 94 overall. Sales Audit adds KES 20 to Register No. 2’s expected cash. Financials debits cash KES 20 and credits revenue KES 20; using Inventory’s KES 10 issue cost, it debits cost of goods sold KES 10 and credits inventory KES 10. Gross profit is KES 10.
Scenario 5
Sales Audit + POS + Financials
The business goal: Count the register, explain differences and finalise the trading day.
Sales Audit requests Register No. 2’s completed transactions up to an agreed session cutoff. For this example, all 150 transactions are cash, with no opening float, refunds or recorded cash movements. Expected cash is KES 5,000; card and gift-card reconciliation are separate.
The manager counts KES 4,950. Sales Audit calculates a KES 50 shortage and blocks closing until investigation notes and sign-off are recorded: “Recount completed; no supporting payout record found. KES 50 shortage accepted for investigation.” If evidence instead establishes a cleaning-supplies payout, record that cash movement and expense, then recalculate the variance.
Sales Audit publishes DayClosed with the register session, cutoff, expected and actual amounts, KES 50 residual shortage and approval reference. Financials debits Cash Over/Short KES 50 and credits cash KES 50. Closing with approval preserves the discrepancy; it does not describe the register as balanced.
Receiving does not need to know the financial value of the goods. Financials does not need to know their warehouse bin. Retail Sales does not need to know the supplier. Include stable product, purchase-order-line, receipt and transaction references so each consumer can obtain authorised facts from the owning service. Local copies built from events are permitted; ownership and write authority remain with the source domain.
Architecture review
The scenarios describe successful business flows. Your design must also explain how those flows remain correct under concurrency, retries and partial failure. Record these decisions and demonstrate the relevant cases as each module reaches review.
Implementation references: transactional outbox, idempotent consumers and gRPC deadlines.
Feature flags
Do not build all eight modules at once. Use these module flags to control routes, event listeners and frontend visibility as development proceeds.
Phase 1
Phase 2
Phase 3
Phase 4
Developer handbook
Submission checklist
A module is ready for review only when all six conditions are met. Request review from the instructor / lead architect on the pull request.