| | """ |
| | Backend configuration with environment variable loading. |
| | |
| | Per @specs/001-auth-api-bridge/research.md |
| | """ |
| | import os |
| | from functools import lru_cache |
| | from pathlib import Path |
| | from dotenv import load_dotenv |
| | from pydantic_settings import BaseSettings |
| | from sqlalchemy import create_engine |
| | from sqlmodel import SQLModel |
| |
|
| | |
| | |
| | env_path = Path(__file__).parent.parent / ".env" |
| | load_dotenv(env_path, override=True) |
| |
|
| |
|
| | class Settings(BaseSettings): |
| | """Application settings loaded from environment variables.""" |
| |
|
| | |
| | better_auth_secret: str |
| | better_auth_url: str = "http://localhost:3000" |
| |
|
| | |
| | database_url: str |
| |
|
| | |
| | api_port: int = 8000 |
| | api_host: str = "localhost" |
| | debug: bool = True |
| |
|
| | |
| | |
| | openai_api_key: str |
| | neon_database_url: str |
| | mcp_server_port: int = 8000 |
| | openai_model: str = "gpt-4-turbo-preview" |
| | mcp_server_host: str = "127.0.0.1" |
| |
|
| | |
| | email_host: str = "smtp.gmail.com" |
| | email_port: int = 587 |
| | email_username: str = "" |
| | email_password: str = "" |
| | email_from: str = "" |
| | email_from_name: str = "TaskFlow" |
| | emails_enabled: bool = True |
| |
|
| | class Config: |
| | env_file = ".env" |
| | case_sensitive = False |
| | extra = "ignore" |
| |
|
| |
|
| | @lru_cache() |
| | def get_settings() -> Settings: |
| | """Get cached settings instance.""" |
| | return Settings() |
| |
|
| |
|
| | |
| | settings = get_settings() |
| |
|
| | |
| | engine = create_engine( |
| | settings.database_url, |
| | poolclass=None, |
| | pool_size=5, |
| | max_overflow=10, |
| | pool_pre_ping=True, |
| | pool_recycle=3600, |
| | echo=settings.debug, |
| | ) |
| |
|
| |
|
| | def init_db(): |
| | """Initialize database tables.""" |
| | SQLModel.metadata.create_all(engine) |
| |
|