Skip to main content

SCM packages

Supply Chain Management (SCM) modules share a common runtime bootstrap pattern and export loop participant manifests for the Loop Engine graph.

Module interface (factory / runtime pattern)

1. Configure the runtime once

At application startup, call the package configure*Runtime with infrastructure dependencies (getDb, outbox, readChannelMessages).
import { configureInventoryRuntime } from "@betterdata/scm-inventory";
import type { ChannelReader, OutboxWriter } from "@betterdata/scm-contracts";

const outbox: OutboxWriter = {
  async write(entry, tx) {
    /* persist outbox row in same transaction as domain write */
  },
};

const readChannelMessages: ChannelReader = async (args) => {
  /* load channel messages for worker consumption */
};

configureInventoryRuntime({
  getDb: () => prisma,
  outbox,
  readChannelMessages,
});
Other SCM packages expose parallel entry points:
  • configureProcurementRuntime@betterdata/scm-procurement
  • configureExecutionRuntime@betterdata/scm-execution
Catalog-focused flows use adapter seams documented in each package README.

2. Call domain services

import { StockService } from "@betterdata/scm-inventory";

const result = await StockService.reserveStock({
  /* domain input — see package types */
});

Loop participation

Every SCM module ships a *LoopParticipant manifest typed as LoopParticipantManifest from @betterdata/loop-definitions.
import { inventoryLoopParticipant } from "@betterdata/scm-inventory";
import { EventNames, LoopIds } from "@betterdata/loop-definitions";

// inventoryLoopParticipant.moduleId === "scm.inventory"
// Example handler binding:
// { event: EventNames.EXECUTION_GOODS_RECEIVED, loops: [LoopIds.SCM_PROCUREMENT, LoopIds.SCM_FULFILLMENT] }
@betterdata/loop-actors includes validation tests so participants only reference known LoopIds and EventNames.

Package list

PackageWhat it does
@betterdata/scm-contractsShared types, event envelopes, OutboxWriter, ChannelReader, runtime helpers
@betterdata/scm-inventoryStock, lots, reservations, QOH, availability
@betterdata/scm-procurementPO lifecycle, invoice alignment hooks
@betterdata/scm-executionShipments, pick/pack/ship/receive
@betterdata/scm-catalogProduct masters, marketplace search, normalizers
Event contracts are centralized in domain contracts.

Key exports (high level)

@betterdata/scm-inventoryStockService, reservation helpers, LotService, inventoryLoopParticipant, configureInventoryRuntime. @betterdata/scm-catalog — product resolution, marketplace search services, catalogLoopParticipant, adapter interfaces for ranking and trust. @betterdata/scm-procurement — procurement services, loop-participation / preload-contribution, configureProcurementRuntime. @betterdata/scm-execution — shipment and warehouse engines, configureExecutionRuntime, execution loop participation.