# ratheshprabakar/attendance-system architecture

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

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

## Overview

##### Main Components
- Admin Site: Represents the administration portal (found in the admin_site directory). This component handles registration of faculties and students, collection of student training data (snapshots), and model creation/storage.
- Teachers Site: Represents the teacher’s portal (located in the teachers_site directory). This component manages teacher login, capturing snaps for marking attendance, attendance reporting, Excel generation for reports, and email alert functionality.
- Facial Recognition Module: Part of the teachers_site (specifically in tf_files), which contains the retrained TensorFlow graph (retrained_graph.pb) and labels (retrained_labels.txt). This module is responsible for processing captured images and matching them against stored faces.
- Database: Represented by the database.sql file and the underlying database used by both the admin and teacher sites for storing faculty, student details, attendance logs, and model data.
- Excel & Report Generation: Indicated by the excel subdirectories under teachers_site, storing generated attendance reports in Excel format.
- External Services: Email alerts (via flask_mail in the teachers site) that send notifications to students and their parents.

##### Relationships and Interactions
- The Admin Site and Teachers Site are two separate Flask applications. They both interact with the central database.
- The Admin Site is responsible for initial input: adding new faculties, enrolling students, capturing training images, and creating/updating facial recognition models.
- The Teachers Site captures live snaps during class sessions. These images are passed to the Facial Recognition Module for identity verification.
- Once a recognition match is made, the Teachers Site marks attendance and this data is stored in the central Database.
- Attendance data flows from the teacher application into the database and then is used by reporting modules to generate Excel files.
- The email alert functionality is triggered in the Teachers Site and uses external email services to communicate with students/parents.

##### Architectural Patterns and Design Principles
- Client-Server (Web) Architecture: Two client interfaces (admin and teacher) interact with backend services.
- Modular Separation: Clearly dividing administrative functions from teacher functionalities while sharing the underlying data and facial recognition module.
- Use of Third-party Libraries/Frameworks: Python Flask for web apps; TensorFlow (using the retrained model files) for facial recognition; flask_mail for email alerts.
- Data Flow & Processing Pipelines: Image capture → Facial recognition processing → Attendance marking → Report generation.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Presentation Layer
    subgraph "Presentation Layer"
        AdminSite["Admin Site (Faculty Registration, Student Enrollment, Model Training)"] 
        TeacherSite["Teachers Site (Login, Live Capture, Attendance Marking)"]
    end

    %% Processing Layer
    subgraph "Processing Layer"
        FaceRec["Facial Recognition Module (TensorFlow)"]
    end

    %% Data Layer
    subgraph "Data Layer"
        Database["Database (Faculty, Students, Attendance Logs)"]
    end

    %% Output/Integration Layer
    subgraph "Output/Integration"
        ExcelReports["Excel & Report Generation"]
        EmailService["External Email Service (Email Alerts)"]
    end

    %% Connections
    AdminSite -->|"sends-registration-training-data"| Database
    TeacherSite -->|"captures-live-snap"| FaceRec
    FaceRec -->|"returns-match"| TeacherSite
    TeacherSite -->|"sends-attendance-data"| Database
    Database -->|"data-for-reports"| ExcelReports
    Database -->|"trigger-alerts"| EmailService

    %% Click Events
    click AdminSite "https://github.com/ratheshprabakar/attendance-system/tree/master/admin_site/"
    click TeacherSite "https://github.com/ratheshprabakar/attendance-system/tree/master/teachers_site/"
    click FaceRec "https://github.com/ratheshprabakar/attendance-system/tree/master/teachers_site/tf_files/"
    click Database "https://github.com/ratheshprabakar/attendance-system/blob/master/database.sql"
    click ExcelReports "https://github.com/ratheshprabakar/attendance-system/tree/master/teachers_site/excel/"

    %% Styles
    classDef presentation fill:#b3cde0,stroke:#0a3d62,stroke-width:2px;
    classDef processing fill:#f9e79f,stroke:#b9770e,stroke-width:2px;
    classDef database fill:#d5f5e3,stroke:#229954,stroke-width:2px;
    classDef external fill:#fadbd8,stroke:#d35400,stroke-width:2px;

    class AdminSite,TeacherSite presentation;
    class FaceRec processing;
    class Database database;
    class ExcelReports,EmailService external;
```
