Skip to main content

Product Discovery

product-discovery is a Storefront-area Supporting bounded context of the warehouse-systems fleet. It is the read side of browsing and search: it keeps one ProductView per catalogue item (title, flags, content, category path, list and effective price, inStock, purchasable) and one CategoryView (the browsable category tree plus purchasable counts), and it answers three questions for the shopper's storefront: which products match what I typed or filtered, what does this product page look like, and which categories can I browse. Both views are projections. The context owns no aggregate, takes no command, serves no write route and publishes no event (ADR 0001, ADR 0002).

The facts come from three producers over Kafka: the retail network's offer-availability (item master and listing availability), the storefront's product-content (content and the category tree) and pricing (prices). The context joins them into the single answer a shopper sees, above all the purchasable verdict (item active, content published, price active, at least one live listing with stock), which none of the three producers can give alone. A product that cannot be bought is still shown, as currently unavailable.

:::info What runs on this branch Four binaries: cmd/api (REST on :8080 plus three always-on Kafka consumers), cmd/a2a (a read-only Agent2Agent agent on :8093, ADR 0007), cmd/mcp (a read-only MCP server on :8090, ADR 0009) and cmd/rebuild (a one-shot snapshot backfill, shipped as an optional, default-off Helm Job, ADR 0006). It runs on real Postgres and real Kafka only: there is no in-memory mode, and DATABASE_URL, KAFKA_BROKERS and the three consumer group ids are mandatory. REST, A2A and MCP are unauthenticated fleet-wide. Packaging is the Helm chart charts/product-discovery and one image carrying all four binaries. :::

What the context owns​

ConceptWhere it livesRule in one line
ProductView (one row per catalogue item)internal/domain/productviewA value that facts are folded into, guarded per source: listing asOf, content revision, price version, all strictly monotonic. inStock and purchasable are recomputed on every fold.
Stub rowsameA fact for an item the item master has not announced creates an invisible row; CatalogItemCreated completes it (ADR 0002).
PurchasableRuleView.PurchasableItem ACTIVE, content PUBLISHED, price ACTIVE and at least one LIVE listing with availableQty > 0.
CategoryView (one tree)internal/domain/categoryviewOne published tree version, replaced wholesale when its version is strictly higher; purchasable counts are derived from ProductView and roll up the tree.
Searchinternal/domain/searchValidated Query, keyset Cursor, price Bands, Facets, trigram similarity. Run by PostgreSQL full-text search with a pg_trgm typo fallback behind the SearchPort.
ListingItemMaplisting_items tableThe read-side lookup listingId to catalogItemId, learned from ListingCreated and ListingAvailabilityChanged, used by ListingSuppressed and ListingRestored.
Inboxprocessed_events tableIdempotency on the CloudEvents id, written in the same transaction as the fold.

What it does not own​

Out of scopeBelongs to
The item master (title, dimensions, flags) and listing availability as factsoffer-availability (retail network)
Descriptions, media, attributes and the category tree itselfproduct-content
List prices, sale windows and the effective pricepricing
The cart, the checkout, paymentshopping-cart, checkout, customer-payments
Orders, reservations, delivery promisesthe retail network
Recommendations, reviews, personalisation, sponsored placementlater phases; ranking weights are fixed (title A, category names A, attributes B, description C)
Any write path, any published event, any analytics of what was searchednot in this context
Authenticationremoved fleet-wide; there is none to configure

Classification​

  • Supporting subdomain, Storefront area, CloudEvents tier storefront. The search engine itself is generic (PostgreSQL behind a port) and the competitive differentiation is the purchasable join, which is custom-built but not where the business wins; it is a Core candidate at scale (Subdomain classification).

Main capabilities​

  1. Search products (GET /products): full-text over title, category names, attributes and description, pg_trgm typo fallback on a first page that finds nothing, filters ANDed (categoryId subtree, inStock, priceMin, priceMax), four sorts, keyset paging, three facets (category, price-band, in-stock) and category suggestions for product-type queries.
  2. Read one product page (GET /products/{catalogItemId}): the full ProductView with the category path joined at query time.
  3. Browse the category tree (GET /categories) with purchasable counts per category.
  4. Fold eleven CloudEvents types from three topics into the projections, at least once with an atomic effect, idempotent on the event id and safe under replay and out-of-order delivery; unusable messages go to <topic>.dlq.
  5. Rebuild the projections from the producers' paged snapshot reads (cmd/rebuild), safe to run beside the live consumers.
  6. Delegate to agents over A2A: the skills search_products and get_product answer from the same use cases as REST.

Where to go next​

You want toRead
See the layers, packages, binaries and the rules that police themArchitecture
Run it and make the first callsQuickstart
Know every settingConfiguration
Deploy and operate itRunbook, Observability, Before the first release
Fix something that brokeTroubleshooting
Know what tests and CI gates existTesting
See who talks to whomIntegration
See the use cases and their invariantsUse cases
Read the design as ddd-crew artifactsDDD artifacts, Ubiquitous language
Read the contractsAPI overview, Event catalogue
Read the decisionsADR index

Published at https://iqvo.github.io/product-discovery/.

Disclaimer

This project is a domain-driven design study. It is not associated with, endorsed by or affiliated with any company, and it uses no company's code, data, logos or trademarks. All names, figures and examples are illustrative or synthetic.