Spaces:
Running on T4
Running on T4
File size: 3,512 Bytes
2756f0f 7a3215f 2756f0f 7a3215f 2756f0f 7a3215f 2756f0f 7a3215f 2756f0f fe40b87 6437539 2756f0f | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 | """Settings from environment variables (and an optional .env file)."""
from functools import lru_cache
from typing import Literal
from uuid import UUID
from pydantic import Field
from pydantic_settings import BaseSettings, SettingsConfigDict
class Settings(BaseSettings):
model_config = SettingsConfigDict(env_file=".env", extra="ignore")
env: Literal["dev", "test", "prod"] = "dev"
# Postgres (asyncpg driver), e.g. postgresql+asyncpg://user:pass@host/db
database_url: str = "postgresql+asyncpg://app:app@localhost:55440/app_dev"
# Connections per API process = pool_size + max_overflow. Keep the total under the database's client limit
# (Supabase's session pooler allows 15 across every client); extra requests wait up to pool_timeout_s.
database_pool_size: int = 5
database_max_overflow: int = 5
database_pool_timeout_s: float = 30.0
# Set true when DATABASE_URL points at a transaction-mode pooler (Supabase port 6543), which cannot keep
# prepared statements between transactions.
database_transaction_pooler: bool = False
api_audit_reader_account_ids: list[UUID] = Field(default_factory=list)
api_audit_enabled: bool = True
api_audit_max_body_bytes: int = Field(default=1048576, ge=1024, le=16777216)
api_audit_write_timeout_s: float = Field(default=2.0, gt=0, le=30)
api_audit_retention_days: int = Field(default=30, ge=1, le=365)
service_version: str = "0.1.0"
# Tokens
jwt_secret: str = "change-me"
access_token_ttl_s: int = 1800
refresh_token_ttl_days: int = 30
password_reset_ttl_s: int = 3600
# Object storage (S3-compatible: DigitalOcean Spaces in production)
storage_endpoint: str = "https://nyc3.digitaloceanspaces.com"
storage_region: str = "nyc3"
storage_bucket: str = "cognivision-media"
storage_key: str = ""
storage_secret: str = ""
upload_url_ttl_s: int = 900
download_url_ttl_s: int = 3600
# Media limits
max_video_bytes: int = 250 * 1024 * 1024
max_thumbnail_bytes: int = 5 * 1024 * 1024
max_video_seconds: float = 60.0
# Consent: when true, new analysis needs an accepted consent event. A withdrawal always blocks.
require_analysis_consent: bool = False
consent_versions: list[str] = ["1.0"]
# Plans (the free weekly limit is a fixed constant in app.modules.billing.entitlement, not a setting)
entitlement_window_days: int = 7
# Retention (cleanup job)
unattached_upload_ttl_h: int = 24
pending_session_ttl_h: int = 24
deleted_media_retention_days: int = 30
idempotency_ttl_h: int = 24
# Rate limits (per process)
auth_rate_limit_per_minute: int = 10
# Social sign-in (milestone 4)
apple_client_ids: list[str] = []
google_client_ids: list[str] = []
# Email (milestone 4)
email_from: str = "no-reply@cognivision.app"
resend_api_key: str = ""
password_reset_url: str = "https://cognivision.app/reset-password"
# Push (milestone 3)
fcm_project_id: str = ""
fcm_service_account_file: str = ""
# Billing (milestone 4)
pro_product_ids: list[str] = ["pro_monthly"]
apple_bundle_id: str = ""
apple_environment: Literal["Production", "Sandbox"] = "Production"
apple_issuer_id: str = ""
apple_key_id: str = ""
apple_private_key_file: str = ""
google_package_name: str = ""
google_service_account_file: str = ""
google_pubsub_audience: str = ""
@lru_cache
def get_settings() -> Settings:
return Settings()
|