""" Configuration management for ClaudeTools. This module provides centralized configuration management using pydantic-settings to load and validate environment variables. All sensitive configuration values are loaded from environment variables rather than being hardcoded. """ from functools import lru_cache from pydantic_settings import BaseSettings class Settings(BaseSettings): """ Application settings loaded from environment variables. All settings are loaded from environment variables or a .env file. This ensures sensitive information like database credentials and encryption keys are never hardcoded in the source code. Attributes: DATABASE_URL: Complete database connection URL DATABASE_NAME: Database name (for display purposes) DATABASE_POOL_SIZE: Number of connections to maintain in the pool DATABASE_MAX_OVERFLOW: Maximum number of connections beyond pool_size JWT_SECRET_KEY: Secret key for JWT token signing ENCRYPTION_KEY: Key for encrypting sensitive data JWT_ALGORITHM: Algorithm used for JWT token signing ACCESS_TOKEN_EXPIRE_MINUTES: Token expiration time in minutes ALLOWED_ORIGINS: Comma-separated list of allowed CORS origins """ # Database configuration DATABASE_URL: str DATABASE_NAME: str = "claudetools" DATABASE_POOL_SIZE: int = 20 DATABASE_MAX_OVERFLOW: int = 10 # Security configuration JWT_SECRET_KEY: str ENCRYPTION_KEY: str JWT_ALGORITHM: str = "HS256" ACCESS_TOKEN_EXPIRE_MINUTES: int = 60 # API configuration ALLOWED_ORIGINS: str = "*" class Config: """Pydantic configuration.""" env_file = ".env" case_sensitive = True @lru_cache() def get_settings() -> Settings: """ Get cached application settings. This function uses lru_cache to ensure settings are only loaded once and reused throughout the application lifecycle, improving performance and ensuring consistency. Returns: Settings: The application settings instance Example: ```python from api.config import get_settings settings = get_settings() print(settings.DATABASE_URL) ``` """ return Settings()