PIM

PIM - Domain Events & Integration Contracts

Comprehensive catalog of emitted domain events, downstream integration contracts, and asynchronous event choreography for the PIM domain.

Domain Events & Integration Contracts

In Domain-Driven Design, Domain Events represent significant business facts that have occurred within the domain. As emphasized in Vlad Khononov’s Learning Domain-Driven Design, domain events are immutable historical records. Once dispatched, they cannot be altered or retracted.

The PIM bounded context communicates with downstream operational engines primarily through asynchronous domain events. When a product is created, a variant updated, or an engineering BOM revision approved, PIM broadcasts an event over the enterprise event bus. Downstream bounded contexts—such as Warehousing, Sales, Point of Sale, and Manufacturing—subscribe to these events and materialize local projections according to their own business rules, eliminating tight database-level coupling.


1. Domain Event Delivery Guarantees

To ensure bulletproof reliability across distributed enterprise architectures, PIM implements the Transactional Outbox Pattern:

sequenceDiagram
    participant Aggregate as Product Aggregate
    participant Outbox as Transactional Outbox
    participant Relay as Event Relay Worker
    participant Bus as Enterprise Message Bus
    participant Downstream as Downstream Subscribers

    rect rgb(245, 245, 255)
        Note over Aggregate,Outbox: Atomic Database Transaction
        Aggregate->>Aggregate: Apply State Mutation & Enforce Invariants
        Aggregate->>Outbox: Persist Domain Event in Outbox Table
    end
    Relay->>Outbox: Poll Uncommitted Events
    Relay->>Bus: Dispatch Event (At-Least-Once Delivery)
    Bus->>Downstream: Distribute to Subscribed Handlers
    Downstream->>Downstream: Idempotent Event Processing (Deduplicate via Event ID)
    Relay->>Outbox: Mark Event as Dispatched

Core Event Architectural Standards

  • At-Least-Once Delivery: Events are guaranteed to be published to the message broker. Subscribers must implement idempotent message handling using unique event_id keys.
  • Envelope Metadata: Every emitted event payload encapsulates standardized envelope headers:
    • event_id: Unique UUIDv4 identifier for deduplication.
    • correlation_id: Distributed tracing identifier linking chained cross-domain activities.
    • causation_id: The identifier of the command or antecedent event that caused this event.
    • occurred_at: Microsecond-precision UTC timestamp.
    • schema_version: Explicit version number supporting backward-compatible evolution.

2. Catalog of Emitted Domain Events

The table below catalogs the authoritative domain events emitted by the PIM bounded context:

Event NameBusiness TriggerConceptual Payload Key AttributesDownstream Enterprise Subscribers
ProductCreatedInitial product shell (SPU) instantiated.product_id, handle, family_code, brand_id, master_category_code, status.Audit Service, Catalog Indexer.
ProductEnrichedMarketing copy or localized attributes updated.product_id, channel_scope, locale, changed_attributes_map.Storefronts, Cache Purge Worker.
ProductFamilyAssignedAttribute Family schema bound to product.product_id, family_code, applied_attribute_groups.Merchandising UI, Validation Engine.
ProductStatusChangedLifecycle state transition executed.product_id, previous_state, new_state, actor_id, reason_code.Workflow Engine, Audit Service.
ProductPublished100% completeness passed; item goes live.product_id, target_channel, effective_date, active_variant_skus, completeness_score.Sales / OMS, Storefronts, POS, WMS, Accounting.
ProductSuspendedEmergency commercial quarantine initiated.product_id, suspension_reason, actor_id, timestamp.Storefront CDN, POS Registers, Marketplaces.
ProductDeprecatedDiscontinuation declared; sell-down active.product_id, sunset_date, superseding_sku, allow_backorders: false.Sales / OMS, Purchasing, Storefronts.
ProductArchivedTerminal retirement committed.product_id, archival_timestamp, zero_stock_verification_checksum.ERP Core, Data Warehouse, Master Catalog.
VariantCreatedConcrete physical SKU generated.variant_id, sku_code, product_id, option_values_map, dimensions, weight, base_uom.Inventory / WMS, Sales / OMS, Accounting.
VariantUpdatedPhysical dimensions, weight, or prices updated.variant_id, sku_code, updated_dimensions, updated_weight, variant_price_override.Inventory / WMS, Freight TMS, Sales / OMS.
VariantBarcodeAssignedValidated GS1 barcode linked to variant.variant_id, sku_code, barcode, symbology (EAN13, UPCA).Point of Sale (POS), Inventory / WMS.
VariantDeactivatedSpecific SKU removed from sale.variant_id, sku_code, deactivation_reason.Sales / OMS, Storefronts, POS.
AttributeFamilyCreatedReusable attribute family template registered.family_code, family_label, attribute_codes_list, validation_rules.Schema Registry, Merchandising UI.
CategoryTreeUpdatedHierarchy nodes restructured or moved.tree_code, affected_node_ids, parent_node_mapping.Storefront Navigation, Reporting Engine.
ProductCategorizedProduct assigned to category leaf node.product_id, tree_code, category_id, is_master_leaf.Corporate Reporting, Search Indexes.
MediaAssetAttachedVisual asset or document linked with a role.target_entity_type, target_id, asset_id, asset_role, file_url.Digital Storefronts, POS Touchscreens, CDN.
MediaAssetRemovedMedia asset association severed.target_entity_type, target_id, asset_id, asset_role.CDN Purge Engine, Image Cache.
CompletenessEvaluatedReadiness calculation executed for channel.product_id, channel_code, locale, score_percentage, missing_fields_list.Merchandising QA Dashboard.
BOMRevisionApprovedEngineering sign-off on assembly recipe.product_id, finished_sku, revision_tag, components_list (sku, gross_qty, scrap_rate).Manufacturing / MRP, Subcontracting.

