This project shows inventory control for a retailer with an online store and physical stores. An online order and a store sale can occur at the same time. If only one unit is available, only one transaction can use that unit.
The retailer can use different stock records for online orders and store sales. If the two sales channels use shared stock, they use the same stock record. Available stock is the on-hand quantity minus the quantity in active stock reservations.
The ordering platform uses online stock first. It can also use store stock from a store with online fulfillment.
A stock reservation holds the units for the order during payment. The stock reservation stays active after payment. At shipment, the inventory system decreases the on-hand quantity. The inventory system sets the stock reservation status to Consumed.
If payment does not occur before the time limit, the inventory system releases the stock reservation. If the customer cancels the order before payment, the inventory system releases the stock reservation.
The ten diagrams show different parts of the same design. Each diagram has a description.
This project contains ten diagrams. Select Edit this diagram to open that diagram in the editor.
The mind map has three branches for inventory planning. The branches show stock sources, checkout, and fulfillment. The link between Stock sources and Checkout shows how stock allocation changes available stock.
The ontology shows classes, individuals, and their relations. Store stock and online stock are classes of inventory stock. A stock reservation holds units from a stock record for one order item. Maya Chen is an example of a Customer. Order #1042 is an example of an Order.
The entity relationship diagram shows records and their relations. An order contains one or more order items. Each order item has one product. An order item can have stock reservations from different stock records. Each stock record has an on-hand quantity and a held quantity.
A primary key identifies a record. A foreign key identifies a related record.
The C4 System Landscape shows the sales channels and their related systems. The store point of sale sends store sales data to the inventory system. The ordering platform sends stock reservation requests to the same inventory system. The diagram also shows the warehouse team, shipping service, payment provider, and analytics platform.
The C4 System Context shows the ordering platform and its users and external systems. The customer sends an order to the ordering platform. The ordering platform sends a stock reservation request to the inventory system. The payment provider gives payment authorization.
The C4 Containers diagram shows the web application, Web API, order database, and receipt worker. The Web API sends requests to the inventory system and the payment provider. The order database stores order records. The receipt worker makes a receipt after the Web API records the order.
The C4 Components diagram shows the parts of the Web API. The order controller sends the request to the order service. The order service uses the inventory client for stock reservation requests. The order service uses the payment client for payment requests. The inventory system compares the requested quantity with available stock.
The state workflow shows changes in the stock reservation status. If sufficient stock is available, the inventory system makes a stock reservation. If the requested quantity is more than the quantity of available stock, the inventory system rejects the stock reservation request. The stock reservation stays active after payment. At shipment, the inventory system sets the stock reservation status to Consumed.
The inventory system releases the stock reservation if payment does not occur before the time limit. It also releases the stock reservation if the customer cancels the order before payment.
The ordered request shows the software steps for a stock reservation. The inventory service compares the requested quantity with available stock. If sufficient stock is available, the inventory service saves the stock reservation, inventory update, and reservation status in one transaction. If the requested quantity is more than the quantity of available stock, the inventory service rejects the request. The examples show a request that the inventory service accepts and a request that it rejects.
Facts and checks
Eligible available units available
Requested units requested
Make sure that the requested quantity is more than zero. Make sure that the requested quantity is not more than the quantity of available stock.
Save together
If any write fails, keep none of these changes.
Order reservation status · Set the order status to Stock held · awaiting payment. order-state
Stock reservation · Record the order item, stock record, held quantity, and payment time limit. stock-hold
Inventory stock · Increase the held quantity. Decrease available stock. held-stock
Acceptance examples
Two units requested, three available
Starting state: Checkout started · Eligible available units: 3 · Requested units: 2
Allowed · State: Stock held · awaiting payment · Saved writes: order-state, stock-hold, held-stock The inventory system holds two units. One unit stays available.
Three units requested, two available
Starting state: Checkout started · Eligible available units: 2 · Requested units: 3
Refused · State: Checkout started · Saved writes: None The inventory system rejects the request. Two units stay available.
The requirements traceability diagram shows the relation between the requirement, the design decision, and the planned test. The requirement prevents two sales of the same unit. The design uses the same stock record for both sales channels.
The planned test uses one unit of shared stock. An online checkout and a store sale start at the same time. The test must show that only one transaction uses the unit.
Cardinality: 1 means one; 0..1 optional; 0..* zero or more; 1..* one or more. Arrows follow the displayed relationship direction. Color categories are author-defined. This visual export does not embed the editable source document.