Skip to content

Environment variables

All env vars use the SM_ prefix. Settings are loaded at boot — anything that must be known before the DB is open lives here. Runtime-tunable settings (SMTP creds, feature flags, storage backends) live in the DB-backed settings store and are edited from /settings/modules.

This is the full reference. See Configuration for a narrative overview.

Framework

VariableDefaultNotes
SM_DATABASE_URLsqlite+aiosqlite:///./app.dbRequired in production. Async URL: postgresql+asyncpg://user:pw@host:5432/db or sqlite+aiosqlite:///./app.db.
SM_ENVIRONMENTdevelopmentAny value other than development, test, testing triggers strict discovery + placeholder-secret checks.
SM_SECRET_KEYchange-me-in-productionMust be overridden in production — session cookie signing key.
SM_DEBUGfalseEnables debug mode (tracebacks in HTTP responses).
SM_LOG_LEVELINFODEBUG/INFO/WARNING/ERROR.
SM_LOG_FORMATplainplain for dev, json for structured logs in prod.
SM_MULTI_TENANTfalseEnables TenantMiddleware + MultiTenantMixin auto-filter.
SM_TENANT_HEADERX-Tenant-IDHTTP header that identifies the current tenant.
SM_MODULES_ENABLEDunsetComma-separated allow-list to disable modules without uninstalling them.
SM_VITE_DEV_URLhttp://localhost:5050Dev only — where the Vite HMR client connects.

DB connection pool

VariableDefaultNotes
SM_DB_POOL_SIZE5SQLAlchemy pool_size.
SM_DB_MAX_OVERFLOW10SQLAlchemy max_overflow.
SM_DB_POOL_PRE_PINGtrueTest connections before use.
SM_DB_POOL_RECYCLE1800Recycle connections after N seconds (helps with LB idle drops).

Internationalization

VariableDefaultNotes
SM_I18N_DEFAULT_LOCALEenMust be in SM_I18N_SUPPORTED_LOCALES.
SM_I18N_SUPPORTED_LOCALESenComma-separated, e.g. en,es,de.
SM_I18N_COOKIE_NAMElocaleCookie that stores the user's selected locale.

Users module

VariableDefaultNotes
SM_USERS_BOOTSTRAP_EMAILunsetAuto-creates an admin if set and users_user is empty.
SM_USERS_BOOTSTRAP_PASSWORDunsetPaired with the email above.
SM_USERS_ALLOW_SIGNUPfalseIf true, /users/register is public.
SM_USERS_MAILERconsoleconsole logs the invite link to stdout; smtp sends real emails.
SM_USERS_BASE_URLderivedPublic URL used to build invite links.
SM_USERS_SMTP_HOSTRequired when mailer is smtp.
SM_USERS_SMTP_PORT587
SM_USERS_SMTP_USERNAME
SM_USERS_SMTP_PASSWORD
SM_USERS_SMTP_FROM
SM_USERS_SMTP_TLStrue

Background tasks (Celery)

Prefix SM_BG_TASKS_*. Set in docker-compose.yml for local dev.

VariableDefaultNotes
SM_BG_TASKS_BROKER_URLredis://localhost:6379/0Celery broker.
SM_BG_TASKS_RESULT_BACKENDredis://localhost:6379/1Celery result backend.

File storage module

VariableDefaultNotes
SM_FILE_STORAGE_BACKENDlocallocal, s3, or memory.
SM_FILE_STORAGE_LOCAL_ROOT./storageLocal backend root directory.
SM_FILE_STORAGE_S3_BUCKETS3 bucket name.
SM_FILE_STORAGE_S3_REGIONS3 region.

Most of the storage config moved to DB-backed settings; the env vars above are the ones needed at bootstrap.

Patterns

Per-module prefix

Every module-owned env var uses SM_<MODULE_UPPER>_*. Keeps settings self-describing and avoids collisions.

Comma-separated lists

Pydantic parses comma-separated strings into list[str]SM_I18N_SUPPORTED_LOCALES=en,es,de becomes ["en", "es", "de"].

Booleans

true, 1, yes, onTrue. Everything else → False. Pydantic is strict — SM_DEBUG=True works, SM_DEBUG=TRUE works, but watch for whitespace.

Placeholder-secret check

In production (SM_ENVIRONMENT != development), boot fails if SM_SECRET_KEY == "change-me-in-production". Override before deploying.

.env files

The app loads .env via pydantic's BaseSettings. Order of precedence:

  1. Actual environment variables.
  2. .env file in the current working directory.
  3. Defaults from the Settings class.

Keep secrets out of .env.example — check in only non-secret defaults.

Module-enabled allow-list

bash
SM_MODULES_ENABLED=users,orders,dashboard

Loads only the listed modules. Useful for:

  • TestsSM_MODULES_ENABLED=users,orders for a minimal app.
  • Worker processes — if you run a Celery worker as a separate container, it only needs background_tasks and whatever modules define tasks it processes.
  • Emergency disable — hide a broken module without rebuilding the image. Remove it from the list, restart.

Released under the MIT License.