# phuc1810/attendance-system architecture

> Architecture diagram of the GitHub repository phuc1810/attendance-system, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-14). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/phuc1810/attendance-system
- Repository: https://github.com/phuc1810/attendance-system

## Overview

Smart Attendance is a Streamlit application for employee administration and face-based attendance. Users register employees and face samples, then run camera-based IN/OUT recognition; the system checks attendance rules and records events for dashboards and filtered history/export. Separate pages provide face-detection and recognition test benches. The graph reflects README capabilities and indexed references; unsampled page implementations are represented by their exact paths, but their internal calls are not assumed.

Main entry points: [`app.py`](https://github.com/phuc1810/attendance-system/blob/main/app.py) (App navigation), [`db/database.py`](https://github.com/phuc1810/attendance-system/blob/main/db/database.py) (Employee repository), [`db/attendance_repo.py`](https://github.com/phuc1810/attendance-system/blob/main/db/attendance_repo.py) (IN/OUT rules), [`pages/3_Register_Face.py`](https://github.com/phuc1810/attendance-system/blob/main/pages/3_Register_Face.py) (Face registration)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["Streamlit app"]
  node_entry["App navigation<br/>[app.py]"]
  node_styles["UI styling<br/>[styles.py]"]
  node_dashboard["Dashboard<br/>[1_Dashboard.py]"]
  node_employees["Employee management<br/>[2_Employees.py]"]
end

subgraph group_vision["Vision and enrollment"]
  node_register["Face registration<br/>[3_Register_Face.py]"]
  node_detect_test["Detection test"]
  node_recognition_test["Recognition test"]
  node_camera["Camera streaming<br/>[camera_stream.py]"]
  node_detector["Face detection<br/>[face_detect.py]"]
  node_face_files["Face image storage<br/>[save_face.py]"]
  node_dataset["Training dataset<br/>[face_dataset.py]"]
  node_recognizer["Face recognition<br/>[face_recognizer.py]"]
end

subgraph group_attendance["Attendance operations"]
  node_attendance_page["Check-in camera<br/>[4_Attendance.py]"]
  node_history["History and export<br/>[5_History.py]"]
  node_attendance_rules["IN/OUT rules<br/>[attendance_repo.py]"]
end

subgraph group_data["Data layer"]
  node_employee_repo["Employee repository<br/>[database.py]"]
  node_models["ORM models<br/>[models.py]"]
  node_sessions["DB sessions<br/>[session.py]"]
  node_sqlite[("SQLite database")]
end

node_user(("Operator"))

node_user -->|"opens"| node_entry
node_entry -->|"applies"| node_styles
node_entry -->|"navigates"| node_dashboard
node_entry -->|"navigates"| node_employees
node_entry -->|"navigates"| node_register
node_entry -->|"navigates"| node_attendance_page
node_entry -->|"navigates"| node_history
node_entry -->|"navigates"| node_detect_test
node_entry -->|"navigates"| node_recognition_test
node_entry -->|"initializes"| node_employee_repo
node_entry -->|"initializes"| node_attendance_rules
node_dashboard -->|"queries"| node_employee_repo
node_dashboard -->|"queries"| node_attendance_rules
node_employees -->|"manages"| node_employee_repo
node_register -->|"reads frames"| node_camera
node_register -->|"detects faces"| node_detector
node_register -->|"saves samples"| node_face_files
node_register -->|"loads employees"| node_employee_repo
node_attendance_page -->|"reads frames"| node_camera
node_attendance_page -->|"detects faces"| node_detector
node_attendance_page -->|"predicts identity"| node_recognizer
node_attendance_page -->|"registers event"| node_attendance_rules
node_history -->|"queries history"| node_attendance_rules
node_detect_test -->|"reads frames"| node_camera
node_detect_test -->|"detects faces"| node_detector
node_recognition_test -->|"reads frames"| node_camera
node_recognition_test -->|"detects faces"| node_detector
node_recognition_test -->|"predicts identity"| node_recognizer
node_recognizer -->|"loads training data"| node_dataset
node_recognizer -->|"resolves labels"| node_employee_repo
node_employee_repo -->|"syncs employee folders"| node_face_files
node_attendance_rules -->|"opens sessions"| node_sessions
node_attendance_rules -->|"queries models"| node_models
node_employee_repo -->|"opens sessions"| node_sessions
node_employee_repo -->|"queries models"| node_models
node_sessions -->|"creates schema"| node_models
node_sessions -->|"connects"| node_sqlite

click node_entry "https://github.com/phuc1810/attendance-system/blob/main/app.py"
click node_styles "https://github.com/phuc1810/attendance-system/blob/main/ui/styles.py"
click node_dashboard "https://github.com/phuc1810/attendance-system/blob/main/pages/1_Dashboard.py"
click node_employees "https://github.com/phuc1810/attendance-system/blob/main/pages/2_Employees.py"
click node_register "https://github.com/phuc1810/attendance-system/blob/main/pages/3_Register_Face.py"
click node_attendance_page "https://github.com/phuc1810/attendance-system/blob/main/pages/4_Attendance.py"
click node_history "https://github.com/phuc1810/attendance-system/blob/main/pages/5_History.py"
click node_detect_test "https://github.com/phuc1810/attendance-system/blob/main/pages/6_Face_Detection.py"
click node_recognition_test "https://github.com/phuc1810/attendance-system/blob/main/pages/7_Face_Recognition.py"
click node_camera "https://github.com/phuc1810/attendance-system/blob/main/core/camera_stream.py"
click node_detector "https://github.com/phuc1810/attendance-system/blob/main/core/face_detect.py"
click node_face_files "https://github.com/phuc1810/attendance-system/blob/main/core/save_face.py"
click node_dataset "https://github.com/phuc1810/attendance-system/blob/main/core/face_dataset.py"
click node_recognizer "https://github.com/phuc1810/attendance-system/blob/main/core/face_recognizer.py"
click node_attendance_rules "https://github.com/phuc1810/attendance-system/blob/main/db/attendance_repo.py"
click node_employee_repo "https://github.com/phuc1810/attendance-system/blob/main/db/database.py"
click node_models "https://github.com/phuc1810/attendance-system/blob/main/db/models.py"
click node_sessions "https://github.com/phuc1810/attendance-system/blob/main/db/session.py"

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_entry,node_styles,node_dashboard,node_employees toneBlue
class node_register,node_detect_test,node_recognition_test,node_camera,node_detector,node_face_files,node_dataset,node_recognizer toneAmber
class node_attendance_page,node_history,node_attendance_rules toneMint
class node_employee_repo,node_models,node_sessions,node_sqlite toneRose
class node_user toneIndigo
```

## Components

### Streamlit app

- [App navigation](https://github.com/phuc1810/attendance-system/blob/main/app.py): `app.py`
- [UI styling](https://github.com/phuc1810/attendance-system/blob/main/ui/styles.py): `ui/styles.py`
- [Dashboard](https://github.com/phuc1810/attendance-system/blob/main/pages/1_Dashboard.py): `pages/1_Dashboard.py`
- [Employee management](https://github.com/phuc1810/attendance-system/blob/main/pages/2_Employees.py): `pages/2_Employees.py`

### Vision and enrollment

- [Face registration](https://github.com/phuc1810/attendance-system/blob/main/pages/3_Register_Face.py): `pages/3_Register_Face.py`
- [Detection test](https://github.com/phuc1810/attendance-system/blob/main/pages/6_Face_Detection.py): `pages/6_Face_Detection.py`
- [Recognition test](https://github.com/phuc1810/attendance-system/blob/main/pages/7_Face_Recognition.py): `pages/7_Face_Recognition.py`
- [Camera streaming](https://github.com/phuc1810/attendance-system/blob/main/core/camera_stream.py): `core/camera_stream.py`
- [Face detection](https://github.com/phuc1810/attendance-system/blob/main/core/face_detect.py): `core/face_detect.py`
- [Face image storage](https://github.com/phuc1810/attendance-system/blob/main/core/save_face.py): `core/save_face.py`
- [Training dataset](https://github.com/phuc1810/attendance-system/blob/main/core/face_dataset.py): `core/face_dataset.py`
- [Face recognition](https://github.com/phuc1810/attendance-system/blob/main/core/face_recognizer.py): `core/face_recognizer.py`

### Attendance operations

- [Check-in camera](https://github.com/phuc1810/attendance-system/blob/main/pages/4_Attendance.py): `pages/4_Attendance.py`
- [History and export](https://github.com/phuc1810/attendance-system/blob/main/pages/5_History.py): `pages/5_History.py`
- [IN/OUT rules](https://github.com/phuc1810/attendance-system/blob/main/db/attendance_repo.py): `db/attendance_repo.py`

### Data layer

- [Employee repository](https://github.com/phuc1810/attendance-system/blob/main/db/database.py): `db/database.py`
- [ORM models](https://github.com/phuc1810/attendance-system/blob/main/db/models.py): `db/models.py`
- [DB sessions](https://github.com/phuc1810/attendance-system/blob/main/db/session.py): `db/session.py`
- **SQLite database**

### Other components

- **Operator**

## Connections

- Operator → App navigation: opens (evidence: `README.md`)
- App navigation → UI styling: applies (evidence: `app.py`)
- App navigation → Dashboard: navigates (evidence: `app.py`)
- App navigation → Employee management: navigates (evidence: `app.py`)
- App navigation → Face registration: navigates (evidence: `app.py`)
- App navigation → Check-in camera: navigates (evidence: `app.py`)
- App navigation → History and export: navigates (evidence: `app.py`)
- App navigation → Detection test: navigates (evidence: `app.py`)
- App navigation → Recognition test: navigates (evidence: `app.py`)
- App navigation → Employee repository: initializes (evidence: `app.py`)
- App navigation → IN/OUT rules: initializes (evidence: `app.py`)
- Dashboard → Employee repository: queries (evidence: `pages/1_Dashboard.py`)
- Dashboard → IN/OUT rules: queries (evidence: `pages/1_Dashboard.py`)
- Employee management → Employee repository: manages (evidence: `pages/2_Employees.py`)
- Face registration → Camera streaming: reads frames (evidence: `pages/3_Register_Face.py`)
- Face registration → Face detection: detects faces (evidence: `pages/3_Register_Face.py`)
- Face registration → Face image storage: saves samples (evidence: `pages/3_Register_Face.py`)
- Face registration → Employee repository: loads employees (evidence: `pages/3_Register_Face.py`)
- Check-in camera → Camera streaming: reads frames (evidence: `pages/4_Attendance.py`)
- Check-in camera → Face detection: detects faces (evidence: `pages/4_Attendance.py`)
- Check-in camera → Face recognition: predicts identity (evidence: `pages/4_Attendance.py`)
- Check-in camera → IN/OUT rules: registers event (evidence: `pages/4_Attendance.py`)
- History and export → IN/OUT rules: queries history (evidence: `pages/5_History.py`)
- Detection test → Camera streaming: reads frames (evidence: `pages/6_Face_Detection.py`)
- Detection test → Face detection: detects faces (evidence: `pages/6_Face_Detection.py`)
- Recognition test → Camera streaming: reads frames (evidence: `pages/7_Face_Recognition.py`)
- Recognition test → Face detection: detects faces (evidence: `pages/7_Face_Recognition.py`)
- Recognition test → Face recognition: predicts identity (evidence: `pages/7_Face_Recognition.py`)
- Face recognition → Training dataset: loads training data (evidence: `core/face_recognizer.py`)
- Face recognition → Employee repository: resolves labels (evidence: `core/face_recognizer.py`)
- Employee repository → Face image storage: syncs employee folders (evidence: `db/database.py`)
- IN/OUT rules → DB sessions: opens sessions (evidence: `db/attendance_repo.py`)
- IN/OUT rules → ORM models: queries models (evidence: `db/attendance_repo.py`)
- Employee repository → DB sessions: opens sessions (evidence: `db/database.py`)
- Employee repository → ORM models: queries models (evidence: `db/database.py`)
- DB sessions → ORM models: creates schema (evidence: `db/session.py`)
- DB sessions → SQLite database: connects (evidence: `db/session.py`)
