Configuration
1. Environment Variables
Source:
EnvironmentKeysin@nx/core/src/common/environments.ts. Service reads viaapplicationEnvironment.get<T>(key).
Core runtime
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
APP_ENV_PORT | number | 3000 | HTTP listen port (container) | |
APP_ENV_HOST | string | 0.0.0.0 | Bind address | |
APP_ENV_BASE_PATH | string | /v1/api/inventory | Route prefix | |
APP_ENV_NODE_ID | number | — | ✓ | Snowflake worker ID (must be 5 for inventory) |
APP_ENV_LOG_LEVEL | info|debug|warn|error | info | Logger level | |
APP_ENV_NODE_ENV | string | development | Loaded via dotenv-flow | |
RUN_MODE | migrate|server | migrate switches to migration entry |
Database
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
APP_ENV_DB_URL | string | — | ✓ | PostgreSQL connection URL |
APP_ENV_DB_POOL_MAX | number | 10 | Max pool size |
Redis (auth cache only)
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
APP_ENV_REDIS_HOST | string | — | Optional — if unset, auth cache disabled | |
APP_ENV_REDIS_PORT | number | 6379 | — | |
APP_ENV_REDIS_PASSWORD | string | — | — | |
APP_ENV_REDIS_DB | number | 0 | — |
Kafka
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
APP_ENV_KAFKA_BROKERS | csv | — | ✓ | Comma-separated broker list — service refuses to start if empty |
APP_ENV_KAFKA_CLIENT_ID | string | SVC-00050-INVENTORY_PRODUCER / _CONSUMER | Producer/consumer override | |
APP_ENV_KAFKA_GROUP_ID | string | SVC-00050-INVENTORY_CONSUMER_GROUP | Consumer group | |
APP_ENV_KAFKA_SASL_ENABLE | 'true'|'false' | false | Toggle SASL auth | |
APP_ENV_KAFKA_SASL_MECHANISM | enum | NA | When SASL enabled | |
APP_ENV_KAFKA_SASL_USERNAME | string | NA | When SASL enabled | |
APP_ENV_KAFKA_SASL_PASSWORD | string | NA | When SASL enabled |
Authentication
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
APP_ENV_JWKS_URL | url | — | ✓ | Identity service JWKS endpoint (/jw-certs) |
APP_ENV_BASIC_AUTH_* | string | — | Service-to-service basic creds (if enabled) |
2. Feature Flags
| Flag | Storage | Default | Description |
|---|---|---|---|
metadata.inventory.allowOversell | Material row | false | When true, adjustStock skips forceNonNegative guard for that material |
metadata.inventory.isInventoryTracked | Material row | true | When false, material is not seeded into InventoryItem on create |
No global feature-flag service today. Per-row metadata flags only.
3. Seeded Data
Migration processes in
src/migrations/processes/. All idempotent. Run on bootstrap (prestart→bun run rebuild→migrate.ts).
| File | Scope | Idempotency Key | Approx Rows | Notes |
|---|---|---|---|---|
inventory-0002-seed-permissions.ts | Permission (RBAC catalogue) | code | ~131 | Aggregates InventoryPermissions from 15 controller groups (controllers/permissions.ts) |
inventory-0003-seed-unit-of-measures.ts | UnitOfMeasure (system-wide, merchantId=NULL) | code | ~40 | Categories: COUNT (unit, pair, pack, dozen…), WEIGHT (kg, g, lb…), VOLUME (L, ml, gal…), TIME (sec, min, hr, day…); base unit per category has ratio=1 |
inventory-0004-seed-discrimination-types.ts | DiscriminationType (reference data) | (scope, type) | ~100 | Scopes: tracking_reason, tracking_reference_type, tracking_type, location_type, identifier_scheme, ticket_partner_type, material_type, material_identifier_scheme, uom_category, costing_method |
inventory-0005-backfill-vendor-item.ts | VendorItem materialization from PO history | (merchantId, vendorId, itemType, itemId) | one-shot | Snapshots latest non-cancelled PO line per group |
inventory-0006-backfill-merchant-id.ts | InventoryStock.merchantId denorm backfill | per row missing merchantId | one-shot | Populates from InventoryItem.merchantId |
Each seed file extends
MigrationProcessfrom@nx/coreand respectsalwaysRunflag. Backfills (0005,0006) are one-shot — re-execution is a no-op.
4. Configuration Storage (Configuration table)
N/A. Inventory does not use the per-merchant Configuration table for runtime configs (no encrypted credentials, no per-merchant feature toggles in this package).
5. Boot Order
6. Related Pages
- Operations — deployment + observability
- API Events — Kafka topic constants
- Decisions