Skip to main content

Configuration

ChemAudit is configured through environment variables and deployment profiles that control batch limits, worker counts, and resource allocation.

Environment Variables​

Configuration is managed through a .env file in the project root. Copy .env.example to get started:

cp .env.example .env

Required Variables​

These variables must be set before starting ChemAudit:

VariableDescriptionExample
POSTGRES_PASSWORDDatabase passwordGenerated with openssl rand -base64 32
SECRET_KEYApplication secret keyGenerated with openssl rand -base64 32
API_KEY_ADMIN_SECRETAdmin secret for API key managementGenerated with openssl rand -base64 32
CSRF_SECRET_KEYCSRF protection secretGenerated with openssl rand -base64 32
Never Commit Secrets

Never commit your .env file to version control. Keep secrets secure and rotate them periodically.

Optional Variables​

VariableDescriptionDefault
POSTGRES_USERDatabase usernamechemaudit
POSTGRES_DBDatabase namechemaudit
DATABASE_URLFull database connection stringAuto-generated from above
REDIS_PASSWORDRedis authentication passwordchangeme_redis
REDIS_URLRedis connection stringredis://:${REDIS_PASSWORD}@redis:6379/0
DEBUGEnable debug modefalse
CORS_ORIGINS_STRAllowed CORS origins (comma-separated)http://localhost:3002
GRAFANA_PASSWORDGrafana admin passwordadmin
Redis Authentication

Redis authentication is enforced in both development and production. The REDIS_URL must include the password. If you see Authentication required errors, ensure REDIS_PASSWORD is set in your .env file and REDIS_URL includes it.

Development vs Production​

Development Mode

In development (using docker-compose.yml), services are exposed on individual ports. The frontend runs on 3002, backend on 8001.

Production Mode

In production (using docker-compose.prod.yml), all services run behind Nginx on port 80/443.

Startup Secret Validation

When DEBUG=false, ChemAudit validates that SECRET_KEY, API_KEY_ADMIN_SECRET, and CSRF_SECRET_KEY do not contain placeholder values (CHANGE_ME). The application will refuse to start until secure values are set. Use openssl rand -hex 64 to generate secrets, or run deploy.sh which auto-generates them.

Deployment Profiles​

ChemAudit includes pre-configured deployment profiles that set batch limits, worker counts, and memory allocation based on your workload.

Available Profiles​

ProfileMax BatchMax File SizeCelery WorkersUse Case
small1,000100 MB2Development, testing
medium10,000500 MB4Standard production
large50,000500 MB8High-throughput labs
xl100,0001 GB12Enterprise scale
coconut1,000,0001 GB16Full COCONUT database

Profile Configuration Files​

Profiles are defined in YAML files under config/:

# config/medium.yml
MAX_BATCH_SIZE: 10000
MAX_FILE_SIZE_MB: 500
CELERY_WORKERS: 4
GUNICORN_WORKERS: 4
REDIS_MAXMEMORY: 512mb
BACKEND_MEMORY_LIMIT: 2g
CELERY_MEMORY_LIMIT: 2g

Using Deployment Profiles​

The deploy.sh script makes it easy to deploy with a specific profile:

# Interactive mode - shows menu of profiles
./deploy.sh

# Direct profile selection
./deploy.sh large

The script automatically:

  1. Parses the selected profile from config/{profile}.yml
  2. Exports environment variables for Docker Compose
  3. Updates .env with profile settings
  4. Launches docker-compose.prod.yml

Custom Profiles​

deploy.sh only accepts the built-in profile names (small, medium, large, xl, coconut). To change settings, edit the matching file in config/ and deploy with that profile:

# Edit config/medium.yml with your settings
# Then deploy
./deploy.sh medium

Notification & Integration Variables​

VariableDescriptionDefault
NOTIFICATION_EMAILGlobal email for batch completion notificationsNone
SMTP_HOSTSMTP server hostnameNone
SMTP_PORTSMTP server port587
SMTP_USERSMTP authentication usernameNone
SMTP_PASSWORDSMTP authentication passwordNone
WEBHOOK_URLWebhook endpoint URL for batch completion callbacksNone
WEBHOOK_SECRETHMAC-SHA256 signing secret for webhook payloadsNone
OPSIN_JAR_PATHPath to OPSIN JAR for IUPAC name conversionAuto-provisioned in Docker
BASE_URLPublic URL for report links in emails and webhookshttp://localhost:3002

Dynamic Limit Discovery​

The frontend automatically discovers deployment limits from the backend API:

curl http://localhost:8001/api/v1/config

Response:

{
"app_name": "ChemAudit",
"app_version": "1.0.0",
"deployment_profile": "medium",
"limits": {
"max_batch_size": 10000,
"max_file_size_mb": 500,
"max_file_size_bytes": 524288000
}
}

This ensures the UI always displays accurate limits for your deployment.

CORS Configuration​

For development, CORS origins are configured in .env:

# Comma-separated string (not JSON array)
CORS_ORIGINS_STR=http://localhost:3002,http://127.0.0.1:3002

For production behind Nginx, CORS is handled by the proxy configuration.

CORS Security

Only add trusted origins to CORS_ORIGINS_STR. In production, use your actual domain names.

Next Steps​

With configuration complete:

  1. Run your first validation - Test your setup
  2. Explore deployment options - Production deployment guide
  3. Monitor your deployment - Set up Prometheus and Grafana