Skip to content

Configuration

1. Environment Variables

Core keys inherited from @nx/core EnvironmentKeys; ledger-specific keys in src/common/environments.ts.

Core (selected)

NameTypeDefaultRequiredDescription
APP_ENV_PORTnumber3000HTTP listen port (external 31060)
APP_ENV_BASE_PATHstring/v1/api/ledgerRoute prefix
APP_ENV_NODE_IDnumber-Snowflake worker ID (6)
APP_ENV_DB_URLstring-PostgreSQL connection
APP_ENV_S3_BUCKETstringledgerTarget S3 bucket
RUN_MODEstring-migrate short-circuits component/service/controller registration

Kafka

NameTypeDefaultRequiredDescription
APP_ENV_KAFKA_BROKERSstring-Comma-separated brokers
APP_ENV_KAFKA_CLIENT_IDstringSVC-00060-LEDGERProducer/consumer client id
APP_ENV_KAFKA_GROUP_IDstringSVC-00060-LEDGER_GROUPConsumer group
APP_ENV_KAFKA_CONSUMER_COUNTnumber1*Worker consumer instances
APP_ENV_KAFKA_SASL_ENABLEbooleantrueToggle SASL
APP_ENV_KAFKA_SASL_MECHANISMstringSCRAM-SHA-512SASL mechanism
APP_ENV_KAFKA_SASL_USERNAME / _PASSWORDstring-SASL credentials

* int() of an unset value - set explicitly for >1.

WebSocket (worker role)

NameTypeDefaultDescription
APP_ENV_WEBSOCKET_REDIS_MODEsingle|clustersingleEmitter Redis topology
APP_ENV_WEBSOCKET_REDIS_HOST / _PORT / _PASSWORD / _DB-localhost/6379/-/0Single-mode connection
APP_ENV_WEBSOCKET_REDIS_CLUSTER_NODESstring-Cluster-mode nodes (required if cluster)
APP_ENV_WEBSOCKET_REDIS_IDENTIFIER / _MAX_RETRY-ledger-ws-redis/5-

Service-specific

NameTypeDefaultDescription
APP_ENV_APPLICATION_ROLESstringapi,workerCSV of api/worker; invalid/empty falls back to both
APP_ENV_LEDGER_ENCRYPTION_KEYstring-AES-256-GCM key (required for encrypt/decrypt)
APP_ENV_SWEEP_INTERVAL_MSnumber300000Recovery sweep interval
APP_ENV_STALL_THRESHOLD_MSnumber180000Job-stall cutoff
APP_ENV_JOB_TIMEOUT_MSnumber120000Per-job generate timeout (Promise.race)
APP_ENV_WORKER_IDLE_TIMEOUT_MSnumber-Worker idle timeout
APP_ENV_FORCE_GENERATEbooleanfalseBypass in-flight skip + use latest job (testing)
APP_ENV_ALLOW_CURRENT_PERIODbooleanfalseInclude the current month/quarter in batch expansion
APP_ENV_EXTERNAL_DATA_BASE_URLstring-External data source base URL

2. Feature Flags

FlagDefaultEffect
APP_ENV_FORCE_GENERATEfalseRegenerate even when no PENDING job exists (testing)
APP_ENV_ALLOW_CURRENT_PERIODfalseBatch generation includes the in-progress period

3. Seeded Data

src/migrations/processes/migration-process.ts declares the seedPaths order. alwaysRun: true = idempotent permission seeds; false = one-time reference data (upsert by natural key).

FileSeedsAlways runNotes
ledger-0001-seed-permissionsLedger permission rowsUpsert by code
ledger-0004-seed-role-permissionsRole→permission grants for ledger permissionsMaps ledger permission codes to roles
ledger-0005-seed-ledger-identifiers6 LedgerIdentifier rows (S1a-HKD..S2e-HKD) with i18n name/description-Upsert by identifier
ledger-0006-seed-tax-tiers4 TaxTier rows (TIRE_1..TIRE_4) with revenue bounds-Upsert by code
ledger-0007-seed-ledger-tax-configsLedgerTaxConfig tax approaches per tier (requiredLedgers, metadata.isDefault/isSelectable)-Upsert by (taxTierId, code); skips an approach if its TaxTier is missing (run 0006 first)

4. Configuration Storage

Reference data (form catalogue, tiers, approaches) is seeded into dedicated ledger.* tables, not the generic Configuration table. No encrypted credentials are stored by this service; the only secret is APP_ENV_LEDGER_ENCRYPTION_KEY (env).

ConfigStorageRead by
HKD form catalogueledger.LedgerIdentifierLedgerIdentifierController, generation pipeline
Revenue tiersledger.TaxTierTaxTierController
Tax approaches + required formsledger.LedgerTaxConfigLedgerTaxConfigController
Per-merchant per-year tax onboardingledger.MerchantTaxConfigschema-only (no repository/service wired yet)

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