Skip to content

Environment Reference

How environment files work

Each backend package uses dotenv-flow. The NODE_ENV value determines which file is loaded:

FilePurposeGitignored
.env.developmentDev server (bun run server:dev)Typically no
.env.localPersonal overridesYes
.env.testTest suite (bun run test)Usually

To set up a new package, copy from an existing working package and adjust ports / service name / Snowflake ID.

Each package's npm scripts pass the env file explicitly:

json
"server:dev": "NODE_ENV=development bun run start --env-file=.env.development"

Common Variables (All Services)

These are shared across every backend service.

Application

VariableRequiredDescriptionExample
APP_ENV_APPLICATION_NAMEYesService name (used in logging, service discovery)identity
APP_ENV_APPLICATION_CODEYesUnique service codeSVC-00010-IDENTITY
APP_ENV_APPLICATION_ROLESYesService role tagidentity
APP_ENV_APPLICATION_TIMEZONEYesTimezoneAsia/Ho_Chi_Minh
APP_ENV_APPLICATION_SECRETYesShared secret for AES-256-GCM payload encryption (certificate system, credential encryption). Must be identical across all services.
APP_ENV_APPLICATION_DS_MIGRATIONNoMigration datasource namepg_core
APP_ENV_APPLICATION_DS_AUTHORIZENoAuthorization datasource namepg_core

Server

VariableRequiredDescriptionExample
APP_ENV_SERVER_HOSTYesBind hostlocalhost
APP_ENV_SERVER_PORTYesBind port (unique per service)31010
APP_ENV_SERVER_BASE_PATHYesAPI base path/v1/api/identity

Snowflake ID

VariableRequiredDescriptionExample
APP_ENV_SNOWFLAKE_WORKER_IDYesUnique worker ID (0-1023). Must be unique per running instance — collisions cause duplicate IDs.1
APP_ENV_SNOWFLAKE_EPOCH_CHECKPOINTYesEpoch start (ms since Unix epoch)1735689600000

PostgreSQL

VariableRequiredDescriptionExample
APP_ENV_POSTGRES_HOSTYesDatabase hostlocalhost
APP_ENV_POSTGRES_PORTYesDatabase port5432
APP_ENV_POSTGRES_DATABASEYesDatabase namenx_seller
APP_ENV_POSTGRES_USERNAMEYesDB userpostgres
APP_ENV_POSTGRES_PASSWORDYesDB password

Redis (Cache)

VariableRequiredDescriptionExample
APP_ENV_CACHE_REDIS_MODEYessingle or clustercluster
APP_ENV_CACHE_REDIS_IDENTIFIERYesLogical namecache
APP_ENV_CACHE_REDIS_PASSWORDNoRedis password
APP_ENV_CACHE_REDIS_HOSTSingle modeRedis hostlocalhost
APP_ENV_CACHE_REDIS_PORTSingle modeRedis port6379
APP_ENV_CACHE_REDIS_CLUSTER_NODESCluster modeComma-separated host:portnode1:6379,node2:6380

Redis (BullMQ / Queues)

VariableRequiredDescriptionExample
APP_ENV_BULLMQ_REDIS_HOSTIf using queuesRedis host for BullMQlocalhost
APP_ENV_BULLMQ_REDIS_PORTIf using queuesRedis port6379
APP_ENV_BULLMQ_REDIS_PASSWORDNoRedis password

External Services

VariableRequiredDescriptionExample
APP_ENV_IDENTITY_SERVICE_BASE_URLYes (all verifiers)Identity service URL for JWKShttp://localhost:31010/v1/api/identity
APP_ENV_JWKS_REST_PATHNoJWKS endpoint path/jw-certs (default)
APP_ENV_BASIC_AUTH_USERNAMENoHTTP Basic auth usersuperadmin
APP_ENV_BASIC_AUTH_PASSWORDNoHTTP Basic auth password

Logging

VariableRequiredDescriptionExample
APP_ENV_LOGGER_FOLDER_PATHNoLog file output directory./app_data/logs
APP_ENV_PARSE_RESULT_FOLDER_PATHNoParse result output./app_data/parse_result

Misc

VariableDescriptionExample
DEBUGEnable debug outputtrue
NODE_ENVRuntime environmentdevelopment
RUN_MODEstartup or migratestartup
TZSystem timezoneAsia/Ho_Chi_Minh

