Skip to main content

Bounded context canvas

Following the ddd-crew Bounded Context Canvas v5. This is a read-only context: no command arrives, no event leaves. Messages are taken from the code and the specs on this branch.

Canvas at a glance​

Source: internal/adapters/inbound/{http,kafka,a2a}, internal/adapters/outbound/sources, docs/network-ohs-allowlist.yaml, apis/*.yaml.

Name​

Product Discovery (product-discovery, code PD, CloudEvents tier storefront).

Purpose​

The read side of browsing and search. One ProductView per catalogue item (title, flags, content, category path, list and effective price, inStock, purchasable) and one CategoryView (the browsable tree plus purchasable counts), fed by events from offer-availability, product-content and pricing, searched with PostgreSQL full-text search and pg_trgm behind a port.

Strategic classification​

AxisVerdict
DomainSupporting, a Core candidate at scale (Core domain chart)
Business modelConversion enabler: finding the right purchasable item fast
EvolutionCustom-built; the search engine slice is designed for swap

Domain roles​

RoleApplies?Evidence
Analysis (search and browse)Yes, primarythe projections and the search behaviour
Gateway (the storefront's catalogue reads)Yesthe only shopper-facing catalogue surface: the three REST reads, mirrored by two A2A skills
ExecutionNono command, no state machine
SpecificationNoprices, content and availability are the upstreams' facts

Inbound communication​

CollaboratorMessageTypeChannelRelationship
storefront-bffSearchProducts, GetProduct, ListCategoriesQueryREST GET /products, GET /products/{catalogItemId}, GET /categoriesOpen Host Service (this context is the host)
agentssearch_products, get_productQueryA2A JSON-RPC 2.0 on / and /a2aOpen Host Service (delegation channel, ADR 0007)
offer-availabilityCatalogItemCreated, CatalogItemDiscontinued, ListingCreated, ListingAvailabilityChanged, ListingSuppressed, ListingRestoredEventKafka retailnetwork.offer-availability.eventsConformist
product-contentProductContentPublished, ProductContentRetired, CategoryTreePublishedEventKafka retailnetwork.product-content.eventsConformist
pricingItemPriceChanged, ItemPriceWithdrawnEventKafka retailnetwork.pricing.eventsConformist

Outbound communication​

CollaboratorMessageTypeChannelRelationship
offer-availabilitylist catalogueQueryREST GET /catalog, rebuild onlyCustomer/Supplier (the network's Open Host Service)
offer-availabilitylist listingsQueryREST GET /listings, rebuild only, ops-only in-org read, never on a user requestdocumented exception (TestNoInOrgNetworkRoute)
pricinglist item pricesQueryREST GET /item-prices, rebuild onlyCustomer/Supplier
product-contentlist contents, list categoriesQueryREST GET /product-contents, GET /categories, rebuild onlyCustomer/Supplier

No event is published: no retailnetwork.product-discovery.events topic, no analytics topic. The only thing written to Kafka is the dead-letter record. Payloads: Domain events.

Ubiquitous language​

Top terms: Purchasable, Product View, Category View, In Stock, Stub, Monotonic guard, Product-type query. Full glossary: Ubiquitous language.

Business decisions​

  1. No aggregate in v1: projections only (ADR 0002). A wrong projection is rebuilt, not corrected by hand.
  2. Fixed ranking: tsvector weights title A, category names A (a query-time boost), attributes B, description and bullets C; pg_trgm is the typo fallback; facets are category, price band and in-stock.
  3. Product-type queries also return category suggestions: categories whose name covers every query word, shallowest first, at most 5.
  4. Out-of-order safety comes from per-source monotonic guards (listing asOf, content revision, price version, tree version) on top of the CloudEvents-id inbox.
  5. Bootstrap is snapshot plus catch-up (ADR 0003, ADR 0006): the rebuild job folds the producers' paged reads through the same rules; the consumers resume from their committed offsets.

Policies: PurchasableRule (View.Purchasable) and UnavailableNotBuyable (a row that is not purchasable is still shown, flagged; out-of-stock purchase is impossible in this network).

Assumptions​

The assumptions A1 to A18 are in ADR 0002. The ones that shape behaviour most: a suppress or restore for an unknown listing is skipped (A1); a stub is invisible (A2); a category filter covers the subtree (A3); price sorts and filters skip unpriced rows (A14); price bands are configurable (A15); a rebuild never rewinds a known listing state (A16).

Verification metrics​

MetricSource on this branch
Searches by outcome (served, empty, failed with reason)discovery.searches.served (Observability)
Request duration by routehttp.server.request.duration
Messages skipped or dead-lettered because they can never be applieddiscovery.kafka.poison_messages by consumer, disposition, reason
Consumer lag of the three groups, dead-letter depthKafka tooling; not exported by the service
Guard regressions (an older fact overwriting a newer one)0 by construction; pinned by the fold tests and the godog suite
Inbox duplicates acknowledgedprocessed_events rows
Rebuild countersthe rebuild finished log line

No latency targets are enforced in code; the Kong SLO alerts in warehouse-infra use 99 % availability and 95 % under 500 ms on the edge route.

Open questions​

  • No search analytics. Nothing is published, so query terms, zero-result and fallback rates are unobservable downstream; only the discovery.searches.served counter exists.
  • Silent staleness. There is no freshness metric and no alert on consumer lag or a silent topic.
  • Unbounded growth. processed_events and the dead-letter topics have no pruning job.
  • The listing snapshot is an in-org read. GET /listings has no storefront OHS equivalent; the exception is allowed only on the rebuild path.