Uses Spring Modulith https://spring.io/projects/spring-modulith/
catalog: product details management & searchorder: order workflowinventory: stock and reservationscustomerdatashipping
A module can only reference by default the classes in the top-level package of other modules. A class in any subpackage (eg. impl) is considered implementation detail, and it should NOT be accessed from outside that module. Extra packages can be exposed via @NamedInterface
Modules cannot form dependency cycles.
index.adoc contains a diagram of the module interactions generated at each test run.
Expand the hints if needed, and keep running ArchSpringModulithTest:
- In
GetProductApireturn the stock in the response.
catalogshould not access any internal class ofinventorymodule (run tests).- Enable and Pass
GetProductE2ETest. -
Hint
Retrieve the stock item number via a call to a new method in `InventoryInternalApi`
- Extract payment-related classes out of
ordermodule into a newpaymentmodule.
- Fix the encapsulation violation and the dependency cycle introduced.
-
Hint to fix 'non-exposed..':
Code having to do with the `order` internals should stay in `order`. -
Hint to fix cycle:Solution#1
Have a `PaymentCompletedEvent` thrown from payment back into order -
Hint to fix cycle:Solution#2
Introduce an interface in one of the modules implemented in the other (aka Dependency Inversion). Which module should hold the interface?
-
- Encapsulate the new
paymentmodule: hide as many classes exposing as few classes to other modules-
Hint
Move classes in a subpackage, like 'impl'
-
-
SearchProductApishould only return products in stock- Test
SearchProductsApiTestshould pass.
-
Option
Search for matching products and join in-memory with all stock. Or vice-versa. -
Option
JOIN Stock via SQL/JPQL😐 -
Option
Replicate stock item number at every change via events from `inventory` -
Option
Publish `OutOfStockEvent` and `BackInStockEvent` from `inventory`, updating a `Product.inStock` boolean; -
Option
Join the Product with the StockView @Entity exposed by `inventory`
- Test
-
Notifications
-
When payment is confirmed
-
Hint - code snippet
public void onOrderStatusChanged(OrderStatusChangedEvent event) { String customerEmail = customerModule.getCustomer(event.customerId()).email(); if (event.status() == OrderStatus.PAYMENT_APPROVED) { sendPaymentConfirmedEmail(event, customerEmail); } if (event.status() == OrderStatus.SHIPPING_IN_PROGRESS) { sendOrderShippedEmail(event, customerEmail); } }
-
-
Move Reviews-related stuff out of
catalogmodule- tests should pass