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_ACCESS_KEY=your-access-keyR2_SECRET_KEY=your-secret-key
# PDF ProcessingPDF_PROCESSOR_URL=http://...PDF_PROCESSOR_TOKEN=your-token
# Email (Resend)RESEND_API_KEY=re_...
# GitHub IntegrationGITHUB_TOKEN=ghp_...GITHUB_REPO_OWNER=your-orgGITHUB_REPO_NAME=erp-unlocked
# Dagster / TemporalDAGSTER_CLOUD_URL=https://your-org.dagster.cloudDAGSTER_CLOUD_API_TOKEN=your_dagster_api_tokenDAGSTER_GRAPHQL_URL=https://your-dagster-graphql-endpoint/graphqlDAGSTER_GRAPHQL_TOKEN=your_dagster_graphql_tokenTEMPORAL_SERVER_URL=your-temporal-serverTEMPORAL_NAMESPACE=default
# Slack (Optional)SLACK_WEBHOOK_URL=https://hooks.slack.com/...Optional Environment Variables:
# Database Pool ConfigurationDB_POOL_MAX=10DB_POOL_IDLE_TIMEOUT=30000DB_CONNECTION_TIMEOUT=10000๐ PDF API (apps/pdf-api)
Section titled โ๐ PDF API (apps/pdf-api)โ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
# Service AuthenticationPDF_PROCESSOR_TOKEN=your-token
# PDF ProcessingMAX_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)
# CORSCORS_ORIGINS=*|comma-separated-origins
# LoggingLOG_LEVEL=INFO|DEBUG|WARNING|ERROR๐ PDF Worker (apps/pdf-worker)
Section titled โ๐ PDF Worker (apps/pdf-worker)โ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
# Service AuthenticationPDF_PROCESSOR_TOKEN=your-token
# PDF ProcessingMAX_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)
# LoggingLOG_LEVEL=INFO|DEBUG|WARNING|ERROR๐ฆ 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
# Service AuthenticationPDF_PROCESSOR_TOKEN=your-token
# 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 for CI/CD Pipeline
Section titled โGitHub Secrets for CI/CD PipelineโProduction Environment:
# CloudflareCLOUDFLARE_API_TOKEN=your-cloudflare-tokenCLOUDFLARE_ACCOUNT_ID=your-account-id
# Webapp URLsPRODUCTION_WEBAPP_URL=https://app.erpunlocked.comSTAGING_WEBAPP_URL=https://staging.erpunlocked.com
# Coolify WebhooksCOOLIFY_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 KeysPUBLIC_CLERK_PUBLISHABLE_KEY_PRODUCTION=pk_...PUBLIC_CLERK_PUBLISHABLE_KEY_STAGING=pk_...๐ Deployment Environment Variables
Section titled โ๐ Deployment Environment VariablesโCoolify (Docker Services)
Section titled โCoolify (Docker Services)โWebapp Service:
NODE_ENV=productionPDF_PROCESSOR_URL=http://erp-unlocked-pdf-api:8000REDIS_URL=redis://redis:6379/0PORT=4321
# R2 StoragePUBLIC_R2_ACCOUNT_ID=your-account-idPUBLIC_R2_BUCKET_NAME=your-bucket-nameR2_ACCESS_KEY=your-access-keyR2_SECRET_KEY=your-secret-keyPDF API Service:
REDIS_URL=redis://redis:6379/0DATABASE_URL=your-database-urlPDF Worker Service:
REDIS_URL=redis://redis:6379/0DATABASE_URL=your-database-urlCloudflare Pages (Marketing Site)
Section titled โCloudflare Pages (Marketing Site)โProduction:
PUBLIC_WEBAPP_URL=https://app.erpunlocked.comStaging:
PUBLIC_WEBAPP_URL=https://staging.erpunlocked.com๐ Environment Setup Checklist
Section titled โ๐ Environment Setup ChecklistโDevelopment Setup
Section titled โDevelopment Setupโ- Copy
.env.exampleto.envin 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
Production Setup
Section titled โProduction Setupโ- 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
Staging Setup
Section titled โStaging Setupโ- Copy production environment variables
- Update URLs to point to staging 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_KEY and PDF_PROCESSOR_TOKEN
- Authentication Issues: Verify Clerk keys are correct
- R2 Storage Errors: Check R2 credentials 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')"