app.config module#

Centralized application configuration via pydantic-settings.

This module defines the single source of truth for runtime configuration. Values are loaded from process environment variables and an optional .env file, validated with Pydantic, and exposed through a module-level Settings instance. This consolidation avoids ad-hoc os.getenv calls across the codebase and improves type safety and discoverability.

See Also#

app.database

Engine/session factories that consume settings.DATABASE_URL.

app.utils

Logging helpers and general utilities that may use config values.

Notes#

  • Primary role: provide a validated Settings model and a ready-to-use settings instance consumed throughout the application.

  • Key dependencies: pydantic_settings.BaseSettings, process environment, and an optional .env file at the project root.

  • Invariants: DATABASE_URL must be present; extra environment variables are ignored to minimize coupling; sensible defaults exist for non-critical options.

Examples#

>>> from app.config import settings
>>> isinstance(settings.DATABASE_URL, str)
True
>>> # Override via environment or instantiate directly for tests
>>> from app.config import Settings
True