How nelay04/face-recognition works
Face Recognition is a browser-based enrolment and live identification product backed by a FastAPI service. Users enrol a named face from a camera capture or uploaded photo, then send webcam frames for matching; they can also remove identities and inspect service health. The backend decodes images, detects and encodes faces, stores enrolments in SQLite, and compares embeddings to produce recognition results. Relationships for sampled code are grounded in source references; some browser-to-API and documented capabilities rely on the README because frontend/API excerpts are incomplete.
Main entry points: main.py App Factory · app.js UI Controller · router.py V1 Router · faces.py Enrolment API
Components 22
Browser UI
- UI Controller
frontend/js/app.js - API Client
frontend/js/api.js - Camera Capture
frontend/js/camera.js - Result Overlay
frontend/js/overlay.js
HTTP API
- App Factory
backend/app/main.py - V1 Router
backend/app/api/v1/router.py - Enrolment API
backend/app/api/v1/endpoints/faces.py - Recognition API
backend/app/api/v1/endpoints/recognize.py - Health API
backend/app/api/v1/endpoints/health.py - Upload Decoder
backend/app/api/uploads.py - Service Dependencies
backend/app/api/deps.py - Response Models
backend/app/schemas/common.py
Recognition Services
- Face Encoder
backend/app/services/encoder.py - Face Matcher
backend/app/services/recognizer.py - Identity Gallery
backend/app/services/gallery.py - SQLite Gallery
- Image Validation
backend/app/utils/image.py
Runtime Platform
- Settings
backend/app/core/config.py - Device Resolver
backend/app/core/device.py - Error Handling
backend/app/core/exceptions.py
Other components
- User
- Browser
Connections 27
- User → UI Controller: uses
README.md - Browser → UI Controller: loads UI
README.md - UI Controller → API Client: calls
frontend/js/app.js - UI Controller → Camera Capture: captures frames
frontend/js/app.js - UI Controller → Result Overlay: draws results
frontend/js/app.js - API Client → Recognition API: posts frames
README.md - API Client → Enrolment API: enrols, removes
- App Factory → V1 Router: mounts routes
backend/app/main.py - V1 Router → Enrolment API: registers
backend/app/api/v1/router.py - V1 Router → Recognition API: registers
backend/app/api/v1/router.py - V1 Router → Health API: registers
backend/app/api/v1/router.py - App Factory → Face Encoder: initializes
backend/app/main.py - App Factory → Identity Gallery: initializes
backend/app/main.py - App Factory → Face Matcher: initializes
backend/app/main.py - App Factory → Device Resolver: resolves device
backend/app/main.py - App Factory → Settings: loads settings
backend/app/main.py - App Factory → Error Handling: registers handlers
backend/app/main.py - Enrolment API → Service Dependencies: requests services
backend/app/api/v1/endpoints/faces.py - Enrolment API → Upload Decoder: decodes upload
backend/app/api/v1/endpoints/faces.py - Recognition API → Service Dependencies: requests services
backend/app/api/v1/endpoints/recognize.py - Recognition API → Upload Decoder: decodes upload
backend/app/api/v1/endpoints/recognize.py - Health API → Service Dependencies: checks services
backend/app/api/v1/endpoints/health.py - Upload Decoder → Image Validation: decodes image
backend/app/api/uploads.py - Face Encoder → Image Validation: uses image type
backend/app/services/encoder.py - Face Matcher → Identity Gallery: reads embeddings
backend/app/services/recognizer.py - Identity Gallery → SQLite Gallery: reads and writes
backend/app/services/gallery.py - Error Handling → Response Models: renders errors
backend/app/core/exceptions.py