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.databaseEngine/session factories that consume
settings.DATABASE_URL.app.utilsLogging helpers and general utilities that may use config values.
Notes#
Primary role: provide a validated
Settingsmodel and a ready-to-usesettingsinstance consumed throughout the application.Key dependencies:
pydantic_settings.BaseSettings, process environment, and an optional.envfile at the project root.Invariants:
DATABASE_URLmust 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