Synced files: - Quote wizard frontend (all components, hooks, types, config) - API updates (config, models, routers, schemas, services) - Client work (bg-builders, gurushow) - Scripts (BGB Lesley termination, CIPP, Datto, migration) - Temp files (Bardach contacts, VWP investigation, misc) - Credentials and session logs - Email service, PHP API, session logs Machine: ACG-M-L5090 Timestamp: 2026-03-10 19:11:00 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
84 lines
2.5 KiB
Python
84 lines
2.5 KiB
Python
"""
|
|
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 = "*"
|
|
|
|
# Microsoft Graph API (Email via M365)
|
|
GRAPH_TENANT_ID: str = ""
|
|
GRAPH_CLIENT_ID: str = ""
|
|
GRAPH_CLIENT_SECRET: str = ""
|
|
GRAPH_SENDER_EMAIL: str = "noreply@azcomputerguru.com"
|
|
ADMIN_NOTIFICATION_EMAIL: str = "mike@azcomputerguru.com"
|
|
|
|
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()
|