# rohitbansal2005/face-recognition-attendance-system-software architecture

> Architecture diagram of the GitHub repository rohitbansal2005/face-recognition-attendance-system-software, 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/rohitbansal2005/face-recognition-attendance-system-software
- Repository: https://github.com/rohitbansal2005/face-recognition-attendance-system-software

## Overview

##### Overall Project Type and Purpose
- The system is a comprehensive face recognition application that includes training, real-time recognition, attendance tracking, user authentication (login/registration), and database integration using MySQL. It is built in Python and leverages OpenCV for face detection and recognition as well as Tkinter for its GUI.

##### File Structure
- Top-Level Files: You have files like main.py, login.py, register.py, attendance.py, developer.py, help.py which indicate a multi-module structure handling user interaction (login, registration, help) and specific functionalities (training, recognition, attendance tracking).
- Modules:
- train.py – Handles the training part, processing captured images to train the face recognizer.
- face_recognition.py – Implements the real-time face detection and recognition.
- student.py, attendance.py – Likely handle student information management and attendance logging.
- Resources and Data:
- Data/ directory – Stores captured face images.
- college_images/ – Contains UI images.
- XML files (haarcascade_frontalface_default.xml, classifier.xml) – Used for face detection (Haar cascades) and storing the classifier/model data.
- Dependencies: The requirements file and usage of MySQL, OpenCV, Pillow, and Tkinter indicate dependencies that play significant roles in the architecture.

##### README for Additional Insights
- It also describes the technical details such as image capture, grayscale conversion, detected face extraction, LBPH algorithm usage for recognition, and database updates.

##### Main Components and Their Relationships
a. User Interface (UI) Layer:
- Comprised of Tkinter-based GUIs for login, registration, and the main application interface.
- Components: Login Screen (login.py), Registration Screen (register.py), Student Management, and Attendance Screens.

b. Camera/Input and Image Capture Module:
- Manages access to the webcam and image capture for both training and live recognition.
- Involved in both train.py (for capturing and saving training data) and face_recognition.py (for real-time capture).

c. Face Detection Module:
- Uses OpenCV with a Haar Cascade (haarcascade_frontalface_default.xml) to detect faces.
- This module is part of the real-time recognition and the initial preprocessing in training.

d. Face Recognition / Classification Module:
- Involves processing the captured face images, extracting features, and matching against stored training data.
- Outputs a confidence score for detection results.

e. Training Module:
- Processes stored images (in the Data folder) and trains the classifier.
- Updates classifier.xml or another storage mechanism with trained model data.

f. Database Layer:
- A MySQL database handling student records and attendance.
- Handles secure authentication, record updates (attendance marking), and possibly student details via student.py.

g. Auxiliary Modules:
- Additional support scripts like attendance.py, developer.py, and help.py which might log events, provide support functions, or developer utilities.

