urmi-ai/backend/app/config.py
2026-10-07 23:25:19 +05:30

69 lines
2.6 KiB
Python

from pydantic import computed_field
from pydantic_settings import BaseSettings, SettingsConfigDict
class Settings(BaseSettings):
app_name: str = "Urmi API"
environment: str = "development"
database_url: str = "postgresql+psycopg://urmi:urmi@localhost:5432/urmi"
frontend_origin: str = "http://localhost:5173"
# Comma-separated browser origins for CORS (defaults to frontend_origin only)
cors_origins: str = ""
auth_secret: str = "change-me-in-production"
auth_cookie_secure: bool = False
access_token_minutes: int = 60 * 24 * 7
google_client_id: str = ""
google_client_secret: str = ""
google_redirect_uri: str = "http://localhost:8000/api/v1/auth/google/callback"
admin_username: str = "root"
admin_password: str = "Nishtha#01"
upload_dir: str = "uploads"
kyc_template_path: str = "assets/kyc-template.docx"
dlt_loa_template_path: str = "assets/dlt-loa-template.docx"
max_upload_bytes: int = 10 * 1024 * 1024
ultronsms_base_url: str = "https://ultronsms.com"
ultronsms_user: str = ""
ultronsms_password: str = ""
redis_url: str = "redis://localhost:6379/0"
voice_relay_public_url: str = "ws://localhost:8000/api/v1/voice"
bonvoice_token: str = ""
bonvoice_api_url: str = "https://backend.pbx.bonvoice.com/autoDialManagement/autoCallBridging/"
bonvoice_media_allowlist: str = "103.131.25.5"
voice_session_ttl_seconds: int = 600
whatsapp_api_version: str = "v21.0"
whatsapp_verify_token: str = ""
whatsapp_app_secret: str = ""
whatsapp_access_token: str = ""
whatsapp_phone_number_id: str = ""
whatsapp_business_account_id: str = ""
meta_app_id: str = ""
meta_embedded_signup_config_id: str = ""
whatsapp_business_phone: str = "919411257916"
# Public HTTPS base for webhook callback (no trailing slash), e.g. https://urmiai.com
public_api_base_url: str = ""
model_config = SettingsConfigDict(
env_file=(".env", "../.env"),
env_file_encoding="utf-8",
extra="ignore",
)
@computed_field # type: ignore[prop-decorator]
@property
def cors_allowed_origins(self) -> list[str]:
configured = [item.strip() for item in self.cors_origins.split(",") if item.strip()]
if configured:
return configured
return [self.frontend_origin]
@computed_field # type: ignore[prop-decorator]
@property
def whatsapp_webhook_url(self) -> str:
base = self.public_api_base_url.rstrip("/") if self.public_api_base_url else ""
if base:
return f"{base}/api/v1/whatsapp/webhook"
return "/api/v1/whatsapp/webhook"
settings = Settings()