Skip to content

Environment Variables Reference

This document lists all environment variables required by each app and package in the ERP-Unlocked monorepo.

Required Environment Variables:

Terminal window
# Authentication (Clerk)
PUBLIC_CLERK_PUBLISHABLE_KEY=pk_...
CLERK_SECRET_KEY=sk_...
# Database
DATABASE_URL=postgresql://...
# Encryption
ENCRYPTION_KEY=your-encryption-key
# Redis
REDIS_URL=redis://...
# App Configuration
APP_ENV=development|staging|production
DEBUG_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-id
PUBLIC_R2_BUCKET_NAME=your-bucket-name
R2_ACCESS_KEY=your-access-key
R2_SECRET_KEY=your-secret-key
# PDF Processing
PDF_PROCESSOR_URL=http://...
PDF_PROCESSOR_TOKEN=your-token
# Email (Resend)
RESEND_API_KEY=re_...
# GitHub Integration
GITHUB_TOKEN=ghp_...
GITHUB_REPO_OWNER=your-org
GITHUB_REPO_NAME=erp-unlocked
# Dagster / Temporal
DAGSTER_CLOUD_URL=https://your-org.dagster.cloud
DAGSTER_CLOUD_API_TOKEN=your_dagster_api_token
DAGSTER_GRAPHQL_URL=https://your-dagster-graphql-endpoint/graphql
DAGSTER_GRAPHQL_TOKEN=your_dagster_graphql_token
TEMPORAL_SERVER_URL=your-temporal-server
TEMPORAL_NAMESPACE=default
# Slack (Optional)
SLACK_WEBHOOK_URL=https://hooks.slack.com/...

Optional Environment Variables:

Terminal window
# Database Pool Configuration
DB_POOL_MAX=10
DB_POOL_IDLE_TIMEOUT=30000
DB_CONNECTION_TIMEOUT=10000

Required Environment Variables:

Terminal window
# Redis
REDIS_URL=redis://...
# Database
DATABASE_URL=postgresql://...
# R2 Storage
R2_ENDPOINT_URL=https://...
R2_ACCESS_KEY_ID=your-access-key
R2_SECRET_ACCESS_KEY=your-secret-key
R2_BUCKET_NAME=your-bucket-name
# Gemini AI
GEMINI_API_KEY=your-gemini-key
# Service Authentication
PDF_PROCESSOR_TOKEN=your-token
# PDF Processing
MAX_PARALLEL_CHUNKS=4 # Number of chunks processed in parallel (default: 4)
PDF_PAGES_PER_CHUNK=2 # Pages per chunk (default: 2)
PDF_OVERLAP_PAGES=1 # Overlap pages between chunks (default: 1)
# CORS
CORS_ORIGINS=*|comma-separated-origins
# Logging
LOG_LEVEL=INFO|DEBUG|WARNING|ERROR

Required Environment Variables:

Terminal window
# Redis
REDIS_URL=redis://...
# Database
DATABASE_URL=postgresql://...
# R2 Storage
R2_ENDPOINT_URL=https://...
R2_ACCESS_KEY_ID=your-access-key
R2_SECRET_ACCESS_KEY=your-secret-key
R2_BUCKET_NAME=your-bucket-name
# Gemini AI
GEMINI_API_KEY=your-gemini-key
# Service Authentication
PDF_PROCESSOR_TOKEN=your-token
# PDF Processing
MAX_PARALLEL_CHUNKS=4 # Number of chunks processed in parallel (default: 4)
PDF_PAGES_PER_CHUNK=2 # Pages per chunk (default: 2)
PDF_OVERLAP_PAGES=1 # Overlap pages between chunks (default: 1)
# Logging
LOG_LEVEL=INFO|DEBUG|WARNING|ERROR

Required Environment Variables:

Terminal window
# Database Connection
DATABASE_URL=postgresql://...

Optional Environment Variables:

Terminal window
# Database Pool Configuration
DB_POOL_MAX=10
DB_POOL_IDLE_TIMEOUT=30000
DB_CONNECTION_TIMEOUT=10000
# Environment
NODE_ENV=development|production

Required Environment Variables:

