Files
delphi-database/app/config.py
2025-08-15 17:19:51 -05:00

89 lines
2.5 KiB
Python

"""
Delphi Consulting Group Database System - Configuration
"""
from typing import Optional
from pydantic import Field
from pydantic_settings import BaseSettings, SettingsConfigDict
class Settings(BaseSettings):
"""Application configuration (env and .env driven).
Environment precedence: real environment variables take priority over .env,
which take priority over defaults.
"""
# Application
app_name: str = "Delphi Consulting Group Database System"
app_version: str = "1.0.0"
debug: bool = False
# Database
database_url: str = "sqlite:///./data/delphi_database.db"
# Authentication / JWT
# Require SECRET_KEY to be provided via environment/.env (no insecure default)
secret_key: str = Field(..., min_length=32)
# Optional previous secret key to allow seamless rotation
previous_secret_key: Optional[str] = None
algorithm: str = "HS256"
access_token_expire_minutes: int = 240 # 4 hours
# Long-lived refresh token expiration (default 30 days)
refresh_token_expire_minutes: int = 43200
# Admin account settings
admin_username: str = "admin"
admin_password: str = "change-me"
# File paths
upload_dir: str = "./uploads"
backup_dir: str = "./backups"
# Pagination
default_page_size: int = 50
max_page_size: int = 200
# Docker/deployment settings
external_port: Optional[str] = None
allowed_hosts: Optional[str] = None
cors_origins: Optional[str] = None
secure_cookies: bool = False
compose_project_name: Optional[str] = None
# Logging
log_level: str = "INFO"
log_to_file: bool = True
log_rotation: str = "10 MB"
log_retention: str = "30 days"
# Cache / Redis
cache_enabled: bool = False
redis_url: Optional[str] = None
# Notifications
notifications_enabled: bool = False
# Email settings (optional)
smtp_host: Optional[str] = None
smtp_port: int = 587
smtp_username: Optional[str] = None
smtp_password: Optional[str] = None
smtp_starttls: bool = True
notification_email_from: str = "no-reply@localhost"
# QDRO notification recipients (comma-separated emails)
qdro_notify_email_to: Optional[str] = None
# Webhook settings (optional)
qdro_notify_webhook_url: Optional[str] = None
qdro_notify_webhook_secret: Optional[str] = None
# pydantic-settings v2 configuration
model_config = SettingsConfigDict(
env_file=".env",
env_prefix="",
case_sensitive=False,
env_ignore_empty=True,
extra="ignore",
)
settings = Settings()