Files
auto-virtual-tryon/app/config/settings.py

54 lines
1.5 KiB
Python

"""Application settings."""
from functools import lru_cache
from pathlib import Path
from pydantic_settings import BaseSettings, SettingsConfigDict
PROJECT_ROOT = Path(__file__).resolve().parents[2]
class Settings(BaseSettings):
"""Runtime settings loaded from environment variables."""
app_name: str = "temporal-image-pipeline"
api_prefix: str = "/api/v1"
debug: bool = False
auto_create_tables: bool = True
database_url: str = "sqlite+aiosqlite:///./temporal_demo.db"
temporal_address: str = "localhost:7233"
temporal_namespace: str = "default"
s3_access_key: str = ""
s3_secret_key: str = ""
s3_bucket: str = ""
s3_region: str = ""
s3_endpoint: str = ""
s3_cname: str = ""
s3_presign_expiry_seconds: int = 900
image_generation_provider: str = "mock"
gemini_api_key: str = ""
gemini_base_url: str = "https://api.museidea.com/v1beta"
gemini_model: str = "gemini-3.1-flash-image-preview"
gemini_timeout_seconds: int = 300
gemini_max_attempts: int = 2
model_config = SettingsConfigDict(
env_file=PROJECT_ROOT / ".env",
env_file_encoding="utf-8",
case_sensitive=False,
extra="ignore",
)
@property
def sync_database_url(self) -> str:
"""Return a synchronous SQLAlchemy URL for migrations."""
return self.database_url.replace("+aiosqlite", "")
@lru_cache(maxsize=1)
def get_settings() -> Settings:
"""Return the cached application settings."""
return Settings()