Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

27 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

FaceAccess β€” AI-Enhanced Facial Recognition Access Control System v4.2

Project Overview

A complete facial recognition-based access control system with a multi-model biometric pipeline (ArcFace + InsightFace + FaceNet), AI Trust Engine v4, predictive behavioral analysis, real-time anomaly detection, a dedicated internal Developer Testing Lab, and a full legal compliance framework covering privacy, biometrics, SMS, and AI transparency.

Production: https://faceaccess.pages.dev
Home Dashboard: https://faceaccess.pages.dev/home/dashboard
Mobile App: https://faceaccess.pages.dev/home/mobile
πŸ”¬ Dev Lab: https://faceaccess.pages.dev/dev-lab

πŸ“‹ Legal Pages

Page URL Status
Privacy Policy /legal/privacy βœ… Live
Terms of Use /legal/terms βœ… Live
SMS Consent Agreement /legal/sms-consent βœ… Live
Biometric Data Retention Policy /legal/biometric-retention βœ… Live
AI & Facial Recognition Disclosure /legal/ai-disclosure βœ… Live
Enterprise Security Compliance /legal/enterprise-security βœ… Live

βœ… Completed Features

βš–οΈ Legal Compliance Framework (v1.0 β€” NEW)

Full legal policy ecosystem covering BIPA, CCPA, TCPA, and GDPR requirements.