3. Downstream Integration Contracts & Reactions

Downstream bounded contexts subscribe to PIM domain events to drive local operational workflows while maintaining domain isolation:

flowchart LR
    PIM["PIM Domain Events"] --> Bus["Enterprise Event Bus"]

    Bus -->|"VariantCreated / Updated"| WMS["Inventory / WMS<br/>Master Item Setup"]
    Bus -->|ProductPublished| OMS["Sales / OMS<br/>Sellable Catalog Snapshot"]
    Bus -->|VariantBarcodeAssigned| POS["Point of Sale (POS)<br/>Scanner Memory Cache"]
    Bus -->|BOMRevisionApproved| MRP["Manufacturing / MRP<br/>Work Order Routing"]
    Bus -->|ProductPublished| Web["Storefronts & CDN<br/>Edge Cache & Search Index"]

Inventory / Warehouse Management (WMS) Integration

Subscribed EventDownstream Action Executed in WMSMaterialized Enterprise Result
VariantCreatedInstantiates a new Warehouse Master Item profile with dimensions, weight, and handling flags.New warehouse SKU profile created.
VariantUpdatedUpdates volumetric package dimensions ($L \times W \times H$) and gross weight in bin-allocation algorithms.Storage profile refreshed; bin capacity recalculated.
VariantBarcodeAssignedRegisters optical barcode in warehouse scanner gun lookup tables.Receiving and picking scanner index updated.
VariantDeactivatedMarks warehouse SKU as non-replenishable; rejects new inbound receiving docks.Inbound receiving dock blocked.
ProductArchivedValidates physical stock balance is exactly zero; decommission SKU permanently.Warehouse item record sealed read-only.

Boundary Demarcation

  • PIM owns: Packaged dimensions, gross weight mass, storage UOM, and optical barcodes.
  • WMS owns: Shelf bin coordinates, picking paths, cycle count audits, and real-time physical quantity balances.

Sales / Order Management (OMS) Integration

Subscribed EventDownstream Action Executed in OMSMaterialized Enterprise Result
ProductPublishedAdds product and active variant SKUs to the sellable catalog search index.Live sales catalog snapshot refreshed.
VariantUpdatedUpdates baseline MSRP prices in order line validation caches.Order line pricing validator updated.
ProductDeprecatedDisables backorders; limits order line quantities to on-hand inventory availability.Sell-down flag applied; backorders blocked.
ProductArchivedDelists SKU completely from sales quotation engines and repeat order templates.Order line creation prohibited.

Boundary Demarcation

  • PIM owns: Master merchandise specifications, variant definitions, and baseline catalog MSRP.
  • OMS owns: Customer tier discounts, promo code engines, contractual order promises, and fulfillment dispatch.

Point of Sale (POS) Frontline Integration

Subscribed EventDownstream Action Executed in POSMaterialized Enterprise Result
ProductPublishedSyncs item title, SKU, and tax category to local register offline database.Local checkout register database refreshed.
VariantBarcodeAssignedIngests barcode-to-SKU mapping into the in-memory fast scanner table.Ultra-low-latency laser scanner index updated.
MediaAssetAttachedDownloads thumbnail asset tagged with swatch_icon or hero_image for cashier touchscreen buttons.POS touchscreen button graphic updated.
ProductSuspendedImmediately flags barcode as suspended; blocks scan at cash register checkout.Barcode scan locked at POS register.

Boundary Demarcation

  • PIM owns: Canonical barcodes, merchandise descriptions, and default tax classification codes.
  • POS owns: Cash drawer sessions, cashier authentication, receipt printing, and split tender processing.

Manufacturing (MRP) & Subcontracting Integration

Subscribed EventDownstream Action Executed in MRPMaterialized Enterprise Result
BOMRevisionApprovedBinds approved recipe revision to work order generation routes and bill-of-materials explosion.Active production formulation locked.
BOMRevisionApprovedIn Subcontracting, updates purchase order component dispatch ratios for external assembly partners.Subcontractor material dispatch ratio updated.
ProductDeprecatedCancels future scheduled production runs; halts raw material replenishment triggers.Manufacturing schedule purged of retired SKU.

Boundary Demarcation

  • PIM owns: Multi-level BOM component trees, consumption quantities, scrap allowances, and engineering revision tags.
  • MRP owns: Factory work center routing, machine schedules, worker labor shifts, and physical material staging.

E-Commerce Storefronts & Digital Channels

Subscribed EventDownstream Action Executed in Digital ChannelsMaterialized Enterprise Result
ProductPublishedTransforms channel-scoped DTO and indexes document in search engines (e.g., Elasticsearch, Meilisearch).Public storefront search index updated.
ProductPublishedDispatches instant edge cache purge requests to CDN providers for Product Detail Pages (PDP).Fresh page rendered for digital shoppers.
MediaAssetAttachedTriggers asynchronous image processing pipeline to generate responsive WebP and AVIF formats.Responsive image CDN assets generated.
ProductDeprecatedInjects HTTP 301 / 308 permanent redirect headers pointing to the designated superseding_sku.Search engine SEO equity preserved.

Our Premium Sponsors

Obelaw is proudly open-source. Continued development, bug fixes, and community support are made possible by the generosity of our sponsors.

Sponsor Obelaw