backend initialized

This commit is contained in:
bokho 2025-12-14 16:53:08 +03:00
commit 39bcd1c16e
9 changed files with 120 additions and 0 deletions

13
backend/requirements.txt Normal file
View File

@ -0,0 +1,13 @@
fastapi==0.104.1
uvicorn[standard]==0.24.0
sqlalchemy[asyncio]==2.0.23
asyncpg==0.29.0
alembic==1.12.1
pydantic==2.5.0
pydantic-settings==2.1.0
python-multipart==0.0.6
httpx==0.25.2
PyMuPDF==1.23.8
Pillow==10.2.0
dishka==0.7.0

4
backend/src/__init__.py Normal file
View File

@ -0,0 +1,4 @@
"""
ИИ-юрист система
"""

View File

@ -0,0 +1,4 @@
"""
Application layer
"""

View File

@ -0,0 +1,4 @@
"""
Domain layer
"""

View File

@ -0,0 +1,4 @@
"""
Infrastructure layer
"""

View File

@ -0,0 +1,4 @@
"""
Presentation layer
"""

View File

@ -0,0 +1,4 @@
"""
Shared utilities
"""

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()

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