203 lines
7.3 KiB
Python
203 lines
7.3 KiB
Python
"""
|
||
Конфигурация приложения
|
||
"""
|
||
from pathlib import Path
|
||
from pydantic_settings import BaseSettings
|
||
from functools import lru_cache
|
||
from typing import List
|
||
|
||
|
||
BASE_DIR = Path(__file__).resolve().parents[2]
|
||
ENV_PATH = BASE_DIR / ".env"
|
||
|
||
|
||
class Settings(BaseSettings):
|
||
# ============================================
|
||
# APPLICATION
|
||
# ============================================
|
||
app_name: str = "Ticket Form Intake Platform"
|
||
app_env: str = "development"
|
||
debug: bool = True
|
||
|
||
# API
|
||
api_v1_prefix: str = "/api/v1"
|
||
backend_url: str = "http://localhost:8200"
|
||
frontend_url: str = "http://localhost:5175"
|
||
|
||
# ============================================
|
||
# DATABASE (PostgreSQL)
|
||
# ============================================
|
||
postgres_host: str = "147.45.189.234"
|
||
postgres_port: int = 5432
|
||
postgres_db: str = "default_db"
|
||
postgres_user: str = "gen_user"
|
||
postgres_password: str = "2~~9_^kVsU?2\\S"
|
||
|
||
# ============================================
|
||
# MYSQL (для проверки полисов ERV)
|
||
# ============================================
|
||
mysql_host: str = "localhost"
|
||
mysql_port: int = 3306
|
||
mysql_db: str = "u2768571_crm_db"
|
||
mysql_user: str = "root"
|
||
mysql_password: str = ""
|
||
|
||
# ============================================
|
||
# MYSQL CRM (vtiger CRM)
|
||
# ============================================
|
||
mysql_crm_host: str = "localhost" # В режиме network_mode: host используем localhost # Доступ к хосту из Docker контейнера
|
||
mysql_crm_port: int = 3306
|
||
mysql_crm_db: str = "ci20465_72new"
|
||
mysql_crm_user: str = "ci20465_72new"
|
||
mysql_crm_password: str = "EcY979Rn"
|
||
|
||
@property
|
||
def database_url(self) -> str:
|
||
"""Формирует URL для подключения к PostgreSQL"""
|
||
return f"postgresql+asyncpg://{self.postgres_user}:{self.postgres_password}@{self.postgres_host}:{self.postgres_port}/{self.postgres_db}"
|
||
|
||
# ============================================
|
||
# REDIS
|
||
# ============================================
|
||
redis_host: str = "localhost"
|
||
redis_port: int = 6379
|
||
redis_password: str = "CRM_Redis_Pass_2025_Secure!"
|
||
redis_db: int = 0
|
||
redis_prefix: str = "ticket_form:"
|
||
|
||
@property
|
||
def redis_url(self) -> str:
|
||
"""Формирует URL для подключения к Redis"""
|
||
if self.redis_password:
|
||
return f"redis://:{self.redis_password}@{self.redis_host}:{self.redis_port}/{self.redis_db}"
|
||
return f"redis://{self.redis_host}:{self.redis_port}/{self.redis_db}"
|
||
|
||
# ============================================
|
||
# RABBITMQ
|
||
# ============================================
|
||
rabbitmq_host: str = "185.197.75.249"
|
||
rabbitmq_port: int = 5672
|
||
rabbitmq_user: str = "admin"
|
||
rabbitmq_password: str = "tyejvtej"
|
||
rabbitmq_vhost: str = "/"
|
||
|
||
@property
|
||
def rabbitmq_url(self) -> str:
|
||
"""Формирует URL для подключения к RabbitMQ"""
|
||
return f"amqp://{self.rabbitmq_user}:{self.rabbitmq_password}@{self.rabbitmq_host}:{self.rabbitmq_port}{self.rabbitmq_vhost}"
|
||
|
||
# ============================================
|
||
# S3 STORAGE (Timeweb Cloud Storage)
|
||
# ============================================
|
||
s3_endpoint: str = "https://s3.timeweb.com"
|
||
s3_bucket: str = "erv-platform-files"
|
||
s3_access_key: str = "your_access_key_here"
|
||
s3_secret_key: str = "your_secret_key_here"
|
||
s3_region: str = "ru-1"
|
||
|
||
# ============================================
|
||
# OCR SERVICE
|
||
# ============================================
|
||
ocr_api_url: str = "http://147.45.146.17:8001"
|
||
ocr_api_key: str = ""
|
||
|
||
# ============================================
|
||
# AI SERVICE (OpenRouter)
|
||
# ============================================
|
||
openrouter_api_key: str = "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"
|
||
openrouter_base_url: str = "https://openrouter.ai/api/v1"
|
||
openrouter_model: str = "google/gemini-2.0-flash-001"
|
||
|
||
# ============================================
|
||
# FLIGHT APIs
|
||
# ============================================
|
||
# FlightAware
|
||
flightaware_api_key: str = "Puz0cdxAHzAEqMRZwtdeqBUSm9naJfwK"
|
||
flightaware_base_url: str = "https://aeroapi.flightaware.com/aeroapi"
|
||
|
||
# AviationStack (резервный)
|
||
aviationstack_api_key: str = ""
|
||
aviationstack_base_url: str = "http://api.aviationstack.com/v1"
|
||
|
||
# ============================================
|
||
# NSPK BANKS API
|
||
# ============================================
|
||
nspk_banks_api_url: str = "https://qr.nspk.ru/proxyapp/c2bmembers.json"
|
||
|
||
# ============================================
|
||
# SMS SERVICE (SigmaSMS)
|
||
# ============================================
|
||
sms_api_url: str = "https://online.sigmasms.ru/api/"
|
||
sms_login: str = ""
|
||
sms_password: str = ""
|
||
sms_token: str = ""
|
||
sms_sender: str = "lexpriority"
|
||
sms_enabled: bool = True
|
||
|
||
# ============================================
|
||
# VTIGER CRM (PHP Bridge)
|
||
# ============================================
|
||
crm_webservice_url: str = "http://crm.clientright.ru/webservice.php"
|
||
crm_webform_url: str = "https://crm.clientright.ru/modules/Webforms/capture.php"
|
||
crm_token: str = ""
|
||
|
||
# ============================================
|
||
# RATE LIMITING
|
||
# ============================================
|
||
rate_limit_per_minute: int = 60
|
||
rate_limit_per_hour: int = 1000
|
||
|
||
# ============================================
|
||
# FILE UPLOAD
|
||
# ============================================
|
||
max_upload_size_mb: int = 50
|
||
allowed_file_extensions: str = "pdf,jpg,jpeg,png,heic,heif,webp"
|
||
|
||
@property
|
||
def allowed_extensions_list(self) -> List[str]:
|
||
"""Список разрешенных расширений файлов"""
|
||
return [ext.strip() for ext in self.allowed_file_extensions.split(",")]
|
||
|
||
# ============================================
|
||
# CORS
|
||
# ============================================
|
||
cors_origins: str = "http://localhost:5175,http://127.0.0.1:5175,http://147.45.146.17:5175"
|
||
|
||
@property
|
||
def cors_origins_list(self) -> List[str]:
|
||
"""Список CORS origins"""
|
||
if isinstance(self.cors_origins, str):
|
||
return [origin.strip() for origin in self.cors_origins.split(",")]
|
||
return self.cors_origins
|
||
|
||
# ============================================
|
||
# N8N API & WEBHOOKS
|
||
# ============================================
|
||
n8n_url: str = "https://n8n.clientright.pro"
|
||
n8n_api_key: str = "" # Нужно задать в .env
|
||
n8n_policy_check_webhook: str = ""
|
||
n8n_file_upload_webhook: str = ""
|
||
n8n_create_contact_webhook: str = ""
|
||
n8n_create_claim_webhook: str = ""
|
||
|
||
# ============================================
|
||
# LOGGING
|
||
# ============================================
|
||
log_level: str = "INFO"
|
||
log_file: str = "/app/logs/ticket_form_backend.log"
|
||
|
||
class Config:
|
||
env_file = str(ENV_PATH)
|
||
case_sensitive = False
|
||
extra = "ignore" # Игнорируем лишние поля из .env
|
||
|
||
|
||
@lru_cache()
|
||
def get_settings() -> Settings:
|
||
return Settings()
|
||
|
||
|
||
settings = get_settings()
|
||
|
||
|