SOFRS-EA System Overview
Purpose
SOFRS-EA is a multi-client face-recognition system used to register employees and visitors, collect enrollment images, and perform recognition and identity confirmation during check-in.
The system has three major software components:
- Desktop kiosk application (Electron + Vite + TypeScript)
- Mobile application (Expo + React Native + TypeScript)
- Backend API and recognition service (FastAPI + Beanie + MongoDB + DeepFace)
High-Level Architecture
flowchart LR
D[Desktop App] -->|HTTPS API + X-API-Key| B[Backend API]
M[Mobile App] -->|HTTPS API + X-API-Key| B
B -->|Document CRUD| DB[(MongoDB)]
B -->|Image Read/Write| FS[(temp_images)]
B -->|Embedding, analysis, verify| DF[DeepFace models]
Component Responsibilities
Desktop Application
Primary responsibilities:
- Kiosk-first user interface for registration and check-in
- Five-pose face capture flow (front, left, right, up, down)
- Real-time face-quality checks before capture
- Identity verification screen and confidence display
- Fallback relay server support for mobile camera streaming in specific kiosk scenarios
Main implementation area:
- Desktop/employee-access/src
Mobile Application
Primary responsibilities:
- User onboarding and identity details collection
- Five-pose camera capture workflow
- Upload of captured pose images to backend
- Context-managed state for user details, captures, and created record IDs
- Deep-link aware navigation flow
Main implementation area:
- Mobile/employee-access/app
- Mobile/employee-access/lib
- Mobile/employee-access/contexts
Backend API
Primary responsibilities:
- Authenticated API endpoints for employee/visitor CRUD operations
- Image upload and image-search endpoints
- Face preprocessing and quality gating
- DeepFace-powered recognition search and verification logic
- Structured response generation for frontend use
Main implementation area:
- Backend/SOFRS-EA-Backend/backend
Core Data Domains
- Employee
- Persistent profile record with ID prefix EA
- Visitor
- Persistent profile record with ID prefix VA
- Enrolled images
- Preprocessed JPEG images stored in temp_images with owner-prefixed filenames
- Recognition result
- Response object containing match decision, optional profile data, analysis payload, and verification metadata
End-to-End Functional Scope
Enrollment scope
- Create employee or visitor profile through POST API
- Capture multiple face poses
- Upload pose images linked to created owner ID
- Store processed images in backend file storage
Recognition scope
- Capture image and submit to image-search endpoint
- Detect and validate face in input image
- Search nearest candidates in enrolled image set
- Run verification against matched owner references
- Return one of several decision branches:
- No match
- Ambiguous match
- Match found but not confirmed
- Match confirmed
Security and Access Model
- Protected endpoints require X-API-Key header
- Employee, visitor, and image routes are API-key guarded
- CORS policy allows configured origins and localhost development
- Per-client temporary blocking is applied for repeated invalid image-search attempts
Operational Behavior
- Backend startup can run optional DeepFace warmup routines
- Logging writes to console and rotating log file
- Error handling wraps most async operations in shared helper functions
Report Traceability Notes
Use the following references for implementation-backed claims:
- Backend API runtime and routing: Backend/SOFRS-EA-Backend/backend/main.py
- Image recognition orchestration: Backend/SOFRS-EA-Backend/backend/routers/Image.py
- Desktop flow control: Desktop/employee-access/src/renderer.ts
- Mobile navigation and state provider setup: Mobile/employee-access/app/_layout.tsx