backend initialized

This commit is contained in:
2025-12-14 16:53:08 +03:00
commit 39bcd1c16e
9 changed files with 120 additions and 0 deletions
+4
View File
@@ -0,0 +1,4 @@
"""
ИИ-юрист система
"""
+4
View File
@@ -0,0 +1,4 @@
"""
Application layer
"""
+4
View File
@@ -0,0 +1,4 @@
"""
Domain layer
"""
+4
View File
@@ -0,0 +1,4 @@
"""
Infrastructure layer
"""
+4
View File
@@ -0,0 +1,4 @@
"""
Presentation layer
"""
+4
View File
@@ -0,0 +1,4 @@
"""
Shared utilities
"""
+48
View File
@@ -0,0 +1,48 @@
"""
Конфигурация приложения
"""
from pydantic_settings import BaseSettings
from typing import Optional
class Settings(BaseSettings):
"""Настройки (загружаются из .env автоматически)"""
POSTGRES_HOST: str = "localhost"
POSTGRES_PORT: int = 5432
POSTGRES_USER: str = "postgres"
POSTGRES_PASSWORD: str = "postgres"
POSTGRES_DB: str = "lawyer_ai"
QDRANT_HOST: str = "localhost"
QDRANT_PORT: int = 6333
REDIS_HOST: str = "localhost"
REDIS_PORT: int = 6379
TELEGRAM_BOT_TOKEN: Optional[str] = None
YANDEX_OCR_API_KEY: Optional[str] = None
DEEPSEEK_API_KEY: Optional[str] = None
YANDEX_OCR_API_URL: str = "https://vision.api.cloud.yandex.net/vision/v1/batchAnalyze"
DEEPSEEK_API_URL: str = "https://api.deepseek.com/v1/chat/completions"
APP_NAME: str = "ИИ-юрист"
DEBUG: bool = False
SECRET_KEY: str = "your-secret-key-change-in-production"
CORS_ORIGINS: list[str] = ["*"]
@property
def database_url(self) -> str:
"""Вычисляемый URL подключения"""
return f"postgresql://{self.POSTGRES_USER}:{self.POSTGRES_PASSWORD}@{self.POSTGRES_HOST}:{self.POSTGRES_PORT}/{self.POSTGRES_DB}"
class Config:
env_file = ".env"
case_sensitive = True
settings = Settings()
+35
View File
@@ -0,0 +1,35 @@
"""
Кастомные исключения приложения
"""
class LawyerAIException(Exception):
"""Базовое исключение приложения"""
pass
class NotFoundError(LawyerAIException):
"""Ресурс не найден"""
pass
class UnauthorizedError(LawyerAIException):
"""Пользователь не авторизован"""
pass
class ForbiddenError(LawyerAIException):
"""Доступ запрещен"""
pass
class ValidationError(LawyerAIException):
"""Ошибка валидации данных"""
pass
class DatabaseError(LawyerAIException):
"""Ошибка базы данных"""
pass