pahvalentines/backend/app/config.py
michael 9d53adaaf3 Add backend API, video generator, and frontend updates
- Add Python/FastAPI backend with Celery workers
- Add video generation with FFmpeg (spinning record animation)
- Add API endpoints: submissions, status polling, webhook, results
- Add database schema and Alembic migrations
- Update frontend pages with API integration
- Add project documentation and spec

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-30 10:31:58 -06:00

79 lines
1.9 KiB
Python

"""Application configuration using Pydantic Settings."""
from functools import lru_cache
from pathlib import Path
from pydantic_settings import BaseSettings
class Settings(BaseSettings):
"""Application settings loaded from environment variables."""
# Database
DATABASE_URL: str = "postgresql://pah:pah_password@localhost:5432/pah"
# Redis & Celery
REDIS_URL: str = "redis://localhost:6379/0"
CELERY_BROKER_URL: str = "redis://localhost:6379/0"
CELERY_RESULT_BACKEND: str = "redis://localhost:6379/0"
# External API
SONAUTO_API_URL: str = "https://api.sonauto.ai/v1"
SONAUTO_API_KEY: str = ""
WEBHOOK_BASE_URL: str = "http://localhost:8000"
# Queue & Rate Limiting
MAX_CONCURRENT_REQUESTS: int = 10
MAX_RETRIES: int = 3
FORM_SUBMIT_RETRY: int = 10
# Celery Beat Schedule (seconds)
QUEUE_PROCESSOR_INTERVAL: int = 60
CREDITS_CHECK_INTERVAL: int = 600
TIMEOUT_CHECK_INTERVAL: int = 300
# Credits Management
MIN_AVAILABLE_CREDITS: int = 5000
# Timeouts
WEBHOOK_TIMEOUT_MINUTES: int = 10
API_REQUEST_TIMEOUT_SECONDS: int = 30
# File Storage Paths (relative to backend root)
STORAGE_BASE: str = "../storage"
@property
def IMG_STORAGE(self) -> Path:
return Path(self.STORAGE_BASE) / "uploads"
@property
def AUDIO_STORAGE(self) -> Path:
return Path(self.STORAGE_BASE) / "audio"
@property
def VIDEO_STORAGE(self) -> Path:
return Path(self.STORAGE_BASE) / "video"
# Data Retention
FILE_RETENTION_DAYS: int = 30
# CORS Origins
CORS_ORIGINS: list[str] = [
"http://localhost",
"http://localhost:8000",
"http://localhost:8080",
]
class Config:
env_file = ".env"
env_file_encoding = "utf-8"
extra = "ignore"
@lru_cache
def get_settings() -> Settings:
"""Get cached settings instance."""
return Settings()
settings = get_settings()