4.6 KiB
4.6 KiB
Environment Variables
Purpose
List environment variables that influence runtime behavior, taken directly from settings.py and related auth/Celery configuration.
Code Locations (exact paths)
- Primary definitions and defaults:
backend/igny8_core/settings.py - JWT helpers:
backend/igny8_core/auth/utils.py
High-Level Responsibilities
- Configure secrets, debug flags, DB connections, CORS, auth, Celery, and billing providers without code changes.
Detailed Behavior
- Core flags:
SECRET_KEY(required for production)DEBUG(enables debug when set to true)IGNY8_DEBUG_THROTTLE(bypass rate limiting when true; defaults toDEBUG)IGNY8_USE_UNIFIED_EXCEPTION_HANDLER(controls custom DRF exception handler; enabled by default)USE_SITE_BUILDER_REFACTOR(feature flag for site builder)USE_SECURE_COOKIES(sets session/CSRF secure cookies)USE_SECURE_PROXY_HEADER(enablesSECURE_PROXY_SSL_HEADER)USE_X_FORWARDED_HOSTis disabled by default; no env provided.
- Database selection (PostgreSQL default with SQLite fallbacks):
DATABASE_URL(parsed for engine/user/pass/host/port/name; supports postgres or sqlite)DB_ENGINE(forces sqlite when set to sqlite/sqlite3)DJANGO_FORCE_POSTGRES(force Postgres even in debug)DB_NAME,DB_USER,DB_PASSWORD,DB_HOST,DB_PORT(used whenDATABASE_URLnot provided)USE_SQLITEandSQLITE_NAME(explicit sqlite override)
- CORS/hosts:
- CORS origins are hardcoded; no env toggle beyond
DEBUG. Trusted CSRF origins are static in settings.
- CORS origins are hardcoded; no env toggle beyond
- Auth/JWT:
JWT_SECRET_KEY(defaults toSECRET_KEY)JWT_ALGORITHM(defaults to HS256)JWT_ACCESS_TOKEN_EXPIRY(timedelta in settings; default 15 minutes)JWT_REFRESH_TOKEN_EXPIRY(default 30 days)
- Celery/Redis:
CELERY_BROKER_URL(defaults toredis://{REDIS_HOST}:{REDIS_PORT}/0)CELERY_RESULT_BACKEND(defaults to same as broker)REDIS_HOST,REDIS_PORT(defaults redis:6379)REDIS_SENTINEL_ENABLED(when true, adds sentinel backend options)REDIS_SSL_ENABLED(enables Redis backend SSL)
- Feature/config paths:
PUBLISH_SYNC_LOG_DIRis derived; no env override.
- Payments:
STRIPE_PUBLIC_KEY,STRIPE_SECRET_KEY,STRIPE_WEBHOOK_SECRETPAYPAL_CLIENT_ID,PAYPAL_CLIENT_SECRET,PAYPAL_API_BASE(defaults to sandbox base)
- Rate limiting and throttles:
- Scopes are defined in settings; toggling is via
IGNY8_DEBUG_THROTTLE.
- Scopes are defined in settings; toggling is via
- Security/Cookies:
USE_SECURE_COOKIES,USE_SECURE_PROXY_HEADERcontrol secure cookie and proxy behavior.
Data Structures / Models Involved (no code)
- None; variables configure runtime services used by auth, database, Celery, and billing.
Execution Flow
- Django reads env vars at import of
settings.py; defaults apply when unset. - Token helpers read JWT secrets/algorithms/expiries for generation and validation.
- Celery settings are consumed by workers/beat at startup.
Cross-Module Interactions
- Auth stack uses JWT settings and secrets.
- Account middleware uses plan validation; DB settings drive tenancy storage.
- Celery settings affect AI/automation/publishing/billing tasks.
- Stripe/PayPal keys are consumed by billing modules.
State Transitions (if applicable)
- Changes to env vars take effect on process restart; token expiry/secret changes invalidate existing tokens accordingly.
Error Handling
- Missing/invalid DB env falls back to defaults (SQLite in debug unless forced).
- Missing JWT secret falls back to
SECRET_KEY; an absent secret raises errors during decode if unset.
Tenancy Rules
- Env vars do not alter tenancy logic; they configure infrastructure supporting it.
Billing Rules (if applicable)
- Stripe/PayPal keys must be present for payment webhooks/operations; plan enforcement itself is not env-driven.
Background Tasks / Schedulers (if applicable)
- Celery broker/backend URLs and Redis options come from env; task timeouts and serializer are fixed in settings.
Key Design Considerations
- Favor explicit env configuration for production (secrets, DB, Redis, Stripe/PayPal).
- Keep debug-only flags (
DEBUG,IGNY8_DEBUG_THROTTLE) off in production. - Use
DATABASE_URLfor portability; fallback logic supports sqlite for local dev.
How Developers Should Work With This Module
- Set required secrets (
SECRET_KEY,JWT_SECRET_KEY, Stripe/PayPal keys) before deploying. - Choose DB via
DATABASE_URLor explicitDB_*vars; avoid sqlite in production unless intentional. - Configure Redis URLs for Celery in non-dev environments.
- Restart services after changing env vars to apply new configuration.