FaceGuardV2DocsWebsite

FaceGuard — Interface Documentation

Overview

FaceGuard exposes two interfaces. As of MVP v1, the Web Admin UI replaces the CLI design documented in earlier sprints.

Interface Type User Status in MVP v1
Live Display Web (MJPEG + SSE) Employees, guests Implemented
Admin Web UI Web (HTML + HTMX) System administrators Implemented (MVP v1)
Admin CLI CLI Administrators Replaced by Web Admin

The CLI design (register, remove, list, add-guest, logs, status, threshold) has been superseded by the web admin — every CLI action now has an equivalent page (see mapping table below).


1. Live Display (Web)

The live camera feed and verdict overlay shown to anyone standing in front of the door. The same MJPEG stream is also embedded in the admin dashboard so the admin can see what the camera sees from their laptop.

URL (admin view): / (dashboard, requires login)

States

The verdict overlay reflects the current state of the recognition loop.

1.1 Idle (no face detected)

┌─────────────────────┐
│  [Camera feed]      │
│                     │
│                     │
└─────────────────────┘
   Waiting for face...
        (grey)

1.2 Scanning (face detected, comparison in flight)

1.3 Granted (known user / guest)

┌─────────────────────┐
│  [Camera feed]      │
│   ┌─────────┐       │
│   │  face   │       │
│   └─────────┘       │
│  Access granted:    │
│  Ivanov Petr        │
│  user · 0.821       │
└─────────────────────┘
        (green)

1.4 Denied (face seen but no match above threshold)

┌─────────────────────┐
│  [Camera feed]      │
│   ┌─────────┐       │
│   │  face   │       │
│   └─────────┘       │
│  Access denied:     │
│  Unknown            │
│  score 0.312        │
└─────────────────────┘
        (red)

1.5 Error (ML service unreachable / loop crashed)


2. Admin Web UI

Accessible from any device on the same LAN as the Raspberry Pi. URL: http://<pi-ip>:8000/

2.1 Authentication

2.2 Dashboard — /

2.3 Users & Guests — /users

Lists permanent users and active (non-expired) guests with delete/revoke buttons. Each row shows ID, name, and either created_at (users) or expires_at (guests).

Expired guests are auto-purged inside the recognition loop — no manual cleanup needed, but a Purge expired button is available for forced cleanup.

2.4 Register a new person — /register

The admin-side counterpart of US-02.

Steps:

  1. The page shows a live camera preview (left panel).
  2. Admin fills the form:
    • Full name (Surname Firstname) — unique among permanent users.
    • Access type:
      • Permanent — never expires.
      • Temporary — additional field Valid for (days) appears (HTMX swap).
  3. Admin clicks Capture & register.
  4. The backend captures REGISTRATION_FRAME_COUNT (default 5) frames from the ML service at REGISTRATION_FRAME_INTERVAL_MS intervals. For each frame the biggest detected face’s embedding is taken.
  5. The 5 embeddings are averaged and L2-normalized.
  6. The result is saved as a users row (permanent) or a guests row (temporary, with expires_at = now + N days).
  7. A success/error message is swapped in via HTMX — no page reload.

Failure modes shown to the admin:

2.5 Logs — /logs

Audit log (US-10). Each row records:

Field Source
timestamp when the attempt happened
name matched name, or Unknown
access_type user / guest / unknown
score cosine similarity, 0..1
success true if access was granted

Filters:

2.6 Settings — runtime threshold (US-08)

The recognition threshold is read from env at startup (THRESHOLD). A runtime-adjustable threshold UI is planned for v2; for MVP v1 the threshold is configured via .env / Docker env.


3. CLI → Web admin mapping

The CLI commands documented in earlier sprints have the following web equivalents in MVP v1:

Old CLI command Web admin equivalent
register <name> /register form (permanent access)
add-guest <name> --hours N /register form (temporary access, days)
remove <name> Delete button on /users
list /users page
logs [--today] [--user X] /logs page (same filters)
status Dashboard right panel (/)
threshold <value> .env: THRESHOLD (runtime UI planned v2)

4. Interface comparison

Aspect Live Display Admin Web UI
User Employee, guest System admin
Input None (passive) Forms, buttons (HTMX)
Output MJPEG + verdict overlay HTML pages, SSE updates
Location Pi + camera Any LAN device, browser
Authentication Biometric (face) Username + password (session)
Latency Real-time (≤ 500ms tick) On-demand
MVP v1

5. Hardware feedback (servo + LED)

Servo (US-06 / US-07)

LED indicators (planned for v2)

Customer-requested LED feedback (green=granted, red=denied, yellow=scanning) is documented but not yet wired in MVP v1. The verdict overlay colour scheme mirrors the planned LED colours so the visual feedback contract is already stable.


6. API summary

All admin endpoints require a valid session cookie. See README.md for the full HTTP method / path table.