| 12345678910111213141516171819202122232425262728293031323334 |
- """Application settings.
- Configuration is read from the environment. For the MVP the two knobs are the
- database URL and the ``USE_FAKE_DATA`` flag.
- """
- from __future__ import annotations
- from functools import lru_cache
- from pydantic_settings import BaseSettings, SettingsConfigDict
- class Settings(BaseSettings):
- """Runtime settings, populated from environment variables.
- ``DATABASE_URL`` and ``USE_FAKE_DATA`` (case-insensitive) override defaults.
- """
- model_config = SettingsConfigDict(env_file=".env", extra="ignore")
- # Async SQLAlchemy URL. asyncpg driver is required for the async engine.
- database_url: str = "postgresql+asyncpg://hsdata:hsdata@localhost:5432/hsdata"
- # When true, the funnel API serves a realistic in-memory snapshot instead of
- # querying Postgres. Default ON so `uvicorn app.main:app` works with zero
- # infrastructure. Set USE_FAKE_DATA=false to read the real wide table.
- use_fake_data: bool = True
- @lru_cache
- def get_settings() -> Settings:
- """Return a cached Settings instance."""
- return Settings()
|