config.py 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. from pathlib import Path
  2. from pydantic_settings import BaseSettings
  3. # Application version - single source of truth
  4. APP_VERSION = "0.1.5b"
  5. GITHUB_REPO = "maziggy/bambusy"
  6. class Settings(BaseSettings):
  7. app_name: str = "BambuTrack"
  8. debug: bool = False # Default to production mode
  9. # Paths
  10. base_dir: Path = Path(__file__).resolve().parent.parent.parent.parent
  11. archive_dir: Path = base_dir / "archive"
  12. static_dir: Path = base_dir / "static"
  13. log_dir: Path = base_dir / "logs"
  14. database_url: str = f"sqlite+aiosqlite:///{base_dir}/bambutrack.db"
  15. # Logging
  16. log_level: str = "INFO" # Override with LOG_LEVEL env var or DEBUG=true
  17. log_to_file: bool = True # Set to false to disable file logging
  18. # API
  19. api_prefix: str = "/api/v1"
  20. class Config:
  21. env_file = ".env"
  22. env_file_encoding = "utf-8"
  23. settings = Settings()
  24. # Ensure directories exist
  25. settings.archive_dir.mkdir(exist_ok=True)
  26. settings.static_dir.mkdir(exist_ok=True)
  27. if settings.log_to_file:
  28. settings.log_dir.mkdir(exist_ok=True)