Skip to main content
Complete reference for all environment variables used by the KaireonAI platform.

1. Quick Reference

validateEnv() (src/lib/env-validation.ts) throws at startup in production if any of DATABASE_URL, NEXTAUTH_SECRET, JWT_SIGNING_SECRET, CONNECTOR_ENCRYPTION_KEY, WEBHOOK_SIGNING_SECRET, or API_KEY_PEPPER is missing, and if CORS_ALLOWED_ORIGINS is empty or *. In development these are warnings, not fatal.

2. Database

DATABASE_URL

PostgreSQL connection string used by Prisma via the @prisma/adapter-pg driver adapter. Notes:
  • In Prisma 7, this value is read from prisma.config.ts, not from the schema.prisma datasource block.
  • For RDS deployments, append ?sslmode=require and optionally &sslrootcert=/app/certs/rds-ca.pem.
  • Use IAM database authentication in production where possible.
  • Connection pooling is handled by the pg adapter; set connection_limit in the connection string if needed.

REDIS_URL

Redis connection string for caching. Optional — when unset the cache is a pass-through no-op and reads fall through to PostgreSQL. Notes:
  • Use rediss:// (double s) for TLS connections to ElastiCache.
  • For ElastiCache cluster mode, use the configuration endpoint.
  • The same Redis is used by the default EVENT_PUBLISHER=redis event bus.

3. Authentication

NEXTAUTH_URL

The canonical URL of the KaireonAI application. Used by NextAuth.js for callback URLs and CSRF protection. Notes:
  • Must match the domain configured in your OAuth provider.
  • Do not include a trailing slash.
  • In development, use http://localhost:3000.

NEXTAUTH_SECRET

Secret used to encrypt NextAuth.js session tokens and CSRF tokens. Notes:
  • Must be identical across all application replicas.
  • Rotate every 180 days. See the security hardening guide for rotation procedures.
  • Store in AWS Secrets Manager, never in source control.

JWT_SIGNING_SECRET

Secret used to sign and verify JWT tokens for API authentication. Notes:
  • Used for service-to-service authentication and API key validation.
  • Must differ from NEXTAUTH_SECRET.
  • Support dual-key validation during rotation: the application accepts tokens signed with either the current or previous key.

4. Security

CONNECTOR_ENCRYPTION_KEY

AES-256 encryption key used to encrypt connector credentials (database passwords, API keys, OAuth tokens) at rest. Notes:
  • Used by the connector registry to encrypt sensitive configuration fields before storing in PostgreSQL.
  • Rotation requires re-encrypting all existing connector credentials. See the security hardening guide.
  • Generate with: openssl rand -hex 32.

WEBHOOK_SIGNING_SECRET

Secret used to sign and verify outbound/inbound webhook payloads (HMAC). Notes:
  • Required in production — validateEnv() throws at startup if unset.
  • Rotation is supported alongside the previous key during a cutover window.

API_KEY_PEPPER

Server-side pepper mixed into API-key hashing so stored key hashes are not reversible even if the database is exposed. Notes:
  • Required in production — validateEnv() throws at startup if unset.
  • Changing it invalidates all existing API-key hashes; rotate deliberately.

CORS_ALLOWED_ORIGINS

Comma-separated allowlist of browser origins permitted to call the API. Notes:
  • In production, validateEnv() throws if this is unset, empty, or * (wildcard origins are rejected as a security risk).
  • The legacy CORS_ORIGIN variable is not read by any code — use CORS_ALLOWED_ORIGINS.

5. Runtime

NODE_ENV

Node.js environment identifier. Controls Next.js build behavior, logging verbosity, and debug features. Notes:
  • Set to production in all deployed environments (staging, production).
  • In development mode, Next.js enables hot module replacement and verbose error pages.
  • In production mode, error details are hidden from responses for security.

LOG_LEVEL

Controls the minimum severity level for application log output. Notes:
  • Use debug or trace only for troubleshooting. These levels generate high log volume.
  • In production, info is recommended. Use warn if log costs are a concern.
  • Log output is structured JSON when NODE_ENV=production.

WORKER_CONCURRENCY

