Skip to content

Instantly share code, notes, and snippets.

@ticean
Forked from impactmass/inventory-data-flow.txt
Last active June 27, 2019 22:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ticean/9548e2eb32d5e5e506a2a4e52ea2d1db to your computer and use it in GitHub Desktop.
Save ticean/9548e2eb32d5e5e506a2a4e52ea2d1db to your computer and use it in GitHub Desktop.
sequence diagram for reaction inventory data flow
title Inventory Data Flow
participant Kafka Topic
participant Shippable-Inventory-Plugin
participant Simple-Inventory-Plugin
participant Inventory
participant MongoDB SimpleInventory
participant MongoDB Products
participant MongoDB Orders
Kafka Topic -> Shippable-Inventory-Plugin:
note over Shippable-Inventory-Plugin:
Consumer calls bulk-write mutation.
This function is not defined in "Inventory" plugin
end note
Shippable-Inventory-Plugin -> Simple-Inventory-Plugin: updateSimpleInventoryBulk()
Simple-Inventory-Plugin -> MongoDB SimpleInventory: Bulk write to SimpleInventory collection
MongoDB SimpleInventory -> Simple-Inventory-Plugin: Returns result set
alt resulting inserts from batch operation
loop for Each inserted SimpleInventory Record
Simple-Inventory-Plugin -> MongoDB Orders: Reads count of new/processing Orders per sku
note right of Simple-Inventory-Plugin:
Calls recalculateReservedSimpleInventory function, which
calculates the reserved inventory based on number
of product variants that are in Orders marked as "new" or "processing".
This is saved in the SimpleInventory collection as `inventoryReserved`
end note
note right of Simple-Inventory-Plugin
Emits "afterInventoryUpdate" event
end note
end
else resulting updates from batch operation
note right of Simple-Inventory-Plugin:
Emits "afterBulkInventoryUpdate" event
This contains all update records from the batch
end note
Simple-Inventory-Plugin -> Inventory: handles afterBulkInventoryUpdate event
opt afterBulkInventoryUpdate()
note left of Inventory
Dedupe by productId to avoid
multiple updates on the same
top-level product
end note
loop for Each Product
Inventory -> Inventory: updateInventoryBooleansInCatalog()
Inventory -> MongoDB Products: Reads from Products collection.
Inventory -> MongoDB SimpleInventory: Reads from SimpleInventory collection.
Inventory -> MongoDB Catalog: Writes to Catalog collection.
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment