RailsEventStore / ecommerce

Application with CQRS and Event Sourcing built on Rails and Rails Event Store
MIT License
421 stars 70 forks source link

Fixing choreography issues: Ordering<->Inventory #225

Closed pjurewicz closed 1 year ago

pjurewicz commented 1 year ago

There are some design issues with choreography across bounded contexts.

We want to eliminate them, starting with Ordering and Inventory BCs. OrderingProcess needs to be introduced. Goal architecture: exploring ecommerce-4

After going fully async, we will need to take care of UI. Changes from domains can be broadcasted to the users asynchronously with turbo streams (just like read model).

pjurewicz commented 1 year ago

Adding an item may be a process too.

exploring ecommerce-5

pjurewicz commented 1 year ago

I've been thinking about it for some time. In fact, when an item is added to the cart, we check its availability only for UX reasons. In this step, no reservation is made. Aggregate's step stays unchanged. I can see now that the currently existing CheckAvailability command does not make sense. We can safely move this checking to the read model. Updated diagram: exploring ecommerce-6

pjurewicz commented 1 year ago

This one is almost done. However, I am wondering now if it is not too complicated. In fact, Reserve and CancelReservation operations will always be synchronous. We always do commands in a synchronous manner. So that, StockReserved and CanceledStockReservation do not need to invoke ReservationProcess. We already know if it succeeds or not when we dispatch the reserve command.

Let's try to simplify this.

exploring ecommerce-7

pjurewicz commented 1 year ago

Merged to master. Now it is time to go async with this process.