# aryan2-7/smartattendance architecture

> Architecture diagram of the GitHub repository aryan2-7/smartattendance, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-07-03). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/aryan2-7/smartattendance
- Repository: https://github.com/aryan2-7/smartattendance

## Overview

1. This repository is a C++17 desktop application for smart attendance, built around a Qt GUI with OpenCV-based facial recognition and SQLite persistence. The top-level structure suggests a single executable launched from `src/main.cpp`, with feature modules split by responsibility rather than by service.

2. The main functional boundaries are visible in `src/registration`, `src/attendance`, `src/auth`, `src/records`, `src/export`, and `src/db`. These map to the core user flows: registering a face, authenticating a user, marking attendance, viewing stored records, exporting data, and storing/retrieving records from the database.

3. The only substantive source file present in the tree is `src/registration/FaceRegistration.cpp` and its header, so face registration is the most clearly implemented subsystem in the current snapshot. The other module directories exist but appear to be placeholders, which is important if you are drawing the architecture: the repository is structured as a multi-module app, but the implementation is only partially populated.

4. The computer-vision boundary is driven by OpenCV. The `resources/haarcascades/haarcascade_frontalface_default.xml` file indicates Haar cascade face detection is used for locating faces, while the README states LBPH recognition from `opencv_contrib` is part of the stack. That implies a pipeline of camera frames → face detection → face recognition/training → stored model.

5. Model artifacts are separated from source code under `resources/trained_models`. This suggests recognition state is persisted as filesystem assets rather than embedded in the database, which creates a clear split: image/model data on disk, operational records in SQLite.

6. The database boundary is represented by `src/db` and the README’s SQLite dependency. In the intended architecture, SQLite likely stores user profiles, attendance events, and record metadata, while the face model files hold recognition features or trained classifiers. That means the system has two persistence paths: relational data in SQLite and ML artifacts in local resources.

7. Authentication appears to be a separate gate in `src/auth`, not just a UI concern. For an architecture diagram, it should sit before administrative features like records viewing or export, controlling access to attendance and maintenance functions.

8. Attendance marking in `src/attendance` is logically downstream from registration and authentication. The expected flow is: a registered face is recognized from a live camera feed, then the attendance module writes a presence event to the database. This is the primary operational path of the application.

9. Records and export are read-heavy subsystems. `src/records` is likely responsible for querying and presenting attendance history, while `src/export` takes those same records and produces a file-based output format for reporting or sharing. Both depend on the database rather than on the camera/vision pipeline.

10. The `resources/icons` folder and the Qt dependency indicate a conventional desktop UI with packaged assets. UI rendering is therefore a separate layer from business logic, with the Qt frontend orchestrating module calls and showing results, rather than the modules directly driving each other.

11. From an architecture perspective, the important integration points are:
- UI entrypoint in `main.cpp`
- OpenCV camera/vision pipeline in registration and attendance
- SQLite as system-of-record for attendance and users
- trained model files as local ML artifacts
- resource files for cascades and UI assets

12. In short, this is a layered desktop system: presentation/UI on top, feature modules in the middle, and two persistence backends underneath. The visible codebase is best diagrammed as a modular monolith with clear separations for registration, recognition, auth, records, export, and database access.

