How taraneshwer/vizage works
Purpose and entry points
Vizage is an offline desktop application for masked-face recognition. Its primary runtime is a Python/FastAPI backend launched as uvicorn app.main:app, with a React UI packaged through Electron. The backend application boundary is backend/app/main.py; desktop process startup and backend lifecycle management are in frontend/electron/main/main.ts and frontend/electron/services/backendManager.ts.
Desktop client and API boundary
The React renderer provides recognition, enrollment, camera, history, settings, diagnostics, and system views. It calls backend HTTP APIs and consumes real-time events over WebSocket:
• frontend/src/App.tsx
• frontend/src/utils/api.ts
• frontend/src/hooks/useWebSocket.ts
Electron separates privileged process/IPC functionality from the renderer via its main and preload processes:
• frontend/electron/main/main.ts
• frontend/electron/preload/preload.ts
• frontend/electron/ipc/handlers.ts
Backend API and real-time event delivery
FastAPI exposes versioned operational endpoints for camera control, recognition, enrollment, history, runtime, settings, and system state. API routers are the external control plane, while WebSocket infrastructure broadcasts runtime events and logs to connected clients:
• backend/app/api/v1/routers/recognition.py
• backend/app/api/v1/routers/enrollment.py
• backend/app/api/v1/websockets/event_bridge.py
• backend/app/api/v1/websockets/manager.py
Runtime orchestration and camera pipeline
Runtime services own application startup/shutdown, camera sessions, pipeline execution, recovery, and inspection. Input/source abstractions permit webcams, RTSP/IP cameras, ESP32 streams, video files, and images without coupling recognition to transport:
• backend/app/services/runtime/startup.py
• backend/app/services/runtime/camera_runtime.py
• backend/app/services/runtime/pipeline.py
• backend/app/sources/factory.py
• backend/app/sources/providers/rtsp.py
Control flow is API request → runtime/orchestrator → source session/frame buffering → AI inference and decisioning → history/events → REST/WebSocket response.
AI recognition and decision layer
Recognition combines face detection, mask analysis, tracking, embeddings, vector search, and temporal decision logic. Model loading and GPU allocation are isolated from inference; the decision engine manages candidate ranking, confidence fusion, unknown detection, thresholds, and session state:
• backend/app/services/ai/inference_engine.py
• backend/app/services/ai/model_manager.py
• backend/app/services/ai/faiss_service.py
• backend/app/services/ai/decision/decision_engine.py
• backend/app/services/ai/decision/state_machine.py
Bundled ONNX and PyTorch artifacts provide offline detector/embedding models, while FAISS persists the identity-search index:
• backend/models/best_yolo.onnx
• backend/models/best_adaface.onnx
• backend/faiss_index.bin
Enrollment, identity persistence, and history
Enrollment orchestrates identity creation/import and embedding-index updates. Database repositories isolate persistence access for cameras, identities, and recognition history, keeping API and AI services storage-agnostic:
• backend/app/services/orchestrators/enrollment_orchestrator.py
• backend/app/services/orchestrators/recognition_orchestrator.py
• backend/app/db/models.py
• backend/app/db/repository/identity_repo.py
• backend/app/db/repository/history_repo.py
ML development subsystem
maskshield-ai is a separate model-development workspace, not the desktop serving path. It prepares and augments datasets, trains/evaluates YOLO and AdaFace models, then exports artifacts that can be deployed under backend/models:
• maskshield-ai/dataset_builder/augmentations/pipeline.py
• maskshield-ai/scripts/train_yolo.py
• maskshield-ai/scripts/train_adaface.py
• maskshield-ai/scripts/export_models.py
Main entry points: recognition.py Operational APIs · api.ts API & WebSocket Client · main.py FastAPI App · enrollment_orchestrator.py Enrollment Orchestrator
Components 21
Desktop Client
- Electron Main · Starts the desktop app and manages backend lifecycle.
frontend/electron/main/main.ts - Backend Manager · Launches and supervises the FastAPI backend.
frontend/electron/services/backendManager.ts - Preload & IPC · Exposes controlled renderer access to Electron capabilities.
frontend/electron/preload/preload.ts - React Renderer · Recognition, enrollment, camera, history, settings, and diagnostics views.
frontend/src/App.tsx - API & WebSocket Client · Makes HTTP calls and subscribes to runtime events.
frontend/src/utils/api.ts
Backend Control Plane
- FastAPI App · Backend entry point served as app.main:app.
backend/app/main.py - Operational APIs · Versioned recognition and enrollment control endpoints.
backend/app/api/v1/routers/recognition.py - Event Bridge · Broadcasts runtime events and logs to clients.
backend/app/api/v1/websockets/event_bridge.py - WebSocket Manager · Tracks connected WebSocket clients.
backend/app/api/v1/websockets/manager.py - Enrollment Orchestrator · Creates or imports identities and updates embeddings.
backend/app/services/orchestrators/enrollment_orchestrator.py - Identity & History Persistence · Storage boundary for identities and recognition history.
backend/app/db/repository/identity_repo.py
Runtime Pipeline
- Runtime Startup · Owns backend startup and shutdown services.
backend/app/services/runtime/startup.py - Camera Runtime · Owns camera sessions, buffering, recovery, and inspection.
backend/app/services/runtime/camera_runtime.py - Recognition Pipeline · Runs frames through recognition processing.
backend/app/services/runtime/pipeline.py - Source Factory · Creates webcam, IP, stream, video, and image sources.
backend/app/sources/factory.py
Recognition AI
- Inference Engine · Runs detection, mask analysis, tracking, and embeddings.
backend/app/services/ai/inference_engine.py - Model Manager · Loads models and isolates GPU allocation.
backend/app/services/ai/model_manager.py - Decision Engine · Fuses confidence, ranks candidates, and detects unknowns.
backend/app/services/ai/decision/decision_engine.py - FAISS Identity Index · Persistent identity embedding search index.
backend/faiss_index.bin - Offline Model Artifacts · Detector and embedding models deployed for serving.
backend/models/best_yolo.onnx
Model Development
Separate workspace that produces deployable model artifacts.
- Training & Export · Trains YOLO and AdaFace models and exports serving artifacts.
maskshield-ai/scripts/export_models.py
Connections 24
- Electron Main → Backend Manager: manages
- Electron Main → Preload & IPC: loads
- Preload & IPC → React Renderer: privileged bridge
- React Renderer → API & WebSocket Client: uses
- Backend Manager → FastAPI App: launches
- API & WebSocket Client → Operational APIs: HTTP control
- API & WebSocket Client → WebSocket Manager: event subscription
- FastAPI App → Operational APIs: mounts
- FastAPI App → Runtime Startup: lifecycle
- Operational APIs → Camera Runtime: camera control
- Operational APIs → Enrollment Orchestrator: enrollment requests
- Camera Runtime → Source Factory: opens source
- Camera Runtime → Recognition Pipeline: frames
- Recognition Pipeline → Inference Engine: infer
- Model Manager → Inference Engine: provides models
- Offline Model Artifacts → Model Manager: loaded by
- Inference Engine → Decision Engine: detections and embeddings
- Decision Engine → FAISS Identity Index: identity search
- Decision Engine → Identity & History Persistence: recognition history
- Enrollment Orchestrator → Identity & History Persistence: identity records
- Enrollment Orchestrator → FAISS Identity Index: updates embeddings
- Recognition Pipeline → Event Bridge: runtime events
- Event Bridge → WebSocket Manager: broadcasts
- Training & Export → Offline Model Artifacts: exports