Maximum number of concurrent pipeline tasks a single worker pod processes. Notes:
  • Increase for CPU-heavy transform workloads on larger instances.
  • Each concurrent task consumes approximately 256 MiB of memory. Ensure the pod memory limit accommodates WORKER_CONCURRENCY * 256 MiB plus overhead.
  • Set to 1 for debugging pipeline issues in isolation.

6. Integration Backends

These variables control which backing services KaireonAI uses for event publishing, caching, interaction storage, and search. Each is read once at process startup and selects a process-wide singleton (src/lib/infra/container.ts), so changing one requires a restart. Sensible defaults (pg stores, redis event bus, no-op cache without REDIS_URL) keep a single-node deployment working without extra infrastructure.
Note: These backend selectors are environment-driven. Any in-app settings screens record operator preferences and audit entries — they do not repoint the live adapter. To change the active backend, set the env var (plus the per-backend variables) and restart.

EVENT_PUBLISHER

The event publishing backend for domain events (offer served, decision made, pipeline completed). Related variables by backend:
For AWS MSK with IAM authentication, set EVENT_PUBLISHER=msk and MSK_AUTH_MODE=iam_role (uses the pod’s IRSA role).

Cache backend (REDIS_URL)

The caching backend for decision results, feature vectors, and session data is selected by whether REDIS_URL is set. Notes:
  • Without REDIS_URL, the cache is a pass-through no-op and all reads hit PostgreSQL directly. Suitable for low-traffic deployments.
  • With REDIS_URL, the platform uses Redis (or any Redis-compatible store, e.g., Dragonfly). Recommended for multi-replica deployments or >1000 req/s.
  • Use rediss:// for TLS.

INTERACTION_STORE

The storage backend for customer interaction history used by scoring engines. Related variables by backend:

SEARCH_INDEX

The backend for full-text search across offers, blueprints, and connectors. Related variables by backend:

STORAGE_BACKEND

Blob store for AI-import attachments and related file payloads. Related variables by backend:
Note on Sections 7-10: The default Helm configmap.yaml only passes through OTEL_EXPORTER_OTLP_ENDPOINT plus the CloudWatch log-group and region values. All other variables in sections 7-10 require manual addition to your Helm values override or direct environment variable injection. They are documented here for teams integrating with these services.

7. Observability

OTEL_EXPORTER_OTLP_ENDPOINT

Enables lightweight tracing of the decision pipeline. When set, the platform emits structured trace spans as JSON to stdout (compatible with Winston / log aggregation); when unset, tracing is a no-op with zero overhead. Notes:
  • The platform does not bundle the OpenTelemetry SDK. The value is used only as an on/off switch — spans are written to stdout, not pushed to the endpoint over OTLP.
  • Because there is no OTLP exporter, the standard OTEL tuning variables (OTEL_SERVICE_NAME, OTEL_EXPORTER_OTLP_PROTOCOL, OTEL_TRACES_SAMPLER, OTEL_TRACES_SAMPLER_ARG) are not read by the platform.
  • When set, the decision pipeline emits spans for its stages (qualification, scoring, ranking, delivery, contact policy, budget check).

8. Kafka Integration (Manual Config)

These variables are required only when EVENT_PUBLISHER=kafka.

KAFKA_BROKERS

Comma-separated list of Kafka broker addresses.

KAFKA_SASL_USERNAME / KAFKA_SASL_PASSWORD

SASL/PLAIN credentials for authenticating with the Kafka cluster.

9. AWS Integration (Manual Config)

AWS_REGION

AWS region for SDK calls (DynamoDB, S3, SES, EventBridge, Kinesis).

DYNAMODB_TABLE_NAME

DynamoDB table name for interaction storage when INTERACTION_STORE=dynamodb.

10. Search Integration (Manual Config)

OPENSEARCH_NODE_URL

OpenSearch cluster endpoint when SEARCH_INDEX=opensearch.

OPENSEARCH_INDEX_PREFIX

Prefix for OpenSearch index names.

11. Example .env Files

Development

Production (Minimal — PostgreSQL Only)

Note: This minimal profile runs on PostgreSQL only. Without REDIS_URL the cache is a no-op and the default redis event publisher just logs a non-fatal connect warning (outbox rows still persist) — add REDIS_URL to enable caching and event publishing. Backends are selected by env vars at startup; AWS-backed backends use IAM roles (IRSA) by default on EKS.

Production (Full Infrastructure via Env Vars)

All backends selected explicitly via env vars: