Environment Variables Reference
This document lists all environment variables required by each app and package in the ERP-Unlocked monorepo.
๐ Apps
Section titled โ๐ Appsโ๐ฅ๏ธ Webapp (apps/webapp)
Section titled โ๐ฅ๏ธ Webapp (apps/webapp)โRequired Environment Variables:
# Authentication (Clerk)PUBLIC_CLERK_PUBLISHABLE_KEY=pk_...CLERK_SECRET_KEY=sk_...
# DatabaseDATABASE_URL=postgresql://...
# EncryptionENCRYPTION_KEY=your-encryption-key
# RedisREDIS_URL=redis://...
# App ConfigurationAPP_ENV=development|staging|productionDEBUG_LOGGING=true|false
# Stripe Configuration (Usage-Based Billing)STRIPE_SECRET_KEY=sk_...STRIPE_PUBLISHABLE_KEY=pk_...STRIPE_WEBHOOK_SECRET=whsec_...STRIPE_API_VERSION=2026-02-25.clover# Base subscription price ID ($500/month)STRIPE_BASE_PRICE_ID=price_...# Metered usage price ID (per line item charges)STRIPE_USAGE_PRICE_ID=price_...
# Feature Flags (Flagsmith)FLAGSMITH_ENVIRONMENT_KEY=ser...FLAGSMITH_API_URL=https://flagsmith.yourdomain.com/api/v1
# R2 Storage (Cloudflare)PUBLIC_R2_ACCOUNT_ID=your-account-idPUBLIC_R2_BUCKET_NAME=your-bucket-nameR2_ENDPOINT_URL=https://<account-id>.r2.cloudflarestorage.comR2_ACCESS_KEY_ID=your-access-key-idR2_SECRET_ACCESS_KEY=your-secret-access-keyR2_BUCKET_NAME=your-bucket-name
# Email (Resend)RESEND_API_KEY=re_...
# Inbound email (shared with the Cloudflare email worker and the Temporal pull path).# Verifies X-Inbound-Email-Signature on /api/webhook/inbound-email, /api/alias/lookup,# /api/email/triage and external attachment uploads to POST /api/pdf-documents.# Unset, those routes return 503 and email ingestion stops.INBOUND_EMAIL_SECRET=your-shared-hmac-secret
# GitHub IntegrationGITHUB_TOKEN=ghp_...GITHUB_REPO_OWNER=your-orgGITHUB_REPO_NAME=ordermatic
# Dagster / TemporalDAGSTER_URL=http://localhost:3000DAGSTER_GRAPHQL_URL=https://your-dagster-graphql-endpoint/graphqlDAGSTER_GRAPHQL_TOKEN=your_dagster_graphql_tokenTEMPORAL_ADDRESS=localhost:7233TEMPORAL_NAMESPACE=default
# Operational alerting (Better Stack incidents; routing lives in Better Stack)BETTERSTACK_API_TOKEN=your_betterstack_api_tokenOptional Environment Variables:
# Database Pool ConfigurationDB_POOL_MAX=10DB_POOL_IDLE_TIMEOUT=30000DB_CONNECTION_TIMEOUT=10000๐ก๏ธ Internal Admin Portal (apps/internal)
Section titled โ๐ก๏ธ Internal Admin Portal (apps/internal)โRequired Environment Variables (/runtime/internal):
# Authentication (Clerk)PUBLIC_CLERK_PUBLISHABLE_KEY=pk_...CLERK_SECRET_KEY=sk_...
# Database & RedisDATABASE_URL=postgresql://...REDIS_URL=redis://...
# Temporal / DagsterTEMPORAL_ADDRESS=localhost:7233TEMPORAL_NAMESPACE=defaultDAGSTER_URL=http://localhost:3000โ๏ธ Python Temporal Worker (apps/temporal-worker)
Section titled โโ๏ธ Python Temporal Worker (apps/temporal-worker)โRequired Environment Variables (/runtime/temporal-worker):
# Temporal ServerTEMPORAL_ADDRESS=localhost:7233TEMPORAL_NAMESPACE=defaultTEMPORAL_TASK_QUEUE=pdf-extraction-queue
# Database & RedisDATABASE_URL=postgresql://...REDIS_URL=redis://...
# Cloudflare R2 StorageR2_ENDPOINT_URL=https://<account-id>.r2.cloudflarestorage.comR2_ACCESS_KEY_ID=your-access-key-idR2_SECRET_ACCESS_KEY=your-secret-access-keyR2_BUCKET_NAME=your-bucket-name
# AI / OCR ServicesGEMINI_API_KEY=your-gemini-keyGOOGLE_CLOUD_PROJECT=ordermatic-prodLANGFUSE_PUBLIC_KEY=pk-lf-...LANGFUSE_SECRET_KEY=sk-lf-...
# Feature Flags & CredentialsFLAGSMITH_ENVIRONMENT_KEY=ser...FLAGSMITH_API_URL=https://flagsmith.ordermatic.co/api/v1ENCRYPTION_KEY=your-encryption-key
# Search (Typesense)TYPESENSE_HOST=localhostTYPESENSE_PORT=8108TYPESENSE_API_KEY=your-typesense-keyโก TypeScript Temporal Worker (apps/ts-temporal-worker)
Section titled โโก TypeScript Temporal Worker (apps/ts-temporal-worker)โRequired Environment Variables (/runtime/ts-temporal-worker):
# Temporal ServerTEMPORAL_ADDRESS=localhost:7233TEMPORAL_NAMESPACE=default
# Database & RedisDATABASE_URL=postgresql://...REDIS_URL=redis://...
# ERP Credentials & Feature FlagsENCRYPTION_KEY=your-encryption-keyFLAGSMITH_ENVIRONMENT_KEY=ser...FLAGSMITH_API_URL=https://flagsmith.ordermatic.co/api/v1๐ Dagster Data Pipeline (apps/dagster)
Section titled โ๐ Dagster Data Pipeline (apps/dagster)โRequired Environment Variables (/runtime/dagster):
# Database & EncryptionDATABASE_URL=postgresql://...ENCRYPTION_KEY=your-encryption-key
# Iceberg / Cloudflare R2 WarehouseR2_ENDPOINT_URL=https://<account-id>.r2.cloudflarestorage.comR2_ACCESS_KEY_ID=your-access-key-idR2_SECRET_ACCESS_KEY=your-secret-access-keyR2_BUCKET_NAME=your-bucket-name
# DLT RuntimeRUNTIME__REQUEST_TIMEOUT=120
# Feature Flags & SearchFLAGSMITH_ENVIRONMENT_KEY=ser...FLAGSMITH_API_URL=https://flagsmith.ordermatic.co/api/v1TYPESENSE_HOST=localhostTYPESENSE_PORT=8108TYPESENSE_API_KEY=your-typesense-key๐ฆ Packages
Section titled โ๐ฆ Packagesโ๐๏ธ Database (packages/db)
Section titled โ๐๏ธ Database (packages/db)โRequired Environment Variables:
# Database ConnectionDATABASE_URL=postgresql://...Optional Environment Variables:
# Database Pool ConfigurationDB_POOL_MAX=10DB_POOL_IDLE_TIMEOUT=30000DB_CONNECTION_TIMEOUT=10000
# EnvironmentNODE_ENV=development|production๐ PDF Shared (packages/pdf-shared)
Section titled โ๐ PDF Shared (packages/pdf-shared)โRequired Environment Variables:
# RedisREDIS_URL=redis://...
# DatabaseDATABASE_URL=postgresql://...
# R2 StorageR2_ENDPOINT_URL=https://...R2_ACCESS_KEY_ID=your-access-keyR2_SECRET_ACCESS_KEY=your-secret-keyR2_BUCKET_NAME=your-bucket-name
# Gemini AIGEMINI_API_KEY=your-gemini-key
# LoggingLOG_LEVEL=INFO|DEBUG|WARNING|ERROROptional Environment Variables:
# PDF ProcessingMAX_PARALLEL_CHUNKS=2
# CORSCORS_ORIGINS=*|comma-separated-origins๐ ๏ธ Utils (packages/utils)
Section titled โ๐ ๏ธ Utils (packages/utils)โNo environment variables required.
๐จ UI (packages/ui)
Section titled โ๐จ UI (packages/ui)โNo environment variables required.
๐ง CI/CD Environment Variables
Section titled โ๐ง CI/CD Environment VariablesโGitHub Secrets & Infisical CI Paths
Section titled โGitHub Secrets & Infisical CI PathsโGitHub Actions stores only 3 bootstrap secrets (INFISICAL_UNIVERSAL_AUTH_CLIENT_ID, INFISICAL_UNIVERSAL_AUTH_CLIENT_SECRET, INFISICAL_PROJECT_ID) plus the ordermatic-release-bot GitHub App credentials (RELEASE_APP_ID, RELEASE_APP_PRIVATE_KEY). All other CI secrets are fetched dynamically from Infisical under /ci/* paths (infrastructure/infisical/secrets-map.json).
See Infisical CI Secrets for the full /ci/* path-to-workflow mapping:
# 3 Bootstrap GitHub Repository Secrets:INFISICAL_UNIVERSAL_AUTH_CLIENT_ID=...INFISICAL_UNIVERSAL_AUTH_CLIENT_SECRET=...INFISICAL_PROJECT_ID=...
# Fetched from Infisical /ci/* paths at workflow runtime:# /ci/shared -> TURBO_TOKEN# /ci/cloudflare -> CLOUDFLARE_API_TOKEN, CLOUDFLARE_ACCOUNT_ID, CLOUDFLARE_PAGES_API_TOKEN# /ci/gcp -> GCP_SA_KEY# /ci/clerk -> PUBLIC_CLERK_PUBLISHABLE_KEY, CLERK_SECRET_KEY# /ci/posthog -> PUBLIC_POSTHOG_KEY, PUBLIC_POSTHOG_HOST# /ci/eval -> EVAL_SERVICE_TOKEN, LANGFUSE_PUBLIC_KEY, LANGFUSE_SECRET_KEY, R2_*# /ci/flagsmith -> FLAGSMITH_API_URL, FLAGSMITH_ADMIN_EMAIL, FLAGSMITH_ADMIN_PASSWORD, FLAGSMITH_ENVIRONMENT_KEY# /ci/e2e -> STAGING_TEST_EMAIL, STAGING_TEST_PASSWORD, E2E_FLAG_OVERRIDE_SECRET# /ci/database -> DATABASE_URL# /ci/integrations -> LINEAR_API_KEY, GEMINI_API_KEY, STAGING_WEBAPP_URL๐ Deployment Environment Variables
Section titled โ๐ Deployment Environment VariablesโCloudflare Pages (Docs Site)
Section titled โCloudflare Pages (Docs Site)โProduction:
PUBLIC_WEBAPP_URL=https://app.ordermatic.coStaging:
PUBLIC_WEBAPP_URL=https://staging.ordermatic.co๐ Environment Setup Checklist
Section titled โ๐ Environment Setup ChecklistโDevelopment Setup
Section titled โDevelopment Setupโ- Copy
.env.exampleto.env(andapps/webapp/.env.exampletoapps/webapp/.env) - Set up PostgreSQL database
- Set up Redis instance
- Configure R2 storage credentials (
R2_ACCESS_KEY_ID,R2_SECRET_ACCESS_KEY,R2_ENDPOINT_URL,R2_BUCKET_NAME) - Get Gemini API key
- Set up Clerk authentication
- Configure Dagster and Temporal (
TEMPORAL_ADDRESS)
Production Setup
Section titled โProduction Setupโ- Set all required environment variables in Infisical (
/runtime/*) for the target environment (infrastructure/infisical/secrets-map.json) - Configure the 3
INFISICAL_*bootstrap secrets in GitHub Secrets (Infisical CI Secrets) - Set up Cloudflare Pages environment variables
- Verify all webhook URLs are correct
- Test database connections
- Verify Redis connectivity
- Test R2 storage access
Staging Setup
Section titled โStaging Setupโ- Populate
stagingenvironment variables in Infisical (/runtime/*and/ci/*) - Update URLs to point to
*.ordermatic.costaging services - Configure staging-specific API keys
- Test all integrations
๐ Troubleshooting
Section titled โ๐ TroubleshootingโCommon Issues
Section titled โCommon Issuesโ- Missing DATABASE_URL: Check PostgreSQL connection string
- Redis Connection Failed: Verify Redis URL and connectivity
- PDF Processing Errors: Check
GEMINI_API_KEYandTEMPORAL_ADDRESS - Authentication Issues: Verify Clerk keys are correct
- R2 Storage Errors: Check
R2_ACCESS_KEY_ID,R2_SECRET_ACCESS_KEY, and bucket permissions
Validation Commands
Section titled โValidation Commandsโ# Test database connectionpsql $DATABASE_URL -c "SELECT 1;"
# Test Redis connectionredis-cli -u $REDIS_URL ping
# Test R2 accessaws s3 ls s3://$R2_BUCKET_NAME --endpoint-url $R2_ENDPOINT_URL
# Validate environment variablesnode -e "console.log(process.env.DATABASE_URL ? 'DB OK' : 'DB MISSING')"