Skip to main content

Configuration Reference

Contract Lucidity is configured via environment variables. The backend reads these through Pydantic's BaseSettings class, which supports both environment variables and a .env file at the project root.

All variables are case-insensitive (e.g., POSTGRES_USER and postgres_user are equivalent).

Database

VariableDefaultDescriptionService
POSTGRES_USERcl_userPostgreSQL usernamecl-backend, cl-worker, cl-db
POSTGRES_PASSWORDcl_password_change_mePostgreSQL passwordcl-backend, cl-worker, cl-db
POSTGRES_DBcontract_lucidityPostgreSQL database namecl-backend, cl-worker, cl-db
POSTGRES_HOSTcl-postgresPostgreSQL hostnamecl-backend, cl-worker
POSTGRES_PORT5432PostgreSQL portcl-backend, cl-worker
Change the default password

The default PostgreSQL password is cl_password_change_me. Always set a strong, unique password in production via POSTGRES_PASSWORD.

The database connection URLs are derived automatically:

  • Async (backend API): postgresql+asyncpg://{user}:{password}@{host}:{port}/{db}
  • Sync (Celery worker): postgresql+psycopg2://{user}:{password}@{host}:{port}/{db}

Redis / Celery

VariableDefaultDescriptionService
REDIS_HOSTcl-redisRedis hostnamecl-backend, cl-worker
REDIS_PORT6379Redis portcl-backend, cl-worker
REDIS_URLredis://cl-redis:6379/0Full Redis URLcl-backend, cl-worker
CELERY_BROKER_URLredis://cl-redis:6379/0Celery broker URL (Redis db 0)cl-worker
CELERY_RESULT_BACKENDredis://cl-redis:6379/1Celery result backend (Redis db 1)cl-worker

JWT / Authentication

VariableDefaultDescriptionService
JWT_SECRET_KEYchange-me-to-a-random-secret-in-productionSecret key for signing JWT tokenscl-backend
JWT_ALGORITHMHS256JWT signing algorithmcl-backend
JWT_ACCESS_TOKEN_EXPIRE_MINUTES60Access token lifetime in minutescl-backend
JWT_REFRESH_TOKEN_EXPIRE_DAYS7Refresh token lifetime in dayscl-backend
Change the JWT secret

The default JWT secret is a placeholder. In production, generate a random 64+ character secret:

openssl rand -hex 64

Application

VariableDefaultDescriptionService
APP_NAMEContract LucidityApplication display namecl-backend
APP_ENVdevelopmentEnvironment identifier (development, staging, production)cl-backend
LOG_LEVELINFOLogging level (DEBUG, INFO, WARNING, ERROR)cl-backend, cl-worker
MAX_UPLOAD_SIZE_MB100Maximum file upload size in megabytescl-backend

Storage

VariableDefaultDescriptionService
STORAGE_PATH/data/storagePath for uploaded document filescl-backend, cl-worker
CONFIG_PATH/data/configPath for application configuration filescl-backend, cl-worker

These paths correspond to Docker volumes cl-storage and cl-config. If running without Docker, ensure these directories exist and are writable.

CORS and URLs

VariableDefaultDescriptionService
CORS_ORIGINShttp://localhost:3000,https://contractlucidity.comComma-separated list of allowed CORS originscl-backend
FRONTEND_URLhttp://localhost:3000Public URL of the frontend (used for links in emails, etc.)cl-backend
BACKEND_INTERNAL_URLhttp://cl-backend:8000Internal URL for frontend-to-backend communicationcl-frontend
Adding your domain

For production, set CORS_ORIGINS to include your domain:

CORS_ORIGINS=https://contracts.yourcompany.com

The frontend uses BACKEND_INTERNAL_URL to proxy API requests within the Docker network. This should remain as the default unless you have a custom network topology.

Default Admin

VariableDefaultDescriptionService
DEFAULT_ADMIN_EMAILadmin@contractlucidity.localEmail for the auto-created admin accountcl-backend
DEFAULT_ADMIN_PASSWORD<your-strong-password>Initial password for the admin accountcl-backend

The default admin is created on first boot during the seed process. The account is flagged with must_change_password=True, prompting a password change on first login.

warning

Change DEFAULT_ADMIN_PASSWORD before first boot in production, or change the password immediately after first login. The seed process will not overwrite an existing admin account.

Frontend-Specific

These variables are set on the cl-frontend service in Docker Compose:

VariableDefaultDescriptionService
BACKEND_INTERNAL_URLhttp://cl-backend:8000Backend API URL used by the Next.js server-side proxycl-frontend
NEXT_PUBLIC_FRONTEND_URLhttp://localhost:3000Public-facing frontend URL (available client-side)cl-frontend
tip

NEXT_PUBLIC_ prefixed variables are embedded at build time in Next.js and available in the browser. BACKEND_INTERNAL_URL is server-side only and never exposed to the client.

Worker-Specific

VariableDefaultDescriptionService
CELERY_CONCURRENCY2Number of parallel Celery worker processescl-worker
Tuning concurrency

Each concurrency slot processes one document at a time and makes multiple AI API calls. Higher concurrency means faster throughput but more memory usage and higher AI API costs. Recommended values:

  • Development: 1-2
  • Small team: 2-4
  • Production: 4-8 (depending on available RAM and AI API rate limits)

Allow approximately 512 MB - 1 GB of RAM per concurrency slot.

Complete .env Example

.env
# Database
POSTGRES_USER=cl_user
POSTGRES_PASSWORD=your-strong-database-password
POSTGRES_DB=contract_lucidity

# Redis
REDIS_URL=redis://cl-redis:6379/0

# Authentication
JWT_SECRET_KEY=your-64-character-random-secret-here
JWT_ACCESS_TOKEN_EXPIRE_MINUTES=60
JWT_REFRESH_TOKEN_EXPIRE_DAYS=7

# Application
APP_ENV=production
LOG_LEVEL=INFO
MAX_UPLOAD_SIZE_MB=100

# CORS / URLs
CORS_ORIGINS=https://contracts.yourcompany.com
FRONTEND_URL=https://contracts.yourcompany.com
BACKEND_INTERNAL_URL=http://cl-backend:8000

# Admin
DEFAULT_ADMIN_EMAIL=admin@yourcompany.com
DEFAULT_ADMIN_PASSWORD=initial-strong-password

# Worker
CELERY_CONCURRENCY=4
warning

Never commit .env files to version control. Add .env to your .gitignore.