# revaldo007/face-recognition architecture

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

- Interactive diagram: https://gitdiagram.com/revaldo007/face-recognition
- Repository: https://github.com/revaldo007/face-recognition

## Overview

This is a role-based college attendance application: administrators manage academic records, faculty enroll faces and run class sessions, and students review attendance. The main workflow is face enrollment, camera-frame recognition within a class session, present/absent recording, then reports and student history. The graph combines sampled call/import evidence with README-documented behavior; several UI and backend subsystems are represented by exact tree paths but were not sampled, so their specific internal calls are not asserted.

Main entry points: [`backend/app/main.py`](https://github.com/revaldo007/face-recognition/blob/main/backend/app/main.py) (FastAPI app), [`frontend/src/services/api.js`](https://github.com/revaldo007/face-recognition/blob/main/frontend/src/services/api.js) (API client), [`backend/app/routers/attendance.py`](https://github.com/revaldo007/face-recognition/blob/main/backend/app/routers/attendance.py) (Attendance routes), [`backend/app/services/attendance_service.py`](https://github.com/revaldo007/face-recognition/blob/main/backend/app/services/attendance_service.py) (Attendance rules)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Role-based web app"]
  node_webapp["Role-routed application<br/>[App.jsx]"]
  node_authui["Login and auth state<br/>[AuthContext.jsx]"]
  node_apiclient["API client<br/>[api.js]"]
  node_adminui["Admin management"]
  node_enrollui["Face enrollment<br/>[FaceEnrollment.jsx]"]
  node_camera["Browser camera<br/>[Camera.jsx]"]
  node_sessionui["Attendance session"]
  node_recordsui["Records and reports<br/>[Reports.jsx]"]
  node_studentui["Student portal"]
end

subgraph group_api["Backend API"]
  node_fastapi["FastAPI app<br/>[main.py]"]
  node_authapi["Authentication routes<br/>[auth.py]"]
  node_adminapi["Academic CRUD routes"]
  node_faceapi["Face enrollment routes<br/>[face.py]"]
  node_attendanceapi["Attendance routes<br/>[attendance.py]"]
  node_reportsapi["Reports routes<br/>[reports.py]"]
  node_security["JWT and role checks<br/>[dependencies.py]"]
end

subgraph group_vision["Face and attendance"]
  node_detection["Face detection<br/>[face_detection.py]"]
  node_recognition["Face matching"]
  node_attendance["Attendance rules"]
end

subgraph group_records["Academic records"]
  node_models["Domain models"]
  node_database[("PostgreSQL database")]
end

node_user(("College users"))

node_user -->|"uses"| node_webapp
node_webapp -->|"checks identity"| node_authui
node_authui -->|"requests login"| node_apiclient
node_adminui -.->|"manages records"| node_apiclient
node_enrollui -->|"captures frames"| node_camera
node_enrollui -->|"submits enrollment"| node_apiclient
node_sessionui -->|"captures frames"| node_camera
node_sessionui -->|"sends frames"| node_apiclient
node_recordsui -->|"loads reports"| node_apiclient
node_studentui -.->|"loads attendance"| node_apiclient
node_apiclient -->|"calls API"| node_fastapi
node_fastapi -->|"registers routes"| node_authapi
node_fastapi -->|"registers routes"| node_adminapi
node_fastapi -->|"registers routes"| node_faceapi
node_fastapi -->|"registers routes"| node_attendanceapi
node_fastapi -->|"registers routes"| node_reportsapi
node_authapi -->|"creates tokens"| node_security
node_attendanceapi -->|"detects faces"| node_detection
node_attendanceapi -->|"matches faces"| node_recognition
node_attendanceapi -->|"marks attendance"| node_attendance
node_reportsapi -->|"calculates summaries"| node_attendance
node_attendance -->|"reads and writes"| node_models
node_fastapi -->|"creates tables"| node_database
node_models -.->|"persists records"| node_database

click node_webapp "https://github.com/revaldo007/face-recognition/blob/main/frontend/src/App.jsx"
click node_authui "https://github.com/revaldo007/face-recognition/blob/main/frontend/src/context/AuthContext.jsx"
click node_apiclient "https://github.com/revaldo007/face-recognition/blob/main/frontend/src/services/api.js"
click node_adminui "https://github.com/revaldo007/face-recognition/tree/main/frontend/src/pages/admin"
click node_enrollui "https://github.com/revaldo007/face-recognition/blob/main/frontend/src/pages/faculty/FaceEnrollment.jsx"
click node_camera "https://github.com/revaldo007/face-recognition/blob/main/frontend/src/components/Camera.jsx"
click node_sessionui "https://github.com/revaldo007/face-recognition/blob/main/frontend/src/pages/faculty/AttendanceSession.jsx"
click node_recordsui "https://github.com/revaldo007/face-recognition/blob/main/frontend/src/pages/Reports.jsx"
click node_studentui "https://github.com/revaldo007/face-recognition/tree/main/frontend/src/pages/student"
click node_fastapi "https://github.com/revaldo007/face-recognition/blob/main/backend/app/main.py"
click node_authapi "https://github.com/revaldo007/face-recognition/blob/main/backend/app/routers/auth.py"
click node_adminapi "https://github.com/revaldo007/face-recognition/tree/main/backend/app/routers"
click node_faceapi "https://github.com/revaldo007/face-recognition/blob/main/backend/app/routers/face.py"
click node_attendanceapi "https://github.com/revaldo007/face-recognition/blob/main/backend/app/routers/attendance.py"
click node_reportsapi "https://github.com/revaldo007/face-recognition/blob/main/backend/app/routers/reports.py"
click node_security "https://github.com/revaldo007/face-recognition/blob/main/backend/app/dependencies.py"
click node_detection "https://github.com/revaldo007/face-recognition/blob/main/backend/app/services/face_detection.py"
click node_recognition "https://github.com/revaldo007/face-recognition/blob/main/backend/app/services/face_recognition.py"
click node_attendance "https://github.com/revaldo007/face-recognition/blob/main/backend/app/services/attendance_service.py"
click node_models "https://github.com/revaldo007/face-recognition/tree/main/backend/app/models"

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_webapp,node_authui,node_apiclient,node_adminui,node_enrollui,node_camera,node_sessionui,node_recordsui,node_studentui,node_user toneBlue
class node_fastapi,node_authapi,node_adminapi,node_faceapi,node_attendanceapi,node_reportsapi,node_security toneAmber
class node_detection,node_recognition,node_attendance toneMint
class node_models,node_database toneRose
```

## Components

### Role-based web app

- [Role-routed application](https://github.com/revaldo007/face-recognition/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Login and auth state](https://github.com/revaldo007/face-recognition/blob/main/frontend/src/context/AuthContext.jsx): `frontend/src/context/AuthContext.jsx`
- [API client](https://github.com/revaldo007/face-recognition/blob/main/frontend/src/services/api.js): `frontend/src/services/api.js`
- [Admin management](https://github.com/revaldo007/face-recognition/tree/main/frontend/src/pages/admin): `frontend/src/pages/admin`
- [Face enrollment](https://github.com/revaldo007/face-recognition/blob/main/frontend/src/pages/faculty/FaceEnrollment.jsx): `frontend/src/pages/faculty/FaceEnrollment.jsx`
- [Browser camera](https://github.com/revaldo007/face-recognition/blob/main/frontend/src/components/Camera.jsx): `frontend/src/components/Camera.jsx`
- [Attendance session](https://github.com/revaldo007/face-recognition/blob/main/frontend/src/pages/faculty/AttendanceSession.jsx): `frontend/src/pages/faculty/AttendanceSession.jsx`
- [Records and reports](https://github.com/revaldo007/face-recognition/blob/main/frontend/src/pages/Reports.jsx): `frontend/src/pages/Reports.jsx`
- [Student portal](https://github.com/revaldo007/face-recognition/tree/main/frontend/src/pages/student): `frontend/src/pages/student`

### Backend API

- [FastAPI app](https://github.com/revaldo007/face-recognition/blob/main/backend/app/main.py): `backend/app/main.py`
- [Authentication routes](https://github.com/revaldo007/face-recognition/blob/main/backend/app/routers/auth.py): `backend/app/routers/auth.py`
- [Academic CRUD routes](https://github.com/revaldo007/face-recognition/tree/main/backend/app/routers): `backend/app/routers`
- [Face enrollment routes](https://github.com/revaldo007/face-recognition/blob/main/backend/app/routers/face.py): `backend/app/routers/face.py`
- [Attendance routes](https://github.com/revaldo007/face-recognition/blob/main/backend/app/routers/attendance.py): `backend/app/routers/attendance.py`
- [Reports routes](https://github.com/revaldo007/face-recognition/blob/main/backend/app/routers/reports.py): `backend/app/routers/reports.py`
- [JWT and role checks](https://github.com/revaldo007/face-recognition/blob/main/backend/app/dependencies.py): `backend/app/dependencies.py`

### Face and attendance

- [Face detection](https://github.com/revaldo007/face-recognition/blob/main/backend/app/services/face_detection.py): `backend/app/services/face_detection.py`
- [Face matching](https://github.com/revaldo007/face-recognition/blob/main/backend/app/services/face_recognition.py): `backend/app/services/face_recognition.py`
- [Attendance rules](https://github.com/revaldo007/face-recognition/blob/main/backend/app/services/attendance_service.py): `backend/app/services/attendance_service.py`

### Academic records

- [Domain models](https://github.com/revaldo007/face-recognition/tree/main/backend/app/models): `backend/app/models`
- **PostgreSQL database**

### Other components

- **College users**

## Connections

- College users → Role-routed application: uses (evidence: `frontend/src/App.jsx`)
- Role-routed application → Login and auth state: checks identity (evidence: `frontend/src/App.jsx`)
- Login and auth state → API client: requests login (evidence: `frontend/src/context/AuthContext.jsx`)
- Admin management → API client: manages records (evidence: `frontend/src/pages/admin/Students.jsx`)
- Face enrollment → Browser camera: captures frames (evidence: `frontend/src/pages/faculty/FaceEnrollment.jsx`)
- Face enrollment → API client: submits enrollment (evidence: `frontend/src/pages/faculty/FaceEnrollment.jsx`)
- Attendance session → Browser camera: captures frames (evidence: `README.md`)
- Attendance session → API client: sends frames (evidence: `README.md`)
- Records and reports → API client: loads reports (evidence: `frontend/src/pages/Reports.jsx`)
- Student portal → API client: loads attendance (evidence: `frontend/src/pages/student/StudentDashboard.jsx`)
- API client → FastAPI app: calls API (evidence: `frontend/src/services/api.js`)
- FastAPI app → Authentication routes: registers routes (evidence: `backend/app/main.py`)
- FastAPI app → Academic CRUD routes: registers routes (evidence: `backend/app/main.py`)
- FastAPI app → Face enrollment routes: registers routes (evidence: `backend/app/main.py`)
- FastAPI app → Attendance routes: registers routes (evidence: `backend/app/main.py`)
- FastAPI app → Reports routes: registers routes (evidence: `backend/app/main.py`)
- Authentication routes → JWT and role checks: creates tokens (evidence: `backend/app/routers/auth.py`)
- Attendance routes → Face detection: detects faces (evidence: `backend/app/routers/attendance.py`)
- Attendance routes → Face matching: matches faces (evidence: `backend/app/routers/attendance.py`)
- Attendance routes → Attendance rules: marks attendance (evidence: `backend/app/routers/attendance.py`)
- Reports routes → Attendance rules: calculates summaries (evidence: `backend/app/routers/reports.py`)
- Attendance rules → Domain models: reads and writes (evidence: `backend/app/services/attendance_service.py`)
- FastAPI app → PostgreSQL database: creates tables (evidence: `backend/app/main.py`)
- Domain models → PostgreSQL database: persists records