6 Legal Pages (all live at /legal/*):

  • Privacy Policy β€” Biometric data handling, SMS communications, data rights, contact information
  • Terms of Use β€” Service agreement, biometric consent, SMS consent, acceptable use, limitation of liability
  • SMS Consent Agreement β€” Twilio-compliant TCPA consent language, STOP/HELP keywords, opt-out instructions, message types
  • Biometric Data Retention Policy β€” BIPA-compliant written retention schedule, 3-year max, 30-day deletion SLA, IL/TX/WA/CA compliance
  • AI & Facial Recognition Disclosure β€” Algorithm transparency, 128-dim embeddings, anti-spoof threshold (0.72), accuracy limitations, demographic fairness
  • Enterprise Security Compliance β€” Cloudflare edge security, AES-256 encryption, RBAC, rate limiting, SOC2/ISO27001 vendor compliance

Consent Checkboxes at Every Signup Entry Point: All 4 registration flows now include dual consent checkboxes:

  1. βœ… Required: Terms of Use + Privacy Policy + Biometric data consent
  2. ☐ Optional: SMS text message consent (TCPA-compliant)

Registration flows updated:

  • Business Registration (bizDoRegister) β€” validates biz-reg-consent-terms required
  • Home Registration (homeDoRegister) β€” validates home-reg-consent-terms required
  • Mobile Registration (mobDoRegister) β€” validates mob-reg-consent-terms required
  • Home Onboarding Step 0 (saveAccount) β€” validates ob-consent-terms required
  • sms_consent flag passed to all backend registration APIs

πŸ”¬ Developer Testing Lab (v1.0 β€” NEW at /dev-lab)

Internal sandbox environment for validating biometric pipeline accuracy, enrollment quality, and trust engine logic β€” fully isolated from production data.

Six integrated panels:

  1. Face Enrollment Panel

    • USB webcam / laptop camera / optional RTSP stream connection
    • Start/stop/switch camera controls with real-time feed
    • Live quality metrics: brightness, sharpness, anti-spoof score
    • 7-angle progress dots (center, left, right, up, down, left_up, right_up)
    • One-click capture per angle or Auto-Enroll (captures all 7 angles automatically)
    • Embedding generation via frame pixel analysis (128-dim L2-normalized vector)
    • Clear embeddings per profile
  2. Authentication Test Panel

    • Three test modes: Live Camera, Demo (simulated), Manual
    • Simulated lock selector (Lab-Door-01/02, Lab-Entrance, Server-Room)
    • BLE proximity + Wi-Fi match toggles
    • Full pipeline simulation: cosine similarity β†’ multi-model scoring β†’ trust calculation
    • Debug mode toggle for raw pipeline values
  3. Lock Simulation

    • Animated Access Granted β€” Door Unlocked (green unlock + pulse glow)
    • Access Denied shake animation (red pulse)
    • Pending approval state indicator
  4. Confidence Visualization Panel

    • Three doughnut rings: Identity Confidence, Liveness, Trust Score
    • 8-metric score bars: ArcFace, InsightFace, FaceNet, Combined, Final, Liveness, Anti-Spoof, Proximity
    • Full breakdown table with visual bars per metric
    • Confidence history line chart (last 20 tests)
    • Pipeline trace: stage badges (edge β†’ arcface β†’ insightface β†’ fusion β†’ trust) + latency
  5. Security Log Panel

    • Real-time table: timestamp, result badge, matched user, similarity, combined confidence, trust tier/score, latency, lock, test mode
    • Stats bar: total, granted, denied, avg confidence, avg latency
    • Filter by result (granted/denied/pending)
    • Clear all logs
  6. Dev Controls Panel

    • Reset lab (clear embeddings + logs, keep profiles)
    • Delete all test profiles
    • Debug mode (raw model values in debug console)
    • Pipeline config display (all thresholds)
    • Debug console (monospace live output)
    • Lab statistics dashboard

Dev Lab API endpoints (10 routes under /api/devlab/):

GET/POST     /api/devlab/profiles         β€” CRUD test profiles (name, email, role, device ID)
GET          /api/devlab/profiles/:id     β€” Single profile
DELETE       /api/devlab/profiles/:id     β€” Delete profile + embeddings
POST         /api/devlab/enroll/:id       β€” Store face embedding (64-512 floats)
GET          /api/devlab/enroll/:id       β€” List embeddings for profile
DELETE       /api/devlab/enroll/:id       β€” Clear all embeddings for profile
POST         /api/devlab/authenticate     β€” Full auth pipeline simulation
GET/DELETE   /api/devlab/logs             β€” Security log (filter by decision)
GET          /api/devlab/stats            β€” Aggregate lab statistics
DELETE       /api/devlab/reset            β€” Full lab reset

DB tables: devlab_profiles, devlab_embeddings, devlab_test_log, devlab_sessions

Multi-Model Biometric Pipeline (v4.0 β€” Latest)

  • Tiered Recognition Pipeline: Face detection β†’ Alignment β†’ ArcFace primary β†’ Cosine check β†’ If borderline β†’ InsightFace secondary β†’ FaceNet tertiary
  • ArcFace ResNet100 β€” 512-dim embeddings, primary model (weight 50%), angular margin softmax, highest discriminability
  • InsightFace MobileNetV3 β€” 256-dim embeddings, secondary model (weight 30%), fast inference for borderline cases
  • FaceNet Inception β€” 128-dim embeddings, tertiary model (weight 20%), invoked only when first two disagree
  • Score Fusion Formula: combined = ArcFaceΓ—0.50 + InsightFaceΓ—0.30 + FaceNetΓ—0.20
  • Borderline Detection β€” Scores 60-90% trigger secondary verification automatically
  • Model Agreement Score β€” Measures consistency between all active models; low agreement flags suspicious cases
  • Edge AI Preprocessing β€” Face alignment, landmark detection, anti-spoof pre-check run on-device before cloud verification
  • Continuous Learning Engine β€” EMA-based template adaptation after successful authentications (Ξ±=0.05 update per success)
  • Full Audit Logging β€” Every authentication decision logged with all model scores, latency, and decision path

AI Trust Engine v4

  • Multi-Model Trust Formula: trust = face_avgΓ—0.35 + behavioralΓ—0.35 + predictiveΓ—0.20 βˆ’ penaltyΓ—0.10
  • Per-Model Tracking β€” arcface_avg, insightface_avg stored per user in trust profiles
  • Trust Score History β€” Time-series of trust score changes for trend visualization
  • Tiers: trusted (β‰₯85%) instant unlock; standard (β‰₯60%); watchlist (β‰₯40%) extra verification; blocked (<40%)
  • EMA Adaptation β€” Ξ±=0.15 for stable trust evolution
  • Behavioral Model β€” Continuous learning of typical arrival times, doors, device proximity patterns
  • Behavioral Drift Detection β€” Compares recent vs 7-day prior pattern distributions; flags significant shifts

Biometric Audit Log (Compliance)

Every authentication decision records:

  • Decision: granted | denied | pending | error
  • All model scores: arcface_score, insightface_score, facenet_score, combined_confidence
  • anti_spoof_score, liveness_score, edge_confidence, quality_score
  • Pipeline trace: stage_reached (e.g., edgeβ†’arcfaceβ†’insightfaceβ†’fusion)
  • pipeline_latency_ms, model_agreement, is_borderline
  • Trust context: trust_score, trust_tier, behavioral_typical, anomaly_score
  • Device signals: ble_detected, wifi_matched, proximity_score

AI Intelligence Dashboard (v3.0+)

  • Multi-Model Pipeline Status Panel β€” Visual stage flow with per-model accuracy, avg latency, model agreement
  • Pipeline Performance Metrics β€” 7-day total verifications, borderline cases, latency distribution
  • Trust Engine Formula Display β€” Real-time weighted formula visualization
  • Trust Score Cards β€” Trusted / Standard / Watchlist / Anomalies count
  • User Trust Profile Modal β€” Multi-model biometric stats per user (ArcFace, InsightFace, FaceNet averages)
  • Behavioral Heatmap β€” 24Γ—7 access frequency visualization
  • Arrival Predictions β€” Next predicted arrival per user
  • AI Recommendations β€” Auto-generated: revoke blocked, upgrade watchlist, renew guest passes
  • Anomaly Feed β€” Real-time anomaly events with resolve/acknowledge actions

Core Face Recognition

  • Liveness detection (eye-open ratio, motion history, challenge-response)
  • Anti-spoofing: contrast variance, Sobel texture, highlight ratio, screen artifact detection
  • Cosine similarity matching against AES-256 encrypted embeddings
  • Confidence tiers: High β‰₯85% (auto-grant), Medium 65–84% (triggers 2FA), Low <65% (denied)
  • Phone proximity verification (BLE + WiFi)
  • Multi-angle enrollment: 7 angles, 3 liveness challenges

FaceAccess Home

  • Multi-lock smart home security (August, Schlage, Yale, Nuki, Generic)
  • Real-time face recognition at door via FaceID Engine v2.0
  • Guest pass management with time windows and day restrictions
  • Remote approval: push notification β†’ mobile approve/deny
  • Device registration + BLE proximity fingerprinting

Security & Privacy

  • AES-256 GCM encrypted biometric embeddings (Web Crypto API)
  • GDPR-compliant biometric erasure (DELETE /api/home/users/:id/face)
  • Server-side rate limiting: 10 attempts/min per lock
  • Client-side rate limiting: 5 attempts/min with 60s lockout
  • Hard rejection: anti-spoof score < 0.35, liveness < 0.50
  • No raw photos stored; only 512-dim normalized vectors

API Reference

Multi-Model Biometric (v4.0)

POST /api/home/recognize
  Body: { lock_id, arcface_score, insightface_score, facenet_score,
          combined_confidence, anti_spoof_score, liveness_score,
          edge_confidence, model_agreement, pipeline_latency_ms,
          stage_reached, is_borderline, ble_detected, wifi_matched,
          verification_version: "4.0" }

GET  /api/ai/pipeline/stats/:home_id   β€” 7-day pipeline performance metrics
GET  /api/ai/audit/:home_id            β€” Biometric audit log (compliance)
GET  /api/ai/audit/user/:user_id       β€” Per-user audit + model stats
POST /api/ai/multimodel/enroll/:user_id β€” Store multi-model embeddings
GET  /api/ai/multimodel/embeddings/:user_id β€” Enrollment metadata
GET  /api/ai/behavioral/model/:user_id β€” Behavioral model + drift analysis
GET  /api/ai/trust/history/:user_id   β€” Trust score trend history

AI Trust & Anomaly (v3.0)

GET  /api/ai/dashboard/:home_id        β€” Aggregated AI dashboard data
GET  /api/ai/trust/:home_id            β€” All trust profiles
GET  /api/ai/trust/user/:user_id       β€” Single user trust + hour distribution
POST /api/ai/trust/recalculate/:user_id β€” Force recalculate from history
GET  /api/ai/anomalies/:home_id        β€” Anomaly events
PUT  /api/ai/anomalies/:id/acknowledge
PUT  /api/ai/anomalies/:id/resolve
GET  /api/ai/predictions/:home_id      β€” Active predictive sessions
POST /api/ai/predictions/generate/:home_id
GET  /api/ai/recommendations/:home_id
GET  /api/ai/behavioral/:user_id       β€” Full behavioral analysis

Data Architecture

Storage: Cloudflare D1 (SQLite)

Core tables:

  • homes, home_users, home_devices, smart_locks, home_cameras
  • guest_passes, home_events, home_verifications, home_automations

AI tables (v3.0):

  • user_trust_profiles β€” Dynamic trust scores with EMA
  • behavioral_patterns β€” Raw time-series access events (w/ multi-model scores)
  • anomaly_events β€” Detected anomalies with severity and trust delta
  • predictive_sessions β€” Predicted arrival windows
  • ai_recommendations β€” Auto-generated access management suggestions

Multi-model tables (v4.0):

  • biometric_audit_log β€” Full compliance audit record for every authentication
  • multimodel_embeddings β€” Per-model embedding storage (ArcFace, InsightFace, FaceNet)
  • behavioral_models β€” Continuous learning state with drift detection
  • trust_score_history β€” Time-series of trust score changes

Multi-Model Pipeline Algorithms

Score Fusion:

combined = arcface Γ— 0.50 + insightface Γ— 0.30 + facenet Γ— 0.20
adjusted = combined Γ— (anti_spoof_adjustment) Γ— (0.90 + edge_confidence Γ— 0.10)

Trust Score:

trust = face_avg Γ— 0.35 + behavioral Γ— 0.35 + predictive Γ— 0.20 - penalty Γ— 0.10
EMA:  new = prev Γ— 0.85 + current Γ— 0.15  (Ξ± = 0.15)

Anomaly Types:

Type Severity Trust Delta
spoof_attempt critical βˆ’25%
repeated_failures high βˆ’15%
unusual_time high βˆ’12%
off_schedule medium βˆ’5%
behavioral_drift low βˆ’3%

Borderline Handling:

  • If ArcFace score 0.60–0.90 β†’ automatically invoke InsightFace
  • If ArcFace & InsightFace disagree by >10% β†’ invoke FaceNet
  • Model agreement = 1 - std_dev(all_scores) Γ— 4

User Guide

Admin Dashboard

  1. Visit https://faceaccess.pages.dev/home/dashboard
  2. AI Intelligence tab β†’ Multi-Model Pipeline Status, Trust Scores, Anomaly Feed
  3. Click on a user's trust profile to see per-model (ArcFace/InsightFace/FaceNet) biometric stats
  4. Face Recognition tab β†’ Start camera β†’ Click "Verify Identity" β†’ See pipeline stages in result panel
  5. Anomaly Detection tab β†’ Review and resolve security alerts

Mobile App

  1. Visit https://faceaccess.pages.dev/home/mobile
  2. Profile tab shows trust score gauge with security tier
  3. Home tab shows pending door approvals with confidence breakdown
  4. Approve/deny with biometric confirmation

API Integration (v4.0)

POST /api/home/recognize
{
  "lock_id": "lock-xxxx",
  "arcface_score": 0.91,
  "insightface_score": 0.88,
  "facenet_score": 0.87,
  "combined_confidence": 0.895,
  "anti_spoof_score": 0.88,
  "liveness_score": 0.94,
  "edge_confidence": 0.87,
  "model_agreement": 0.96,
  "pipeline_latency_ms": 342,
  "stage_reached": "edge→arcface→insightface→fusion",
  "is_borderline": false,
  "ble_detected": true,
  "verification_version": "4.0"
}

Deployment

  • Platform: Cloudflare Pages + D1 Database
  • Status: βœ… Active
  • Engine Version: v4.0
  • Tech Stack: Hono + TypeScript + TailwindCSS + Cloudflare D1
  • Last Updated: 2026-03-13

New Files (v4.0)

  • public/static/arcface-engine.js β€” Multi-model biometric pipeline (ArcFace, InsightFace, FaceNet, Edge AI, ContinuousLearning, AuditLogger)
  • migrations/0004_multimodel_schema.sql β€” biometric_audit_log, multimodel_embeddings, behavioral_models, trust_score_history + ALTER TABLE statements

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages