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_IDnumberSnowflake worker ID (6)
APP_ENV_DB_URLstringPostgreSQL connection
APP_ENV_S3_BUCKETstringledgerTarget S3 bucket
RUN_MODEstringmigrate short-circuits component/service/controller registration

Kafka

NameTypeDefaultRequiredDescription
APP_ENV_KAFKA_BROKERSstringComma-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 / _PASSWORDstringSASL 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 / _DBlocalhost/6379/—/0Single-mode connection
APP_ENV_WEBSOCKET_REDIS_CLUSTER_NODESstringCluster-mode nodes (required if cluster)
APP_ENV_WEBSOCKET_REDIS_IDENTIFIER / _MAX_RETRYledger-ws-redis/5

Service-specific

NameTypeDefaultDescription
APP_ENV_APPLICATION_ROLESstringapi,workerCSV of api/worker; invalid/empty falls back to both
APP_ENV_LEDGER_ENCRYPTION_KEYstringAES-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_MSnumberWorker 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_URLstringExternal 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 runs these in order. alwaysRun: true = idempotent permission seeds; false = one-time.

FileSeedsAlways runNotes
ledger-0001-seed-permissionsLedgerSystemPermissions rowsUpsert by code
ledger-0002-seed-tax-declaration-levelsTaxDeclarationLevelTIRE_1, TIRE_2, TIRE_3Tax bands + filing-schedule rules
ledger-0003-seed-merchant-ledger-configsOne MerchantLedgerConfig per merchant (current year, requiredLedgerTypes=[S1a-HKD], origin: migration)Skips if config exists; skips entirely if TIRE_1 level absent
ledger-0004-seed-role-permissionsRole→permission grants for ledger permissionsMaps LedgerSystemPermissions codes to roles

4. Configuration Storage

Per-merchant runtime config lives in the MerchantLedgerConfig table (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
Required ledger types, filing schedules, tax levelledger.MerchantLedgerConfigMerchantLedgerConfigService, batch validation

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