##### Instructing the Principal Software Engineer
- From the “Login Module” → “Main UI” → “Face Capture Module” → “Face Detection Module” → “Face Recognition Module” → “MySQL Database Update” → “Result Display on UI.”
- Technology choices (Python, OpenCV, Tkinter, MySQL) next to the respective components.
- Secure authentication and database connection practices as per the README.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Start Node
    start("Start/Initialization"):::start

    %% UI Layer Subgraph
    subgraph "UI Layer"
        uiLogin("Login Screen"):::ui
        uiRegister("Registration Screen"):::ui
        uiMain("Main Application UI"):::ui
        uiAttendance("Attendance Screen"):::ui
        uiHelp("Help & Support"):::ui
        uiDeveloper("Developer Info"):::ui
    end

    %% Camera/Input Module Subgraph
    subgraph "Camera/Input Module"
        cameraWebcam("Webcam/Video Capture"):::camera
    end

    %% Processing & Recognition Subgraph
    subgraph "Processing and Recognition"
        fd("Face Detection (Haar Cascade)"):::faceDet
        fr("Face Recognition (LBPH)"):::faceRec
    end

    %% Training Module Subgraph
    subgraph "Training Module"
        trainProc("Training Process"):::train
        faceImages("Captured Face Images"):::trainImg
    end

    %% Classifier Model Node
    classifierModel("Trained Classifier Model"):::classifier

    %% Database Layer Subgraph
    subgraph "Database Layer"
        db("MySQL Database (Students & Attendance)"):::db
    end

    %% CSV Backup Files (connected to Database)
    csv1("student.csv"):::db
    csv2("jk.csv"):::db
    csv3("rk.csv"):::db
    csv4("rohit.csv"):::db

    %% Connections
    start -->|"initialize"| uiLogin
    uiLogin -->|"authenticate"| uiMain
    uiRegister -->|"register_user"| uiMain
    uiMain -->|"select_action"| cameraWebcam

    cameraWebcam -->|"for_training"| trainProc
    cameraWebcam -->|"for_recognition"| fd

    trainProc --> faceImages
    trainProc -->|"update_model"| classifierModel

    fd -->|"detect_face"| fr
    fr -->|"update_attendance"| db
    db -->|"send_response"| uiMain

    %% Connect CSV backups to Database
    db --- csv1
    db --- csv2
    db --- csv3
    db --- csv4

    %% Class Definitions and Colors
    classDef ui fill:#f9c,stroke:#333,stroke-width:2px;
    classDef camera fill:#ff9,stroke:#333,stroke-width:2px;
    classDef faceDet fill:#9f9,stroke:#333,stroke-width:2px;
    classDef faceRec fill:#9ff,stroke:#333,stroke-width:2px;
    classDef train fill:#fc9,stroke:#333,stroke-width:2px;
    classDef trainImg fill:#c9f,stroke:#333,stroke-width:2px;
    classDef classifier fill:#ccf,stroke:#333,stroke-width:2px;
    classDef db fill:#f99,stroke:#333,stroke-width:2px;
    classDef start fill:#9fc,stroke:#333,stroke-width:2px;

    %% Click Events for UI Layer
    click uiLogin "https://github.com/rohitbansal2005/face-recognition-attendance-system-software/blob/main/login.py"
    click uiRegister "https://github.com/rohitbansal2005/face-recognition-attendance-system-software/blob/main/register.py"
    click uiMain "https://github.com/rohitbansal2005/face-recognition-attendance-system-software/blob/main/main.py"
    click uiAttendance "https://github.com/rohitbansal2005/face-recognition-attendance-system-software/blob/main/attendance.py"
    click uiHelp "https://github.com/rohitbansal2005/face-recognition-attendance-system-software/blob/main/help.py"
    click uiDeveloper "https://github.com/rohitbansal2005/face-recognition-attendance-system-software/blob/main/developer.py"

    %% Click Events for Camera/Input Module
    click cameraWebcam "https://github.com/rohitbansal2005/face-recognition-attendance-system-software/blob/main/face_recognition.py"

    %% Click Events for Training Module
    click trainProc "https://github.com/rohitbansal2005/face-recognition-attendance-system-software/blob/main/train.py"
    click faceImages "https://github.com/rohitbansal2005/face-recognition-attendance-system-software/tree/main/Data/"

    %% Click Events for Face Detection and Recognition Modules
    click fd "https://github.com/rohitbansal2005/face-recognition-attendance-system-software/blob/main/haarcascade_frontalface_default.xml"
    click fr "https://github.com/rohitbansal2005/face-recognition-attendance-system-software/blob/main/face_recognition.py"
    click classifierModel "https://github.com/rohitbansal2005/face-recognition-attendance-system-software/blob/main/classifier.xml"

    %% Click Events for Database Layer and Backup Files
    click db "https://github.com/rohitbansal2005/face-recognition-attendance-system-software/blob/main/student.py"
    click db "https://github.com/rohitbansal2005/face-recognition-attendance-system-software/blob/main/attendance.py"
    click csv1 "https://github.com/rohitbansal2005/face-recognition-attendance-system-software/blob/main/student.csv"
    click csv2 "https://github.com/rohitbansal2005/face-recognition-attendance-system-software/blob/main/jk.csv"
    click csv3 "https://github.com/rohitbansal2005/face-recognition-attendance-system-software/blob/main/rk.csv"
    click csv4 "https://github.com/rohitbansal2005/face-recognition-attendance-system-software/blob/main/rohit.csv"

    %% Click Events for Auxiliary Modules are covered in UI Layer (developer.py and help.py)
```
