ADR-002: Publish feedback events for Catalog's rating projection
Rating publishes committed feedback-created and feedback-deleted events so Catalog can maintain its own eventually consistent rating summary.
1. Context & Problem
Catalog product listings need to show each book’s average rating and total review count, but querying ReviewsDomainv1.0.0ReviewsCaptures individual customer feedback for books, publishes rating changes for Catalog discovery, and provides privacy-sc...Ownercatalog-experience-teamDiagramOpen docs on every storefront page load would tie Catalog’s speed and uptime directly to the Reviews service. Conversely, giving Catalog direct access to FeedbackEntityv1.0.0FeedbackRepresents an individual customer's rating and optional written review for a Catalog book.Ownercatalog-experience-teamOpen docs records or copying full reviews into Catalog would break domain ownership and duplicate customer content unnecessarily.
The two domains therefore need an integration mechanism that communicates just enough information to keep Catalog’s rating summary up to date without sharing databases, blocking storefront reads, or exposing full review text.
2. Business Value
- Uninterrupted product discovery: Storefront browsing stays fast and available even if Reviews experiences heavy load or temporary maintenance.
- Minimal data exposure: Only the book reference, feedback reference, and numeric rating are shared—keeping reviewer details and comments private to Reviews.
- Independent evolution: Reviews and Catalog can each manage and scale their own data stores independently.
- Clear accountability: Reviews remains responsible for individual feedback accuracy, while Catalog owns its product-facing rating projection.
3. How It Works
Whenever the Rating service commits a new feedback entry or removes an existing one, it publishes a lightweight integration notice to the messaging bus:
- Commit first, then notify: The feedback change is saved in Reviews before any notice is sent, ensuring Catalog never reacts to changes that failed to save.
- Minimal payload: Each notice carries only the BookEntityv1.0.0BookCanonical sellable title in the product catalog, encapsulating descriptive metadata, pricing, stock availability, taxono...Ownercatalog-experience-teamOpen docs reference, FeedbackEntityv1.0.0FeedbackRepresents an individual customer's rating and optional written review for a Catalog book.Ownercatalog-experience-teamOpen docs reference, and rating value needed to adjust Catalog’s average rating and review count. Comments and reviewer details are omitted.
- Ordered and retry-safe delivery: Related notices for the same book and feedback are grouped to preserve order where possible. Because the messaging bus guarantees delivery at least once, Catalog is designed to handle duplicate or retried notices safely without counting the same review twice.
- Independent projection update: Catalog updates its own local rating summary on its own schedule without ever reading Rating DatabaseContainerv1.0.0Rating DatabaseAuthoritative Azure Cosmos DB system of record owned by the Reviews bounded context for customer feedback documents part...Ownercatalog-experience-teamDiagramOpen docs directly.
4. Trade-offs & Lessons Learned
- Eventual consistency: A successful feedback submission does not mean Catalog’s displayed average rating updates instantaneously; a brief lag can occur while messages are delivered and processed.
- Duplicate-safe consumers are mandatory: At-least-once delivery means the same creation or deletion notice can arrive more than once. Applying rating adjustments must be idempotent so duplicates never inflate or distort review counts.
- Contract governance: Event structures and identifiers form a shared contract between Reviews and Catalog. Changing emitted fields or delta rules requires coordinated updates across both teams.
- Operational monitoring: Teams must monitor messaging delivery and consumer lag, since projection freshness depends on healthy asynchronous processing.
Alternatives Considered
- Query Rating synchronously for every Catalog read: Rejected because Catalog read latency and availability would depend on Reviews, coupling storefront discovery to feedback ownership.
- Copy complete feedback records into Catalog: Rejected because it would unnecessarily duplicate Reviews-owned comments and reviewer details.
- Update the Catalog projection through direct database access: Rejected because direct writes bypass Catalog’s domain ownership and persistence boundaries.
5. Technical Reference
- Producer: Rating APIServicev1.0.0Rating APIInternal HTTP and A2A gRPC service for collecting, listing, deleting, and summarizing customer feedback for Catalog book...PublishesFeedbackCreatedIntegrationEvent, FeedbackDeletedIntegrationEventSubscribesCreateFeedback, DeleteFeedback +3APIsOpenAPI, AsyncAPIOwnercatalog-experience-teamDiagramRepositoryOpen docs publishes integration events only after the local transaction commits in Rating DatabaseContainerv1.0.0Rating DatabaseAuthoritative Azure Cosmos DB system of record owned by the Reviews bounded context for customer feedback documents part...Ownercatalog-experience-teamDiagramOpen docs.
- Events & channels (Kafka):
- Feedback createdEventv1.0.0Feedback createdIndicates that a customer feedback rating was created for a book. Rating API
publishes this event so Catalog can update ...Ownercatalog-experience-teamSchemaDiagramOpen docs on
bookworm.{env}.rating.feedback-create - Feedback deletedEventv1.0.0Feedback deletedIndicates that a customer feedback rating was deleted for a book. Rating API
publishes this event so Catalog can remove ...Ownercatalog-experience-teamSchemaDiagramOpen docs on
bookworm.{env}.rating.feedback-delete
- Feedback createdEventv1.0.0Feedback createdIndicates that a customer feedback rating was created for a book. Rating API
publishes this event so Catalog can update ...Ownercatalog-experience-teamSchemaDiagramOpen docs on
- Event payload scope: Carries the book ID, feedback ID, and rating (excludes comment text and reviewer details).
- Messaging semantics:
- Delivery guarantee: At-least-once; Catalog consumers must be idempotent under retries and duplicate delivery.
- Partitioning: Partitioned by book and feedback identifiers to preserve ordering for related updates where possible.
- Related ADR:
adr-006-reviews-rating-projection-on-book(Catalog side).