You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
5.6 KiB
5.6 KiB
Face Recognition Service - Architecture Diagram
graph TB
%% External Layer
EndUser[👤 User] --> GradioUI[🖥️ Gradio Web Interface]
%% Presentation Layer
subgraph "Presentation Layer"
GradioUI --> |HTTP/Web Requests| GradioApp[gradio_app.py]
end
%% Application Layer
subgraph "Application Layer"
GradioApp --> RegisterUC[📝 RegisterFaceUseCase]
GradioApp --> VerifyUC[🔍 VerifyFaceUseCase]
GradioApp --> IdentifyUC[🔎 IdentifyFaceUseCase]
%% Асинхронная публикация задач
RegisterUC --> TaskPublisher[📨 TaskPublisher]
VerifyUC --> TaskPublisher
IdentifyUC --> TaskPublisher
%% Хранилище статусов задач (поллинг/вебсокет)
GradioApp --> TaskStatusRepo[📊 TaskStatusRepository]
end
%% Scalability / Async Layer
subgraph "Scalability Layer (Async, flipped-buffer)"
TaskPublisher --> RabbitMQ[(🐇 RabbitMQ)]
FaceWorkerPool[👷♂️ FaceWorker Pool - N instances] --> RabbitMQ
FaceWorkerPool --> TaskStatusRepo
end
%% Domain Layer
subgraph "Domain Layer"
FaceService[⚙️ FaceRecognitionService] --> Face[👤 Face Entity]
FaceService --> User[👨💼 User Entity]
FaceService --> VResult[✅ VerificationResult]
FaceService --> IResult[🎯 IdentificationResult]
FaceRepo[📊 FaceRepository Interface]
VectorStore[🗂️ VectorStore Interface]
UserRepoIface[👨💼 UserRepository Interface]
ObjectStorageIface[📁 ObjectStorage Interface]
end
%% Infrastructure Layer
subgraph "Infrastructure Layer"
%% ML Components
subgraph "ML Components"
RetinaFace[📷 RetinaFaceDetector]
SFaceRec[🧠 SFaceRecognizer]
end
%% Storage Components
subgraph "Storage Components"
MongoDBRepo[🗄️ MongoDBFaceRepository]
MongoUserRepo[👨💼 MongoDBUserRepository]
ChromaDBStore[🔗 ChromaDBVectorStore]
S3Storage[🪣 S3ObjectStorage]
end
%% Configuration & Logging
subgraph "Cross-cutting Concerns"
Config[⚙️ Settings]
Logger[📋 Logging System]
end
end
%% External Systems
subgraph "External Systems"
MongoDBServer[(🗄️ MongoDB Database)]
ChromaDBServer[(🔗 ChromaDB Vector DB)]
S3Bucket[(🪣 S3 Bucket)]
ONNXModel[🧠 SFace ONNX Model]
RedisOrMongo[(📊 Redis/Mongo for Task Status)]
end
%% Service Dependencies (исполняются внутри воркеров)
FaceWorkerPool --> FaceService
FaceService --> RetinaFace
FaceService --> SFaceRec
FaceService --> FaceRepo
FaceService --> VectorStore
FaceService --> ObjectStorageIface
%% Repository Implementations
FaceRepo -.->|implements| MongoDBRepo
VectorStore -.->|implements| ChromaDBStore
UserRepoIface -.->|implements| MongoUserRepo
ObjectStorageIface -.->|implements| S3Storage
%% External Connections
MongoDBRepo --> MongoDBServer
MongoUserRepo --> MongoDBServer
ChromaDBStore --> ChromaDBServer
S3Storage --> S3Bucket
SFaceRec --> ONNXModel
TaskStatusRepo --> RedisOrMongo
%% Use Case Dependencies (чтение пользователей/статусов)
RegisterUC --> MongoUserRepo
VerifyUC --> MongoUserRepo
IdentifyUC --> MongoUserRepo
%% Logging Dependencies
RetinaFace -.-> Logger
SFaceRec -.-> Logger
FaceService -.-> Logger
FaceWorkerPool -.-> Logger
TaskPublisher -.-> Logger
%% Configuration Dependencies
FaceService -.-> Config
MongoDBRepo -.-> Config
MongoUserRepo -.-> Config
ChromaDBStore -.-> Config
S3Storage -.-> Config
RabbitMQ -.-> Config
TaskStatusRepo -.-> Config
%% Styling
classDef presentation fill:#e1f5fe
classDef application fill:#f3e5f5
classDef domain fill:#e8f5e8
classDef infrastructure fill:#fff3e0
classDef external fill:#ffebee
classDef scalability fill:#ede7f6
class GradioUI,GradioApp presentation
class RegisterUC,VerifyUC,IdentifyUC,TaskPublisher,TaskStatusRepo application
class Face,User,VResult,IResult,FaceRepo,VectorStore,UserRepoIface,ObjectStorageIface,FaceService domain
class RetinaFace,SFaceRec,MongoDBRepo,ChromaDBStore,S3Storage,Config,Logger,MongoUserRepo infrastructure
class MongoDBServer,ChromaDBServer,S3Bucket,ONNXModel,RedisOrMongo external
class RabbitMQ,FaceWorkerPool scalability
Architecture Overview
Layers Description
- Presentation Layer: Gradio-based web interface for user interaction
- Application Layer: Use cases and business logic orchestration
- Domain Layer: Core business entities and repository interfaces
- Infrastructure Layer: Technical implementations and external service adapters
Key Components
- Face Detection: RetinaFace for accurate face detection and landmark extraction
- Face Recognition: SFace ONNX model for embedding extraction and similarity calculation
- Storage: MongoDB for metadata, ChromaDB for vector similarity search, filesystem for images
- Web Interface: Gradio provides registration, verification, and identification capabilities
Data Flow
- User uploads images through Gradio interface
- Use cases orchestrate the business logic
- FaceRecognitionService processes images using ML models
- Data is persisted in MongoDB, ChromaDB, and filesystem
- Results are returned to the user through the web interface