Identity Service Only (JWKS Issuer)

These variables are only needed by @nx/identity — the JWKS issuer.

VariableRequiredDescriptionExample
APP_ENV_JWT_EXPIRES_INYesJWT lifetime in seconds86400 (1 day)
APP_ENV_JWKS_ALGORITHMYesSigning algorithmES256
APP_ENV_JWKS_PRIVATE_KEYYesECDSA private key (PEM, PKCS#8 format)-----BEGIN PRIVATE KEY-----\n...\n-----END PRIVATE KEY-----
APP_ENV_JWKS_PUBLIC_KEYYesECDSA public key (PEM)-----BEGIN PUBLIC KEY-----\n...\n-----END PUBLIC KEY-----

PKCS#8 required

The private key must use PKCS#8 format (-----BEGIN PRIVATE KEY-----), not SEC1 (-----BEGIN EC PRIVATE KEY-----). Generate with:

bash
openssl genpkey -algorithm EC -pkeyopt ec_paramgen_curve:P-256 \
  | tee private.pem | openssl pkey -pubout > public.pem

Licensing Service

VariableRequiredDescriptionDefault
APP_ENV_LICENSING_ED25519_PRIVATE_KEYNo*Ed25519 PEM private key for certificate signing
APP_ENV_LICENSING_ED25519_PUBLIC_KEYNo*Ed25519 PEM public key for verification
APP_ENV_LICENSING_CERT_TTL_SECONDSNoCertificate TTL (written to Redis + payload)86400

* If missing, publishCertificate() silently skips — licenses are issued but without certificates.

Signal Service (WebSocket)

VariableRequiredDescriptionExample
APP_ENV_WEBSOCKET_REDIS_MODEYessingle or clustersingle
APP_ENV_WEBSOCKET_REDIS_HOSTSingle modeWebSocket Redis hostlocalhost
APP_ENV_WEBSOCKET_REDIS_PORTSingle modeWebSocket Redis port6379
APP_ENV_WEBSOCKET_ECDH_INFOYesHKDF info string for E2E encryption

Asset Service (S3 / MinIO)

VariableRequiredDescriptionExample
APP_ENV_MINIO_HOSTYesS3-compatible storage hostlocalhost
APP_ENV_MINIO_API_PORTYesS3 API port9000
APP_ENV_MINIO_ACCESS_KEYYesS3 access key
APP_ENV_MINIO_SECRET_KEYYesS3 secret key

Search Service (Typesense)

VariableRequiredDescriptionExample
APP_ENV_TYPESENSE_API_KEYYesTypesense API key
APP_ENV_TYPESENSE_NODESYesNode list (protocol:host:port)http:localhost:8108

Commerce / Cross-Service URLs

VariablePurposeExample
APP_ENV_COMMERCE_SERVICE_BASE_URLCommerce API base for cross-service callshttp://localhost:31020/v1/api/commerce

Payment Service

VariableDescription
APP_ENV_MQ_PAY_MODEDeployment mode: full (default), api (REST only), worker (BullMQ only)

Service Registry Quick Reference

ServiceAPPLICATION_NAMEAPPLICATION_CODESERVER_PORTSNOWFLAKE_WORKER_IDSERVER_BASE_PATH
identityidentitySVC-00010-IDENTITY310101/v1/api/identity
commercecommerceSVC-00020-COMMERCE310202/v1/api/commerce
salesaleSVC-00030-SALE310303/v1/api/sale
financefinanceSVC-00040-FINANCE310404/v1/api/finance
inventoryinventorySVC-00050-INVENTORY310505/v1/api/inventory
ledgerledgerSVC-00060-LEDGER310606/v1/api/ledger
pricingpricingSVC-00070-PRICING310707/v1/api/pricing
paymentpaymentSVC-00080-PAYMENT310808/v1/api/payment
signalsignalSVC-00090-SIGNAL310909/v1/api/signal
outreachoutreachSVC-00110-OUTREACH3111010/v1/api/outreach
licensinglicensingSVC-00140-LICENSING3112011/v1/api/licensing
taxationtaxationSVC-00130-TAXATION3113013/v1/api/taxation
PageDescription
Getting StartedSetup walkthrough
Build SystemMake targets
IGNIS PatternsFramework configuration patterns
Licensing — CertificatesHow APP_ENV_APPLICATION_SECRET is used for certificate encryption

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