Cart and checkout with Spring: the model, the transaction and never overselling
Designing Cart, CartItem, Order and OrderLine; merging lines when the same product is added twice; money as BigDecimal; placing an order in one transaction with a requestId against double clicks, an atomic stock decrement and a rollback when stock runs out; order status and order history without N+1. With a Spring Boot 3 lab verified by tests.