# zico-hubb/facial-recognition-access- architecture

> Architecture diagram of the GitHub repository zico-hubb/facial-recognition-access-, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-04). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/zico-hubb/facial-recognition-access-
- Repository: https://github.com/zico-hubb/facial-recognition-access-

## Overview

FaceGate is a Flask facial-recognition access and attendance system. Its main workflow accepts student registration or a recognition image, detects and embeds faces, compares embeddings, and records successful access events in PostgreSQL; dashboard pages are documented as the way to view students and logs. The sampled Flask app implements its own recognition service and raw SQL access, distinct from the SQLAlchemy models and database configuration. The README describes a Next.js frontend, but the tree contains no frontend source to inspect, so that connection is documented but unverified.

Main entry points: [`backend/app.py`](https://github.com/zico-hubb/facial-recognition-access-/blob/main/backend/app.py) (Flask API), [`backend/core/database.py`](https://github.com/zico-hubb/facial-recognition-access-/blob/main/backend/core/database.py) (Database Configuration), [`backend/camera.py`](https://github.com/zico-hubb/facial-recognition-access-/blob/main/backend/camera.py) (Camera Demo), [`backend/models/student.py`](https://github.com/zico-hubb/facial-recognition-access-/blob/main/backend/models/student.py) (Student Model)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["Access API"]
  node_flask["Flask API<br/>[app.py]"]
  node_registration["Student Registration<br/>[app.py]"]
  node_recognition_request["Recognition Request<br/>[app.py]"]
  node_log_view["Student And Log View<br/>[app.py]"]
end

subgraph group_face["Face Recognition"]
  node_face_service["Recognition Service<br/>[app.py]"]
  node_face_util["Embedding Utilities"]
  node_camera["Camera Demo<br/>[camera.py]"]
end

subgraph group_data["Persistence"]
  node_postgres[("PostgreSQL")]
  node_db_config["Database Configuration<br/>[database.py]"]
  node_student_model["Student Model<br/>[student.py]"]
  node_log_model["Access Log Model<br/>[log.py]"]
end

subgraph group_ui["Dashboard"]
  node_dashboard["Web Dashboard"]
end

node_admin(("Administrator"))
node_camera_user(("Camera User"))

node_admin -->|"submits image"| node_registration
node_registration -->|"posts to"| node_flask
node_flask -->|"detects and embeds"| node_face_service
node_face_service -->|"loads embeddings"| node_postgres
node_registration -->|"stores student"| node_postgres
node_camera_user -->|"submits frame"| node_recognition_request
node_recognition_request -.->|"posts to"| node_flask
node_flask -->|"compares faces"| node_face_service
node_flask -->|"writes access log"| node_postgres
node_admin -.->|"requests records"| node_log_view
node_log_view -->|"reads students and logs"| node_postgres
node_dashboard -.->|"displays results"| node_log_view
node_db_config -->|"configures connection"| node_postgres
node_student_model -->|"uses base"| node_db_config
node_log_model -->|"uses base"| node_db_config
node_camera -->|"calls recognition helpers"| node_face_util

click node_flask "https://github.com/zico-hubb/facial-recognition-access-/blob/main/backend/app.py"
click node_registration "https://github.com/zico-hubb/facial-recognition-access-/blob/main/backend/app.py"
click node_recognition_request "https://github.com/zico-hubb/facial-recognition-access-/blob/main/backend/app.py"
click node_log_view "https://github.com/zico-hubb/facial-recognition-access-/blob/main/backend/app.py"
click node_face_service "https://github.com/zico-hubb/facial-recognition-access-/blob/main/backend/app.py"
click node_face_util "https://github.com/zico-hubb/facial-recognition-access-/blob/main/backend/face_recognition_util.py"
click node_camera "https://github.com/zico-hubb/facial-recognition-access-/blob/main/backend/camera.py"
click node_db_config "https://github.com/zico-hubb/facial-recognition-access-/blob/main/backend/core/database.py"
click node_student_model "https://github.com/zico-hubb/facial-recognition-access-/blob/main/backend/models/student.py"
click node_log_model "https://github.com/zico-hubb/facial-recognition-access-/blob/main/backend/models/log.py"
click node_dashboard "https://github.com/zico-hubb/facial-recognition-access-/tree/main/frontend"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_flask,node_registration,node_recognition_request,node_log_view,node_camera_user toneBlue
class node_face_service,node_face_util,node_camera toneAmber
class node_postgres,node_db_config,node_student_model,node_log_model toneMint
class node_dashboard toneRose
class node_admin toneIndigo
```

## Components

### Access API

- [Flask API](https://github.com/zico-hubb/facial-recognition-access-/blob/main/backend/app.py): `backend/app.py`
- [Student Registration](https://github.com/zico-hubb/facial-recognition-access-/blob/main/backend/app.py): `backend/app.py`
- [Recognition Request](https://github.com/zico-hubb/facial-recognition-access-/blob/main/backend/app.py): `backend/app.py`
- [Student And Log View](https://github.com/zico-hubb/facial-recognition-access-/blob/main/backend/app.py): `backend/app.py`

### Face Recognition

- [Recognition Service](https://github.com/zico-hubb/facial-recognition-access-/blob/main/backend/app.py): `backend/app.py`
- [Embedding Utilities](https://github.com/zico-hubb/facial-recognition-access-/blob/main/backend/face_recognition_util.py): `backend/face_recognition_util.py`
- [Camera Demo](https://github.com/zico-hubb/facial-recognition-access-/blob/main/backend/camera.py): `backend/camera.py`

### Persistence

- **PostgreSQL**
- [Database Configuration](https://github.com/zico-hubb/facial-recognition-access-/blob/main/backend/core/database.py): `backend/core/database.py`
- [Student Model](https://github.com/zico-hubb/facial-recognition-access-/blob/main/backend/models/student.py): `backend/models/student.py`
- [Access Log Model](https://github.com/zico-hubb/facial-recognition-access-/blob/main/backend/models/log.py): `backend/models/log.py`

### Dashboard

- [Web Dashboard](https://github.com/zico-hubb/facial-recognition-access-/tree/main/frontend): `frontend`

### Other components

- **Administrator**
- **Camera User**

## Connections

- Administrator → Student Registration: submits image (evidence: `README.md`)
- Student Registration → Flask API: posts to (evidence: `README.md`)
- Flask API → Recognition Service: detects and embeds (evidence: `backend/app.py`)
- Recognition Service → PostgreSQL: loads embeddings (evidence: `backend/app.py`)
- Student Registration → PostgreSQL: stores student (evidence: `backend/app.py`)
- Camera User → Recognition Request: submits frame (evidence: `README.md`)
- Recognition Request → Flask API: posts to (evidence: `README.md`)
- Flask API → Recognition Service: compares faces (evidence: `backend/app.py`)
- Flask API → PostgreSQL: writes access log (evidence: `backend/app.py`)
- Administrator → Student And Log View: requests records (evidence: `README.md`)
- Student And Log View → PostgreSQL: reads students and logs (evidence: `backend/app.py`)
- Web Dashboard → Student And Log View: displays results (evidence: `README.md`)
- Database Configuration → PostgreSQL: configures connection (evidence: `backend/core/database.py`)
- Student Model → Database Configuration: uses base (evidence: `backend/models/student.py`)
- Access Log Model → Database Configuration: uses base (evidence: `backend/models/log.py`)
- Camera Demo → Embedding Utilities: calls recognition helpers (evidence: `backend/camera.py`)
