modcomms/backend/app/config.py
2025-12-12 09:03:17 -06:00

27 lines
909 B
Python

import os
from pathlib import Path
from dotenv import load_dotenv
# Load environment variables from .env file
load_dotenv()
class Settings:
"""Application settings loaded from environment variables."""
GEMINI_API_KEY: str = os.getenv("GEMINI_API_KEY", "")
CORS_ORIGINS: str = os.getenv("CORS_ORIGINS", "http://localhost:3000")
HOST: str = os.getenv("HOST", "0.0.0.0")
PORT: int = int(os.getenv("PORT", "8000"))
# Reference docs path - defaults to ../reference_docs relative to backend/
_default_ref_docs = Path(__file__).parent.parent.parent / "reference_docs"
REFERENCE_DOCS_PATH: str = os.getenv("REFERENCE_DOCS_PATH", str(_default_ref_docs))
def validate(self) -> None:
"""Validate required settings are present."""
if not self.GEMINI_API_KEY:
raise ValueError("GEMINI_API_KEY environment variable is required")
settings = Settings()