Environment Variables
Overview
Environment configuration is managed through dotenv files under modules/dotenv/:
modules/dotenv/
├── app.env # Global app config (APP_NAME, LOG_LEVEL, etc.)
├── dev/ # Dev environment values (git-ignored, copied from example/)
│ ├── auth0.env
│ ├── redis.env
│ ├── ai.env
│ ├── postgres-core.env
│ ├── postgres-ai.env
│ ├── minio.env
│ ├── neo4j.env
│ ├── geoip.env # optional — omit to run without session geolocation
│ ├── environment.env
│ ├── dashboards.env # optional — weather / RSS / market widgets
│ └── billing.env # optional — platform allowances, plan prices
├── example/ # Templates (committed, no secrets)
│ ├── auth0.env.example
│ ├── redis.env.example
│ ├── ai.env.example
│ ├── postgres-core.env.example
│ ├── postgres-auth.env.example
│ ├── postgres-ai.env.example
│ ├── minio.env.example
│ ├── neo4j.env.example
│ ├── geoip.env.example
│ ├── dashboards.env.example
│ └── billing.env.example
└── prod/ # Production overrides (git-ignored, written by
# the deploy script from SSM)
There is also a flat modules/.env (template: modules/.env.example). Compose auto-loads it and uses it for ${...} interpolation inside the compose files — a different mechanism from the per-group env_file entries above. A variable needed for ${...} (MINIO_ROOT_USER, REDIS_PASSWORD, INTERNAL_JWT_SECRET, GRAFANA_ADMIN_PASSWORD) must be in that file; putting it only in dotenv/dev/<group>.env will not work, because env_file values go to the container and are never visible to compose itself.
Each service in docker-compose.yml declares which env files it loads via env_file. Variables from later files override earlier ones.
Global (dotenv/app.env)
| Variable | Description | Default |
|---|---|---|
APP_VERSION | Application version | 0.0.0 |
LOG_LEVEL | Verbosity of svc-ai's and svc-core's own loggers (all under app). Libraries log WARNING and above whatever this says, and no line carries what a person wrote (docs/system/monitoring/logging.md). Unset or not a level's name: INFO. INFO is the sensible value for a deployed host | DEBUG (dev app.env) |
FORCE_COLOR | Force coloured log output | 1 |
svc-auth
Sources: dotenv/app.env, dotenv/dev/environment.env, dotenv/dev/auth0.env, dotenv/dev/redis.env
| Variable | Description | Required |
|---|---|---|
AUTH0_CLIENT_ID | Auth0 application client ID | ✓ |
AUTH0_CLIENT_SECRET | Auth0 application client secret | ✓ |
AUTH0_AUDIENCE | Auth0 API audience (e.g. https://api.your-domain) | ✓ |
AUTH_CALLBACK_URL | Full callback URL (http://auth.dev.datachainr.com:8000/callback). No AUTH0_ prefix — AUTH0_CALLBACK_URL is read by nothing | ✓ |
REDIS_URL | Redis connection URL | redis://redis:6379 |
REDIS_PASSWORD | Redis password | ✓ |
SESSION_SECRET | Secret for signing session cookies | ✓ |
SESSION_COOKIE_NAME | Cookie name | sid |
SESSION_MAX_AGE | Session TTL in seconds | 900 |
TOKEN_REFRESH_THRESHOLD | Seconds before expiry to refresh tokens | 300 |
ENVIRONMENT | development / production | development |
FRONTEND_URL | Post-login redirect URL | required |
COOKIE_SECURE | Set Secure flag on cookie | false |
COOKIE_SAMESITE | Cookie SameSite policy | lax |
COOKIE_DOMAIN | Cookie domain scope | .dev.datachainr.com |
GEOIP_DB_PATH | Path to a GeoLite2-City.mmdb for offline session-IP geolocation | unset (geo omitted) |
GEOIP_DB_PATH is set directly in docker-compose.yml (not a dotenv value) — it's a fixed in-container path (/data/GeoLite2-City.mmdb) that the geoipupdate sidecar populates via a shared volume. See GeoIP below.
svc-bff
Sources: dotenv/app.env, dotenv/dev/environment.env, dotenv/dev/redis.env
| Variable | Description | Required |
|---|---|---|
REDIS_PASSWORD | Redis password | ✓ |
SESSION_COOKIE_NAME | Cookie name (must match svc-auth) | sid |
SESSION_SECRET | Cookie signing secret (must match svc-auth) | ✓ |
BACKEND_API_URL | svc-core base URL | http://svc-core:8080 |
ENVIRONMENT | development / staging / production | development |
INTERNAL_JWT_SECRET | Shared secret for minting internal service tokens (required in prod) | — |
svc-core
Sources: dotenv/app.env, dotenv/dev/environment.env, dotenv/dev/postgres-core.env, dotenv/dev/minio.env, dotenv/dev/ai.env, dotenv/dev/neo4j.env, and the optional dotenv/dev/dashboards.env and dotenv/dev/billing.env (Dashboards, Billing)
| Variable | Description | Required |
|---|---|---|
POSTGRES_DB | Database name | ✓ |
POSTGRES_USER | Database user | ✓ |
POSTGRES_PASSWORD | Database password | ✓ |
MINIO_ENDPOINT | MinIO address | minio:9000 |
MINIO_ROOT_USER | MinIO access key | ✓ |
MINIO_ROOT_PASSWORD | MinIO secret key | ✓ |
QDRANT_URL | Qdrant address | http://qdrant:6333 |
DOCLING_URL | Docling address | http://docling:5001 |
NEO4J_URI | Neo4j Bolt URI | bolt://neo4j:7687 |
NEO4J_AUTH | user/password as one value; the user and password are split out of it in code, so NEO4J_USERNAME / NEO4J_PASSWORD are not env vars | neo4j/chainr_dev |
APP_ENV | local / dev / staging / prod | local |
DEBUG | Enable debug output | false |
INTERNAL_JWT_SECRET | Verifies inbound svc-bff tokens & mints svc-ai tokens (required outside dev) | — |
SCHEDULER_ENABLED | Run background jobs in this replica's process. One replica is elected leader by a Postgres advisory lock, so enabling it everywhere is correct — losing the election costs nothing. Set false to fall back entirely to refresh-on-view and purge-on-read | true |
SCHEDULER_TICK_SECONDS | How often the loop wakes. Bounds every job's resolution: a job asking for a finer interval than this gets this one, and GET /monitoring/scheduler reports both | 60 |
BACKGROUND_EVENT_RETENTION_DAYS | Days a background_events row (a tile refreshed, a site re-crawled) is kept before the hourly background_retention job deletes it; also applied when the feed is read. 0 keeps them forever | 30 |
BUILT_IN_NEWS_ENABLED | Provision the built-in News repository and crawl its feeds (hourly, only while an agent has it granted). false provisions and crawls nothing, so the platform makes no outbound fetch no user asked for; rows already provisioned stay, uncrawled. See docs/guides/news.md | true |
BUILT_IN_WEB_KNOWLEDGE_ENABLED | Provision every other built-in repository read from a publisher's website, and crawl it (only while an agent has it granted). false provisions and crawls none of them, as for News. Knowledge CHAIN-R writes itself fetches nothing and is always provided. See docs/guides/knowledge.md#built-in-knowledge | true |
DEPLOY_ID | Which deploy this is. Set from IMAGE_TAG by docker-compose.ecr.yml; empty locally. The platform benchmark runs only where it is set, and runs CHAINR Bot again whenever it changes. See docs/guides/evaluation.md#the-platform-benchmark | (empty) |
PLATFORM_BENCHMARK_ENABLED | Run the platform benchmark (CHAINR Bot and each maker's strongest model on every gold dataset) after each deploy. false starts no run; results already recorded stay | true |
PLATFORM_BENCHMARK_BUDGET_USD | Measured spend, in USD, allowed per calendar month (UTC), reset on the 1st. A target's round starts only when what it cost last time fits what is left; nothing starts once it is spent (the run in progress finishes). What waits runs in next month's round | 50 |
PLATFORM_BENCHMARK_MODEL_REFRESH_DAYS | Days after which a built-in model's benchmark result is measured again, though its dataset and judge are unchanged: a provider can change what an unversioned model name answers with. A pinned version (a dated snapshot such as claude-haiku-4-5-20251001, or a versioned Bedrock id: svc-ai's version_pinned) is never re-run for age. 0 never refreshes | 30 |
PLATFORM_BENCHMARK_JUDGE | The judges for benchmark runs, first choice first, as comma-separated provider/model: the first the catalogue has available grades (on Bedrock without Anthropic access, the second). Not the deployment's default model, which is the one CHAINR Bot answers with: the bot would grade itself. Empty, or none available, falls back to the default model with a warning. Changing the judge in use re-runs every model baseline, because a score under one judge is not comparable with one under another | see app/common/settings.py |
NATIVE_STRUCTURED_SIBLING | true names a native sibling for a turn whose model cannot decode a reply to a schema (Claude 5.x on Bedrock): the same maker's model, in the same region, that can, makes the turn's structured system steps (triage, planning, retrieval's judging, the quality check, memory extraction). Chosen per turn under the workspace's rules (app/services/native_sibling.py), checked again by svc-ai. Off: the only such sibling in the EU is Claude Haiku 4.5, about ten times Haiku 5.5's price per token, whose Bedrock end of life may now come at any time. Changing it re-runs CHAINR Bot's benchmark. See docs/guides/agent-graph.md#a-native-sibling-20-october-2026-off | false |
ECONOMICS_EXPORT_DIR | Where the hourly economics_export job writes each finished day's spend and what it bought, for the host to ship to S3 and CloudWatch (infra/aws/economics). Empty: the job does nothing. The prod compose overlay sets /run/economics | — |
ECONOMICS_EXPORT_LOOKBACK_DAYS | How many days back the job still writes a missing day, and how long a written day is kept on the host before it is deleted | 30 |
svc-ai
Sources: dotenv/app.env, dotenv/dev/environment.env, dotenv/dev/ai.env, dotenv/dev/postgres-ai.env, dotenv/dev/neo4j.env
| Variable | Description | Required |
|---|---|---|
ANTHROPIC_API_KEY | Anthropic API key | — (at least one LLM key needed) |
EMBEDDING_RPM_QUOTA | The account's on-demand requests-per-minute quota for Titan Text Embeddings V2 in this region (Service Quotas; 6,000 in London). svc-ai paces Titan requests evenly at 80% of it; 0 turns pacing off. The embedding model itself follows INFERENCE_BACKEND | 6000 |
EMBEDDING_CONCURRENCY | Titan requests in flight at once: enough threads to reach that pace (Titan takes one text per request) | 8 |
MINIO_ACCESS_KEY | MinIO access key — same value as MINIO_ROOT_USER | ✓ |
MINIO_SECRET_KEY | MinIO secret key — same value as MINIO_ROOT_PASSWORD | ✓ |
POSTGRES_HOST | Postgres host | modules-postgres-ai-1 |
POSTGRES_DB | Database name | ✓ |
POSTGRES_USER | Database user | ✓ |
POSTGRES_PASSWORD | Database password | ✓ |
QDRANT_URL | Qdrant address | http://qdrant:6333 |
MINIO_ENDPOINT | MinIO address | minio:9000 |
DOCLING_URL | Docling address | http://docling:5001 |
NEO4J_URI | Neo4j Bolt URI | bolt://neo4j:7687 |
NEO4J_AUTH | user/password as one value (see svc-core above) | neo4j/chainr_dev |
INFERENCE_BACKEND | How models are reached: direct (the vendors' APIs and keys) or bedrock (Amazon Bedrock, with the catalogue's UK/EU/global routes; inference_routes). The catalogue is the same either way; prices, regions, availability and the default model follow the backend. Part of /health's fingerprint | direct |
BEDROCK_REGION | The AWS region Bedrock is called in. Credentials come from botocore's default chain (on a deployed host, short-lived role credentials), never from a key here | eu-west-2 |
BEDROCK_MODEL_ACCESS | Whose models this AWS account may use on Bedrock: all, or makers comma-separated, as each model id names them: amazon (Nova and Titan), anthropic, deepseek, google, mistral, moonshotai, nvidia, openai, qwen. AWS grants model access per account; a vendor left out has its routes marked unavailable (hidden from pickers, skipped by the benchmark) and refused with a reason, and the default model moves to the Bedrock fallback (is_fallback_default_on_bedrock) | all |
AWS_CONFIG_FILE | Set by docker-compose.prod.yml to /run/aws/config: a credential_process reading the session the host's timer writes for chainr-dev-bedrock-invoke (infra/aws/bedrock) | unset (local) |
AWS_EC2_METADATA_DISABLED | Set to true by docker-compose.prod.yml: botocore never asks the metadata service for the instance role, which is out of reach anyway (hop limit 1) | unset (local) |
LLM_DAILY_CEILING_USD | The deployment's daily (UTC) model-spend ceiling in USD; no model call starts once it is reached (spend_guard). Unset is the default, never unlimited; off lifts it | 15 |
LLM_MONTHLY_CEILING_USD | The same for the calendar month | 150 |
TRIAGE_MODEL | provider/model that triages every agent run, for agents on the same provider only (triage reads the whole request). Empty: the agent's own model. Part of /health's fingerprint, so changing it re-runs CHAINR Bot's benchmark | — (off) |
STRICT_BUILTIN_TOOLS | true binds every tool whose schema the platform wrote with toolSpec.strict on a Bedrock route whose strict_tools flag is set (app/tools/wire.py): gpt-oss-120b and Qwen3 235B, which app.diagnostics.structured_probe measured on 20 October 2026. false binds every tool as it is. Part of /health's fingerprint | true |
ENVIRONMENT | development / production | development |
INTERNAL_JWT_SECRET | Verifies internal tokens from svc-core; if unset, auth is skipped (required outside dev) | — |
Redis (dotenv/dev/redis.env)
| Variable | Description |
|---|---|
REDIS_PASSWORD | Redis auth password |
SESSION_SECRET | Cookie signing secret (shared by svc-auth and svc-bff) |
SESSION_MAX_AGE | Session TTL in seconds |
SESSION_COOKIE_NAME | Cookie name |
MinIO (dotenv/dev/minio.env)
Loaded by svc-core and svc-ai (the clients). The MinIO server container reads MINIO_ROOT_USER / MINIO_ROOT_PASSWORD through ${...} instead, so those must also be in the flat modules/.env. svc-ai reaches MinIO under MINIO_ACCESS_KEY / MINIO_SECRET_KEY (in ai.env) — set all four to the same pair of values.
| Variable | Description |
|---|---|
MINIO_ROOT_PASSWORD | MinIO root/admin password |
MINIO_BUCKET_KNOWLEDGE | Bucket knowledge-base documents are stored in |
Neo4j (dotenv/dev/neo4j.env)
| Variable | Description |
|---|
GeoIP (dotenv/dev/geoip.env)
Optional. Consumed by the geoipupdate sidecar in docker-compose.yml, which downloads MaxMind's GeoLite2-City database into a shared geoip_data volume that svc-auth mounts read-only at GEOIP_DB_PATH. svc-auth itself never talks to MaxMind — only this sidecar does, periodically. Left unconfigured, the sidecar exits immediately and svc-auth just omits session location data.
| Variable | Description |
|---|---|
GEOIPUPDATE_LICENSE_KEY | MaxMind license key |
Dashboards (dotenv/dev/dashboards.env)
Optional, svc-core only. Feed widgets reach the internet on the dedicated feed-egress-network. Weather and RSS need no configuration; the market widget renders a setup prompt until a vendor key is set.
| Variable | Description | Default |
|---|---|---|
MARKET_DATA_API_KEY | Vendor API key. none / disabled / off leaves market widgets deliberately disabled | unset |
FEED_ALLOWED_DOMAINS | Comma-separated publishers the RSS widget may fetch (subdomains included); * or empty allows any public host | * |
FEED_ALLOWED_DOMAINS narrows which publishers are reachable. It never relaxes the SSRF guard, which always refuses private, loopback, link-local and reserved addresses regardless of this setting.
Billing (dotenv/dev/billing.env)
Optional, svc-core only: what CHAIN-R allows and charges each workspace, in US dollars a calendar month (UTC). Not the AWS bill (infra/aws/billing). Commercial terms, so each is off until an amount is chosen: empty, off or none means none. Template: dotenv/example/billing.env.example. Deployed, they are the SSM group billing/ (dotenv/prod/billing.env), seeded off by tools/seed-ssm-params.sh; tools/test_billing_settings.py holds every key to a field of svc-core's settings. See docs/guides/cost-monitoring.md#platform-allowances and docs/guides/cost-monitoring.md#plan-prices.
| Variable | Description | Default |
|---|---|---|
PLATFORM_ALLOWANCE_ORGANISATION_USD | The same for each organisation, with every project in it counted against one allowance | (empty) |
PLAN_PERSONAL_FEE_USD | What each Personal workspace pays CHAIN-R a calendar month (US dollars): the platform fee of its plan. With the two below, its statements show the charges and the economics export the revenue. All three empty, off or none: no plan. See docs/guides/cost-monitoring.md#plan-prices | (empty) |
PLAN_PERSONAL_USAGE_MARKUP_PERCENT | Its markup on model usage past what the fee includes, as a percentage of the usage's measured cost | (empty) |
PLAN_PERSONAL_INCLUDED_USAGE_USD | Model usage the fee includes a month, charged nothing | (empty) |
PLAN_ORGANISATION_FEE_USD | The platform fee of each organisation's plan, its projects counted with it | (empty) |
PLAN_ORGANISATION_USAGE_MARKUP_PERCENT | The organisation plan's markup on usage past what its fee includes | (empty) |
PLAN_ORGANISATION_INCLUDED_USAGE_USD | Model usage the organisation plan's fee includes a month | (empty) |
Flat compose env (modules/.env)
Used for ${...} interpolation inside the compose files, not passed via env_file. Template: modules/.env.example.
| Variable | Description | Default |
|---|---|---|
MINIO_ROOT_PASSWORD | Passed to the MinIO server container | — |
REDIS_PASSWORD | Passed to the redis container as --requirepass | — |
INTERNAL_JWT_SECRET | Shared internal-token secret; the dev override supplies a default | — |
GRAFANA_ADMIN_PASSWORD | Grafana admin password | admin |
Optional credentials and the "off" sentinel
Several credentials are optional — the feature degrades rather than failing when they are unset. Locally you can simply leave them empty, but deployed environments cannot: SSM Parameter Store rejects an empty value, and deploy-on-host.sh refuses any parameter still set to CHANGE_ME. An optional key therefore has to be seeded with a real value that reads as "off", and tools/seed-ssm-params.sh defaults these to none.
| Variable | none means |
|---|---|
MARKET_DATA_API_KEY | dashboard market widgets render a setup prompt |
GEOIPUPDATE_ACCOUNT_ID | the sidecar runs once, fails, and stops; svc-auth omits geo |
GEOIPUPDATE_LICENSE_KEY | as above |
none, disabled, off, unset and change_me are all normalised to "unset" in svc-ai (app/common/settings.py) and svc-core (app/services/dashboards/market.py). This matters because both do if not key — an unnormalised placeholder is truthy and would be used as a real credential. The geoipupdate sidecar is a third-party image and does not implement the convention; the result is one failed run rather than a clean skip, which is observably the same for svc-auth.
Secret Management
Never commit dev credentials.
dotenv/dev/anddotenv/prod/are git-ignored.Generate secure secrets with
make generate-secrets.In production, inject secrets via your secrets manager (e.g. AWS Secrets Manager, Vault) rather than committing files.
SESSION_SECRETandREDIS_PASSWORDmust be identical in both svc-auth and svc-bff.INTERNAL_JWT_SECRETmust be identical across svc-bff, svc-core, and svc-ai. It is required in staging/production (those services refuse to start without it). In local dev,docker-compose.override.ymlsupplies a non-production default andmake fullstackpasses a generated value.