Skip to content

Integration

1. Sister Services

SisterDirectionSurfaceAuthFailure ModeIdempotency
@nx/saleKafka PAYMENT_SUCCESSat-least-once delivery; consumer skips processed via tracking lookup(SALE_ORDER, saleOrderId, stockId)
@nx/saleKafka KITCHEN_TICKET_ITEM_STATUS_CHANGEDat-least-onceper (saleOrderId, kitchenTicketItemId, materialId)
@nx/saleKafka MATERIAL_STOCK_CHANGEDpost-commit fire-and-forgetper stock event id
@nx/financeKafka PURCHASE_ORDER_RECEIVEDpost-commit fire-and-forget; only when payments[] non-empty(POREC, purchaseOrderId) consumer-side
@nx/commerceHTTP — direct call to InventoryService.createInventoryForProductVariant / updateInventoryForProductVariant (in shared TX)JWT (service-to-service)TX rollback on failureensureInventoryItem
@nx/commerce (CDC)Kafka CDC nx.seller.public.product_variant (Debezium)at-least-onceensureInventoryItem is idempotent
@nx/identity (CDC)Kafka CDC nx.seller.public.merchant (Debezium)at-least-onceensureDefaultLocation idempotent
@nx/identityHTTP — JWT verification via JWKS (/jw-certs)JWTretry / circuit-break (gateway)request-id propagated
@nx/identityHTTP — PolicyDefinitionService permission lookupJWTRedis cache fallbackper (role, action)
@nx/signalWebSocket emission via ApplicationWebSocketComponentbest-effort deliverynone (broadcast)

2. External Systems

N/A — inventory does not call any external (third-party) APIs directly. All third-party integrations (e.g., e-invoice, payment) are owned by other packages.

3. Critical Cross-Service Flows

3.1 Sale Payment → Stock Deduction (most critical)

Contract:

  • Sale guarantees PAYMENT_SUCCESS is emitted exactly once per status transition (post-commit).
  • Inventory guarantees idempotent processing per (saleOrderId, stockId).
  • Material reservation runs after product deduction within the same handler call (sequential, not parallel).

3.2 PO Receive → Finance Expense Recording

Contract:

  • Stock + tracking + vendor snapshot are atomic (single TX).
  • Kafka emit happens AFTER commit — if emit fails, finance is notified via reconciliation job (TBD), not in-band rollback.
  • Finance treats PURCHASE_ORDER_RECEIVED as authoritative: idempotent on (POREC, purchaseOrderId).

3.3 Merchant Onboarding → Default Location Seed

Contract: idempotent. Re-delivery causes no-op.

3.4 ProductVariant Create → Inventory Seed

Two parallel paths:

Path A — direct HTTP (synchronous, in commerce's TX):

Path B — CDC (asynchronous, retroactive):

Both paths converge on the same idempotent ensureInventoryItem upsert.

4. Contract Stability

SurfaceStabilityVersioning
HTTP /v1/api/inventory/*stableURL prefix /v1/
Kafka topic payment.successstablepayload field-additive only
Kafka topic purchase-order.receivedstablepayload field-additive only
Kafka topic material.stock-changedbetamay add fields
Kafka topic material.transferredbeta
CDC topics (nx.seller.public.*)stablecontrolled by Debezium config
WebSocket topic observation/inventory/inventory-stockstableroom paths versioned

Proprietary and Confidential. Unauthorized copying, distribution, or use of this software is strictly prohibited.