Configuration
Environment variables, secrets, encryption, OAuth2, database, and production hygiene.
Intended audience: Stakeholders, Business analysts, Solution architects, Developers, Testers
Learning outcomes by role
Stakeholders
- Recognize mandatory secrets and environment classes for production readiness.
Business analysts
- Checklist configuration items for go-live sign-off.
Solution architects
- Produce environment-specific matrices (dev, staging, prod) from this guide.
Developers
- Set CADENCE_* variables and validate against AppSettings behavior.
Testers
- Build config-focused smoke tests and misconfiguration detection.
Configure Cadence from environment variables prefixed CADENCE_ (secrets, Postgres URLs, Redis, RabbitMQ, CORS, OAuth, logging). The authoritative list is in the repository root .env.example. Immutable infrastructure settings load into AppSettings (cadence.core.config); operational defaults and feature flags that change at runtime live in the global_settings database table (not in env vars).
Summary for stakeholders
Section titled “Summary for stakeholders”- Secrets and compliance —
CADENCE_SECRET_KEY,CADENCE_ENCRYPTION_KEY, and database URLs are deployment commitments; weak defaults are rejected or warned in production validation. - Separation — Env vars bootstrap the process; product operators tune many limits via admin APIs and
global_settings, not by redeploying for every change.
Business analysis
Section titled “Business analysis”- Go-live checklist — Map each CADENCE_ variable in
.env.exampleto an owner and verification step (smoke test, secret rotation procedure). - Non-functional requirements — CORS, OAuth redirect URLs, and log format tie directly to customer-facing browser apps and SIEM ingestion.
Architecture and integration
Section titled “Architecture and integration”
Runtime feature flags and tier defaults live in global_settings (DB), not AppSettings — see module docstring in cadence/core/config.py.
Prerequisites
Section titled “Prerequisites”- Infrastructure reachable: PostgreSQL, Redis, and optionally RabbitMQ
- Secrets generated for production (
openssl rand -hex 32for the encryption key)
Environment variables
Section titled “Environment variables”Security and tokens
Section titled “Security and tokens”| Variable | Purpose |
|---|---|
CADENCE_SECRET_KEY | JWT signing secret — must be changed in production |
CADENCE_ENCRYPTION_KEY | 64 hex chars (32 bytes AES-256) for encrypting secrets — generate with openssl rand -hex 32 |
CADENCE_JWT_ALGORITHM | Default HS256 |
CADENCE_ACCESS_TOKEN_TTL_SECONDS | Access token lifetime |
CADENCE_REFRESH_TOKEN_TTL_SECONDS | Refresh token lifetime |
Infrastructure
Section titled “Infrastructure”| Variable | Purpose |
|---|---|
CADENCE_POSTGRES_URL | Primary PostgreSQL URL |
CADENCE_POSTGRES_READ_URL | Optional read replica (unset = use primary) |
CADENCE_PGBOUNCER_ENABLED | true to use NullPool when PgBouncer fronts connections |
CADENCE_REDIS_URL | Session store, OAuth2 codes, rate limits |
CADENCE_RABBITMQ_URL | Event bus for settings broadcast and pool lifecycle events |
HTTP and CORS
Section titled “HTTP and CORS”| Variable | Purpose |
|---|---|
CADENCE_CORS_ORIGINS | Comma-separated allowed browser origins |
OAuth2 and social login
Section titled “OAuth2 and social login”| Variable | Purpose |
|---|---|
CADENCE_OAUTH_REDIRECT_BASE_URL | Nuxt app base URL for OAuth callback (default http://localhost:3000) |
CADENCE_CONSENT_UI_URL | Full URL to consent page (default {oauth_redirect_base_url}/oauth/consent) |
CADENCE_GOOGLE_CLIENT_ID / _SECRET | Google social OAuth |
CADENCE_GITHUB_CLIENT_ID / _SECRET | GitHub social OAuth |
CADENCE_OAUTH2_CLIENT_ID / _SECRET / _AUTHORIZATION_URL / _TOKEN_URL / _USERINFO_URL | Generic OAuth2 provider for social login |
CADENCE_OAUTH2_SCOPES | Default openid email profile |
Runtime behavior
Section titled “Runtime behavior”| Variable | Purpose |
|---|---|
CADENCE_LOG_FORMAT | json or text |
CADENCE_ENVIRONMENT | development / production / etc. |
Initial setup
Section titled “Initial setup”- Copy
.env.exampleto.env. - Bring up infrastructure (Docker Compose or your platform): PostgreSQL, Redis, RabbitMQ.
- Run migrations and bootstrap the admin user.
- Set
CADENCE_CORS_ORIGINSto your UI origin. - Start the API and UI; verify health endpoints (Monitoring).
Verification and quality
Section titled “Verification and quality”Troubleshooting
Section titled “Troubleshooting”| Symptom | Cause | Fix |
|---|---|---|
500 on startup | Database URL, credentials, or network | Check CADENCE_POSTGRES_URL and connectivity |
| Sessions flaky or dropped | Redis unavailable | Check CADENCE_REDIS_URL and Redis health |
| No JSON logs | CADENCE_LOG_FORMAT not set | Set CADENCE_LOG_FORMAT=json |
encryption_key validation error | Not exactly 64 hex characters | Regenerate with openssl rand -hex 32 |