Terminal window
# Redis
REDIS_URL=redis://...
# Database
DATABASE_URL=postgresql://...
# R2 Storage
R2_ENDPOINT_URL=https://...
R2_ACCESS_KEY_ID=your-access-key
R2_SECRET_ACCESS_KEY=your-secret-key
R2_BUCKET_NAME=your-bucket-name
# Gemini AI
GEMINI_API_KEY=your-gemini-key
# Service Authentication
PDF_PROCESSOR_TOKEN=your-token
# Logging
LOG_LEVEL=INFO|DEBUG|WARNING|ERROR

Optional Environment Variables:

Terminal window
# PDF Processing
MAX_PARALLEL_CHUNKS=2
# CORS
CORS_ORIGINS=*|comma-separated-origins

No environment variables required.


No environment variables required.


Production Environment:

Terminal window
# Cloudflare
CLOUDFLARE_API_TOKEN=your-cloudflare-token
CLOUDFLARE_ACCOUNT_ID=your-account-id
# Webapp URLs
PRODUCTION_WEBAPP_URL=https://app.erpunlocked.com
STAGING_WEBAPP_URL=https://staging.erpunlocked.com
# Coolify Webhooks
COOLIFY_PRODUCTION_WEBHOOK_WEB=https://...
COOLIFY_PRODUCTION_WEBHOOK_PDF_API=https://...
COOLIFY_PRODUCTION_WEBHOOK_PDF_WORKER=https://...
COOLIFY_STAGING_WEBHOOK_WEB=https://...
# Optional legacy secret: staging no longer auto-deploys pdf-api,
# but the webhook may remain configured during the retirement window.
COOLIFY_STAGING_WEBHOOK_PDF_API=https://...
COOLIFY_STAGING_WEBHOOK_PDF_WORKER=https://...
COOLIFY_TOKEN=your-coolify-token
# Clerk Keys
PUBLIC_CLERK_PUBLISHABLE_KEY_PRODUCTION=pk_...
PUBLIC_CLERK_PUBLISHABLE_KEY_STAGING=pk_...

Webapp Service:

Terminal window
NODE_ENV=production
PDF_PROCESSOR_URL=http://erp-unlocked-pdf-api:8000
REDIS_URL=redis://redis:6379/0
PORT=4321
# R2 Storage
PUBLIC_R2_ACCOUNT_ID=your-account-id
PUBLIC_R2_BUCKET_NAME=your-bucket-name
R2_ACCESS_KEY=your-access-key
R2_SECRET_KEY=your-secret-key

PDF API Service:

Terminal window
REDIS_URL=redis://redis:6379/0
DATABASE_URL=your-database-url

PDF Worker Service:

Terminal window
REDIS_URL=redis://redis:6379/0
DATABASE_URL=your-database-url

Production:

Terminal window
PUBLIC_WEBAPP_URL=https://app.erpunlocked.com

Staging:

Terminal window
PUBLIC_WEBAPP_URL=https://staging.erpunlocked.com

  • Copy .env.example to .env in each app directory
  • Set up PostgreSQL database
  • Set up Redis instance
  • Configure R2 storage credentials (for webapp, pdf-api, pdf-worker)
  • Get Gemini API key
  • Set up Clerk authentication
  • Configure Dagster and Temporal credentials
  • Set all required environment variables in Coolify
  • Configure GitHub secrets for CI/CD
  • Set up Cloudflare Pages environment variables
  • Verify all webhook URLs are correct
  • Test database connections
  • Verify Redis connectivity
  • Test R2 storage access
  • Copy production environment variables
  • Update URLs to point to staging services
  • Configure staging-specific API keys
  • Test all integrations

  1. Missing DATABASE_URL: Check PostgreSQL connection string
  2. Redis Connection Failed: Verify Redis URL and connectivity
  3. PDF Processing Errors: Check GEMINI_API_KEY and PDF_PROCESSOR_TOKEN
  4. Authentication Issues: Verify Clerk keys are correct
  5. R2 Storage Errors: Check R2 credentials and bucket permissions
Terminal window
# Test database connection
psql $DATABASE_URL -c "SELECT 1;"
# Test Redis connection
redis-cli -u $REDIS_URL ping
# Test R2 access
aws s3 ls s3://$R2_BUCKET_NAME --endpoint-url $R2_ENDPOINT_URL
# Validate environment variables
node -e "console.log(process.env.DATABASE_URL ? 'DB OK' : 'DB MISSING')"