Digital storefront · Supporting domain · EventStorming board
shopping-cart
Holds a shopper's cart before checkout: lines, destination, chosen delivery offers and a non-binding estimate. Closes the cart once checkout completes.
- events published
- 4
- commands
- 16
- policies
- 7
- read models
- 5
- hot spots
- 4
The story in 4 key events
The pivotal events: the few that matter most, in the order they happen.
- Pivotal eventCart
Line Added - Pivotal eventCart
Delivery Quoted - Pivotal eventCart
Checked Out - Pivotal eventCart
Abandoned
Listens to (3): contexts whose events this one reacts to
Tells (0): contexts that react to its events
none
The board, row by row
16 rows, in the order the business story happens: the main path first, then how this context reacts to the others, then the clock. Rows are small stories; read each one left to right.
- Event
- Command
- Actor
- Aggregate
- Policy
- Read model
- External system
- Hot spot
- Opportunity
-
Start a cart
A shopper, signed in or not, opens an empty cart. Nothing is announced to other contexts.
ActorShopperCommandCreateCart POST /cartsAggregateCartSource: application/usecases/cart_commands.go · domain/cart/cart.go
-
Add an item to the cart
The shopper adds an item. It must be known, priced and not discontinued. Adding an item already in the cart merges the quantities, which must stay between 1 and 99.
ActorShopperRead modelPurchasable itemsCommandAddLine POST /carts/{cartId}/linesAggregateCartEventCartLine analytics stream onlyAdded Source: application/usecases/cart_commands.go · domain/cart/lines.go · domain/cart/events.go
-
Change a quantity
The shopper sets a new quantity for a line. Any change to the lines throws away the delivery offers and selections, so they have to be asked for again.
ActorShopperCommandSetLine PUT /carts/{cartId}/lines/{catalogItemId}Quantity AggregateCartSource: application/usecases/cart_commands.go · domain/cart/lines.go
-
Remove an item
The shopper removes a line. Like any change to the lines, it clears the delivery offers and selections. Nothing is announced.
ActorShopperCommandRemoveLine DELETE /carts/{cartId}/lines/{catalogItemId}AggregateCartSource: application/usecases/cart_commands.go · domain/cart/lines.go
-
Say where it should be delivered
The shopper gives a destination postal prefix. Until then the estimate shows only the item total; delivery and tax appear once a destination is set.
ActorShopperCommandSetDestination PUT /carts/{cartId}/destinationAggregateCartSource: application/usecases/cart_commands.go · domain/cart/cart.go · domain/estimate/estimate.go
-
Get delivery offers
The cart asks delivery-promise for delivery offers for its lines and destination, and keeps them. Offers hold no capacity, they are facts frozen at quote time.
ActorShopperRead modelDelivery offers asked from delivery-promiseCommandQuoteDelivery POST /carts/{cartId}/delivery-quotesAggregateCartEventCartDelivery analytics stream onlyQuoted Source: application/usecases/quote_delivery.go · domain/cart/quote.go · domain/cart/events.go
-
Choose a delivery offer
The shopper picks one offer for each shipment group. An offer that is not part of the current quote is refused. The cart is ready for checkout when every group has an offer and none has expired.
ActorShopperCommandSelectDelivery PUT /carts/{cartId}/delivery-selectionAggregateCartSource: application/usecases/cart_commands.go · domain/cart/delivery.go
-
Merge a guest cart after sign-in
When a guest signs in, the guest cart's lines move into the shopper's open cart and the guest cart is closed as merged. Quantities add up, capped at 99.
ActorShopperCommandMergeInto POST /carts/{cartId}/mergesAggregateCartSource: application/usecases/cart_commands.go · domain/cart/lifecycle.go
-
Take over the offers of a checkout requote
When checkout finds that the offers have to be requoted, it can write the new ones into the cart. They replace the quote and are selected for every group, with no call to delivery-promise.
ActorCheckout, for a shopperCommandAcceptRequoted POST /carts/{cartId}/delivery-requote-acceptancesOffers AggregateCartSource: application/usecases/cart_commands.go · domain/cart/requote.go
-
Keep the item list
offer-availability announces new and discontinued catalogue items. The cart keeps a copy of which items exist and which are discontinued, so adding an item needs no live call.
Systemoffer-availability EventCatalogItem Created PolicyWhenever an item is created or discontinued, update what the cart knows of itCommandApplyCatalog started by the policyItem Created Read model · kept up to datePurchasable itemsSource: application/usecases/consume.go · adapters/inbound/kafka/handlers.go
-
Keep the item prices
pricing announces each item's current price, and withdraws it when an item can no longer be sold. The cart keeps the newest price, and an item without a price cannot be added.
SystempricingEventItemPrice Changed PolicyWhenever a price changes or is withdrawn, keep it if its version is newerCommandApplyItem started by the policyPrice Changed Read model · kept up to datePurchasable itemsRead model · kept up to dateEstimate pricesSource: application/usecases/consume.go · adapters/inbound/kafka/handlers_pricing.go
-
Keep the delivery charges
pricing publishes the charge for each delivery speed. The cart replaces its copy and uses it to estimate the delivery cost. Only the estimate moves; the cart's own delivery offers are left alone.
SystempricingEventDeliveryCharge Schedule Changed PolicyWhenever a charge schedule is published, replace the stored one if it is newerCommandApplyDelivery started by the policyCharge Schedule Changed Read model · kept up to dateEstimate delivery chargesSource: application/usecases/consume.go · adapters/inbound/kafka/handlers_pricing.go
-
Keep the tax rates
pricing publishes the tax rates by destination postal prefix. The cart replaces its copy and uses it for the estimate, which is labelled non-binding.
SystempricingEventTaxTable Changed PolicyWhenever a tax table is published, replace the stored one if it is newerCommandApplyTax started by the policyTable Changed Read model · kept up to dateEstimate tax ratesSource: application/usecases/consume.go · adapters/inbound/kafka/handlers_pricing.go
-
Close the cart when checkout completes
checkout reports that the purchase went through. The open cart is closed as checked out. A cart that is unknown or not open only gets a warning in the log.
SystemcheckoutEventCheckoutCompleted PolicyWhenever a checkout completes, close the cart as checked outCommandCloseOn started by the policyCheckout Completed AggregateCartEventCartChecked analytics stream onlyOut Source: application/usecases/consume.go · domain/cart/lifecycle.go · adapters/inbound/kafka/handlers.go
-
Abandon carts nobody touches
A sweep closes every open cart that has not changed for 30 days as abandoned and announces it.
TimeAbandon sweepPolicyEvery sweep, an open cart unchanged for 30 days is abandonedCommandAbandonInactive started by the clockAggregateCartEventCartAbandoned analytics stream onlySource: application/usecases/policies.go · domain/cart/lifecycle.go · adapters/inbound/scheduler/scheduler.go
-
Delete old closed carts
A second sweep deletes carts that are no longer open and have not changed for 30 days. Nothing is announced, so an idle cart is gone about 60 days after its last change.
TimePurge sweepPolicyEvery sweep, a closed cart unchanged for 30 days is deletedCommandPurgeAbandoned started by the clockCarts Source: application/usecases/policies.go · adapters/inbound/scheduler/scheduler.go
Hot spots and opportunities
Open questions and known gaps, each taken from a decision record or a document in the repository, never invented. Opportunities are improvements the documentation already names.
- Hot spotOnly adding a line, quoting, abandoning and checking out publish an event. Removals, quantity changes, destinations, selections and merges raise nothing.
Source: docs/ddd/eventstorming.md
- Hot spotThe cart accepts any known, priced, undiscontinued item without checking stock. It is lenient on purpose: checkout's binding price quote is the gate.
Source: docs/ddd/eventstorming.md
- Hot spotNo context reads the cart's events. Whether a sibling should ever consume one is undecided.
- Hot spotThe route that lets checkout write a requote into the cart has no caller yet in the local checkouts.
Opportunities
- OpportunityPromotions inside the estimate are a later phase and would add complexity to the cart.
- OpportunityA deferred identity context would take over the guest-first shopper ids and the cart merge the cart handles today.
This board is a reconstruction from the code and documentation of shopping-cart at origin/develop, not a workshop output. Roles are the ones the documentation names. How the boards were made.