import os from functools import lru_cache from typing import List class Settings: # App app_name: str = "QuantMind Backend" environment: str = os.getenv("ENVIRONMENT", "dev") # CORS cors_origins: List[str] = os.getenv("CORS_ORIGINS", "*").split(",") # Model model_path: str = os.getenv( "MODEL_PATH", "model/universal_multivariate_model_v1.h5", ) # Market data (Alpha Vantage) alpha_vantage_api_key: str = os.getenv("ALPHA_VANTAGE_API_KEY") # Prediction params history_window: int = int(os.getenv("HISTORY_WINDOW", "60")) max_forecast_days: int = int(os.getenv("MAX_FORECAST_DAYS", "14")) def validate(self): """ Validate critical settings at runtime """ if not self.alpha_vantage_api_key: raise RuntimeError( "ALPHA_VANTAGE_API_KEY is not set in environment variables" ) @lru_cache def get_settings() -> Settings: settings = Settings() settings.validate() return settings