Main entry points: [`src/main.cpp`](https://github.com/aryan2-7/smartattendance/blob/main/src/main.cpp) (App entry), [`src/db`](https://github.com/aryan2-7/smartattendance/tree/main/src/db) (DB access), [`src/attendance`](https://github.com/aryan2-7/smartattendance/tree/main/src/attendance) (Attendance), [`src/registration/FaceRegistration.cpp`](https://github.com/aryan2-7/smartattendance/blob/main/src/registration/FaceRegistration.cpp) (Face reg)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["Presentation"]
  node_main["App entry<br/>qt main<br/>[main.cpp]"]
  node_icons["Icons<br/>ui assets"]
end

subgraph group_core["Feature Modules"]
  node_registration["Registration<br/>feature module"]
  node_face_reg["Face reg<br/>opencv module"]
  node_attendance["Attendance<br/>feature module"]
  node_auth["Auth<br/>feature module"]
  node_records["Records<br/>feature module"]
  node_export["Export<br/>feature module"]
end

subgraph group_data["Persistence"]
  node_db[("DB access<br/>sqlite layer")]
  node_sqlite[("SQLite<br/>relational store")]
end

subgraph group_ml["Vision Assets"]
  node_models["Trained models<br/>ml artifacts"]
  node_cascades["Haar cascade<br/>vision asset"]
end

node_main -->|"opens"| node_registration
node_main -->|"opens"| node_attendance
node_main -->|"opens"| node_auth
node_main -->|"opens"| node_records
node_main -->|"opens"| node_export
node_registration -->|"implements"| node_face_reg
node_face_reg -->|"detects faces"| node_cascades
node_face_reg -->|"writes model"| node_models
node_attendance -->|"detects faces"| node_cascades
node_attendance -->|"recognizes"| node_models
node_attendance -->|"writes event"| node_db
node_auth -->|"verifies access"| node_db
node_records -->|"reads history"| node_db
node_export -->|"consumes"| node_records
node_export -->|"reads history"| node_db
node_db -->|"persists to"| node_sqlite
node_main -->|"loads assets"| node_icons

click node_main "https://github.com/aryan2-7/smartattendance/blob/main/src/main.cpp"
click node_icons "https://github.com/aryan2-7/smartattendance/tree/main/resources/icons"
click node_registration "https://github.com/aryan2-7/smartattendance/tree/main/src/registration"
click node_face_reg "https://github.com/aryan2-7/smartattendance/blob/main/src/registration/FaceRegistration.cpp"
click node_attendance "https://github.com/aryan2-7/smartattendance/tree/main/src/attendance"
click node_auth "https://github.com/aryan2-7/smartattendance/tree/main/src/auth"
click node_records "https://github.com/aryan2-7/smartattendance/tree/main/src/records"
click node_export "https://github.com/aryan2-7/smartattendance/tree/main/src/export"
click node_db "https://github.com/aryan2-7/smartattendance/tree/main/src/db"
click node_models "https://github.com/aryan2-7/smartattendance/tree/main/resources/trained_models"
click node_cascades "https://github.com/aryan2-7/smartattendance/blob/main/resources/haarcascades/haarcascade_frontalface_default.xml"

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_main,node_icons toneBlue
class node_registration,node_face_reg,node_attendance,node_auth,node_records,node_export toneAmber
class node_db,node_sqlite toneMint
class node_models,node_cascades toneRose
```

## Components

### Presentation

Qt desktop entry and packaged UI assets

- [App entry](https://github.com/aryan2-7/smartattendance/blob/main/src/main.cpp): qt main · Launches the desktop application and wires the top-level UI. · `src/main.cpp`
- [Icons](https://github.com/aryan2-7/smartattendance/tree/main/resources/icons): ui assets · Packaged application icons and other desktop assets. · `resources/icons`

### Feature Modules

Attendance workflow and user-facing application logic

- [Registration](https://github.com/aryan2-7/smartattendance/tree/main/src/registration): feature module · Registers new faces and prepares recognition data. · `src/registration`
- [Face reg](https://github.com/aryan2-7/smartattendance/blob/main/src/registration/FaceRegistration.cpp): opencv module · Implemented face registration workflow built on OpenCV. · `src/registration/FaceRegistration.cpp`
- [Attendance](https://github.com/aryan2-7/smartattendance/tree/main/src/attendance): feature module · Marks attendance from recognized faces and live capture. · `src/attendance`
- [Auth](https://github.com/aryan2-7/smartattendance/tree/main/src/auth): feature module · Handles access control for administrative application flows. · `src/auth`
- [Records](https://github.com/aryan2-7/smartattendance/tree/main/src/records): feature module · Queries and presents stored attendance history. · `src/records`
- [Export](https://github.com/aryan2-7/smartattendance/tree/main/src/export): feature module · Produces file-based reports from stored attendance records. · `src/export`

### Persistence

Database and local model/storage backends

- [DB access](https://github.com/aryan2-7/smartattendance/tree/main/src/db): sqlite layer · Application data access boundary for users, attendance, and metadata. · `src/db`
- **SQLite**: relational store · System-of-record for users, attendance events, and record metadata.

### Vision Assets

Face detection and recognition resources

- [Trained models](https://github.com/aryan2-7/smartattendance/tree/main/resources/trained_models): ml artifacts · Persisted recognition models and classifier state on disk. · `resources/trained_models`
- [Haar cascade](https://github.com/aryan2-7/smartattendance/blob/main/resources/haarcascades/haarcascade_frontalface_default.xml): vision asset · Face detection cascade used to locate faces in camera frames. · `resources/haarcascades/haarcascade_frontalface_default.xml`

## Connections

- App entry → Registration: opens · The app launches into the feature modules from the desktop entrypoint.
- App entry → Attendance: opens · Attendance workflow is started from the main application shell.
- App entry → Auth: opens · Authentication gates protected features in the UI.
- App entry → Records: opens · Users browse attendance history through the main UI.
- App entry → Export: opens · Reporting/export actions are initiated from the application shell.
- Registration → Face reg: implements · Face registration is the concrete implemented subsystem in the repository snapshot.
- Face reg → Haar cascade: detects faces · Uses the Haar cascade to find faces in captured frames.
- Face reg → Trained models: writes model · Stores trained recognition artifacts on disk.
- Attendance → Haar cascade: detects faces · Locates faces before recognition and attendance marking.
- Attendance → Trained models: recognizes · Compares live captures against persisted recognition state.
- Attendance → DB access: writes event · Stores attendance marks and related metadata.
- Auth → DB access: verifies access · Checks credentials or user state through the database boundary.
- Records → DB access: reads history · Queries attendance records for display.
- Export → Records: consumes · Exports are based on the records query/view layer.
- Export → DB access: reads history · Pulls stored attendance data for report generation.
- DB access → SQLite: persists to · The application stores operational data in SQLite.
- App entry → Icons: loads assets · The UI uses packaged icons and desktop resources.
