feat: initial microservices project structure
Services: - api: FastAPI gateway with JWT auth, async endpoints, WebSocket - worker-gpu: CUDA sentence-transformers, FAISS IVFFlat, Ollama LLM - worker-indexer: Winnowing+MinHash plagiarism detection, PDF/DOCX extraction - worker-notifier: SMTP email notifications - worker-gost: GOST 7.1-2003 and GOST R 7.0.5-2008 formatting Infrastructure: - docker-compose.yml (production) + docker-compose.dev.yml (hot reload) - Nginx reverse proxy + WebSocket support - PostgreSQL 16 with Alembic migrations - Elasticsearch 8 with Russian/English analyzers - MinIO, RabbitMQ, Redis, Ollama Frontend: - React 18 + Vite + TypeScript + TailwindCSS + Zustand + React Query v5 - 9 pages: Home, Search, Cabinet, Task, Check, Bibliography, Pricing, Login, Register Scripts: - Parser stubs: OpenAlex, КиберЛенинка, arXiv (Phase 0 - to be filled) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
0
services/api/app/schemas/__init__.py
Normal file
0
services/api/app/schemas/__init__.py
Normal file
38
services/api/app/schemas/auth.py
Normal file
38
services/api/app/schemas/auth.py
Normal file
@@ -0,0 +1,38 @@
|
||||
"""Схемы для аутентификации и авторизации."""
|
||||
|
||||
from pydantic import BaseModel, EmailStr, Field
|
||||
|
||||
|
||||
class RegisterRequest(BaseModel):
|
||||
"""Запрос на регистрацию нового пользователя."""
|
||||
|
||||
email: EmailStr
|
||||
password: str = Field(min_length=8, max_length=128)
|
||||
name: str = Field(min_length=1, max_length=255)
|
||||
|
||||
|
||||
class LoginRequest(BaseModel):
|
||||
"""Запрос на вход в систему."""
|
||||
|
||||
email: EmailStr
|
||||
password: str
|
||||
|
||||
|
||||
class UserInToken(BaseModel):
|
||||
"""Минимальная информация о пользователе в JWT токене."""
|
||||
|
||||
id: int
|
||||
email: str
|
||||
name: str
|
||||
plan: str
|
||||
is_verified: bool
|
||||
|
||||
model_config = {"from_attributes": True}
|
||||
|
||||
|
||||
class TokenResponse(BaseModel):
|
||||
"""Ответ с JWT токеном и данными пользователя."""
|
||||
|
||||
access_token: str
|
||||
token_type: str = "bearer"
|
||||
user: UserInToken
|
||||
46
services/api/app/schemas/reports.py
Normal file
46
services/api/app/schemas/reports.py
Normal file
@@ -0,0 +1,46 @@
|
||||
"""Схемы для отчётов о плагиате и результатов поиска."""
|
||||
|
||||
from datetime import datetime
|
||||
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
|
||||
class PlagiarismMatch(BaseModel):
|
||||
"""Совпадение фрагмента с источником."""
|
||||
|
||||
fragment: str
|
||||
position_start: int
|
||||
position_end: int
|
||||
similarity: float = Field(ge=0.0, le=100.0, description="Схожесть в процентах")
|
||||
method: str = Field(description="Метод обнаружения: exact, fuzzy, semantic+llm")
|
||||
confidence: float | None = Field(default=None, ge=0.0, le=1.0)
|
||||
reason: str | None = None
|
||||
source_title: str
|
||||
source_url: str | None = None
|
||||
source_db: str = Field(description="База данных: openalex, cyberleninka, arxiv, и т.д.")
|
||||
|
||||
|
||||
class PlagiarismReport(BaseModel):
|
||||
"""Полный отчёт о плагиате."""
|
||||
|
||||
task_id: str
|
||||
overall_similarity: float = Field(ge=0.0, le=100.0)
|
||||
matches: list[PlagiarismMatch] = Field(default_factory=list)
|
||||
total_fragments: int
|
||||
flagged_fragments: int
|
||||
checked_at: datetime
|
||||
|
||||
|
||||
class SearchResult(BaseModel):
|
||||
"""Источник в результатах поиска."""
|
||||
|
||||
id: int
|
||||
title: str
|
||||
authors: list[dict] = Field(default_factory=list)
|
||||
year: int | None = None
|
||||
journal: str | None = None
|
||||
abstract: str | None = None
|
||||
url: str | None = None
|
||||
relevance_score: float = Field(ge=0.0, le=1.0)
|
||||
gost_citation: str = Field(description="Отформатированная ГОСТ-цитата")
|
||||
source_db: str
|
||||
39
services/api/app/schemas/tasks.py
Normal file
39
services/api/app/schemas/tasks.py
Normal file
@@ -0,0 +1,39 @@
|
||||
"""Схемы для задач и поиска."""
|
||||
|
||||
from datetime import datetime
|
||||
from typing import Any
|
||||
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
|
||||
class TaskCreate(BaseModel):
|
||||
"""Создание задачи."""
|
||||
|
||||
type: str
|
||||
input_data: dict[str, Any] = Field(default_factory=dict)
|
||||
|
||||
|
||||
class TaskResponse(BaseModel):
|
||||
"""Ответ с информацией о задаче."""
|
||||
|
||||
id: str
|
||||
type: str
|
||||
status: str
|
||||
queue_position: int | None = None
|
||||
eta_seconds: int | None = None
|
||||
input_data: dict[str, Any] = Field(default_factory=dict)
|
||||
result: dict[str, Any] | None = None
|
||||
error: str | None = None
|
||||
created_at: datetime
|
||||
|
||||
model_config = {"from_attributes": True}
|
||||
|
||||
|
||||
class SearchRequest(BaseModel):
|
||||
"""Запрос на семантический поиск источников."""
|
||||
|
||||
query: str = Field(min_length=3, max_length=1000)
|
||||
lang: str | None = Field(default=None, description="Язык: ru, en или None для всех")
|
||||
year_from: int | None = Field(default=None, ge=1900, le=2100)
|
||||
year_to: int | None = Field(default=None, ge=1900, le=2100)
|
||||
category: str | None = Field(default=None, description="Тематическая категория")
|
||||
Reference in New Issue
Block a user