- Add google-cloud-storage dependency to requirements.txt - Add GCS configuration settings to config.py - Create storage.py utility module with upload/download/delete operations and temp file context managers for video generation - Update submissions.py to upload photos to GCS and return full GCS URLs - Update results.py to return full GCS URLs for video and record image - Update workers.py to use GCS for audio download, video creation, and cleanup - Update result.js to use audio_url directly from API response - Update docker-compose.yml with GCS credentials mount Storage now uses GCS bucket vday2026 in project holiday-project-india. Database stores blob paths; URLs constructed at API response time. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
87 lines
2.2 KiB
Python
87 lines
2.2 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
|
|
|
|
# Credits Management
|
|
MIN_AVAILABLE_CREDITS: int = 5000
|
|
|
|
# Timeouts
|
|
WEBHOOK_TIMEOUT_MINUTES: int = 10
|
|
API_REQUEST_TIMEOUT_SECONDS: int = 30
|
|
|
|
# Google Cloud Storage
|
|
GCS_PROJECT_ID: str = "holiday-project-india"
|
|
GCS_BUCKET_NAME: str = "vday2026"
|
|
GCS_CREDENTIALS_PATH: str = "google_cloud_storage.json"
|
|
GCS_UPLOADS_FOLDER: str = "uploads"
|
|
GCS_AUDIO_FOLDER: str = "audio"
|
|
GCS_VIDEO_FOLDER: str = "video"
|
|
GCS_IMAGES_FOLDER: str = "images"
|
|
|
|
# File Storage Paths (relative to backend root) - kept for local dev fallback
|
|
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"
|
|
|
|
@property
|
|
def COMPOSITE_STORAGE(self) -> Path:
|
|
return Path(self.STORAGE_BASE) / "images"
|
|
|
|
# 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()
|