from pydantic import BaseModel from typing import Optional from pathlib import Path import os class Settings(BaseModel): API_V1_STR: str = "/api/v1" PROJECT_NAME: str = "Todo API" PROJECT_DESCRIPTION: str = "A simple Todo API built with FastAPI and SQLite" VERSION: str = "0.1.0" # Database settings BASE_DIR: Path = Path(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))) DB_DIR: Path = BASE_DIR / "storage" / "db" SQLALCHEMY_DATABASE_URL: Optional[str] = None class Config: case_sensitive = True settings = Settings() # Ensure DB directory exists settings.DB_DIR.mkdir(parents=True, exist_ok=True) # Set the database URL settings.SQLALCHEMY_DATABASE_URL = f"sqlite:///{settings.DB_DIR}/db.sqlite"