Careeroza
Real World Example
The Product Page at Scale (Amazon / Flipkart Style)
A large e-commerce product page is built from dozens of services. Several patterns from this module work together:
| Page section | Source | Pattern |
|---|---|---|
| Title, price, images | catalog-service | API composition in the BFF (essential, short timeout) |
| Delivery date for your pincode | logistics-service | Composition with fallback ("Check delivery date") |
| Ratings summary, top reviews | review read model | CQRS: precomputed averages, not COUNT(*) on every view |
| Search results and filters | Elasticsearch | CQRS read model fed by product events |
| "Customers also bought" | recommendation-service | Optional section, loaded async, hidden on failure |
| Old seller dashboard | legacy monolith | Strangler fig: migrated route by route |
The Web BFF Endpoint
@GetMapping("/web/products/{id}")
public ProductPage productPage(@PathVariable long id, @RequestParam String pincode) {
// essential: fail the page if this fails
ProductDto product = catalog.get(id);
// optional sections: each has its own timeout and fallback
var delivery = optional(() -> logistics.estimate(id, pincode), DeliveryEstimate.unknown(), 300);
var reviews = optional(() -> reviewView.summary(id), ReviewSummary.empty(), 200);
var alsoBought = optional(() -> recommendations.alsoBought(id, 8), List.<ProductCard>of(), 250);
return new ProductPage(product, delivery.join(), reviews.join(), alsoBought.join());
}
private <T> CompletableFuture<T> optional(Supplier<T> call, T fallback, long timeoutMs) {
return CompletableFuture.supplyAsync(call, virtualThreads)
.completeOnTimeout(fallback, timeoutMs, TimeUnit.MILLISECONDS)
.exceptionally(ex -> {
log.warn("Optional section failed: {}", ex.toString());
return fallback;
});
}Note: The page loads in the time of the slowest essential call plus a small budget for optional ones. A broken recommendation engine never takes the "Buy Now" button down with it.