# mohammedsamirmahmoud/attendance-tracking-system-using-computer-vision architecture

> Architecture diagram of the GitHub repository mohammedsamirmahmoud/attendance-tracking-system-using-computer-vision, 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/mohammedsamirmahmoud/attendance-tracking-system-using-computer-vision
- Repository: https://github.com/mohammedsamirmahmoud/attendance-tracking-system-using-computer-vision

## Overview

Based on our analysis of your project’s file tree and the comprehensive README, the project is clearly a modular Attendance Tracking System that leverages computer vision (for face detection and recognition), custom attendance logic, and a Django-based web application to manage employee attendance data. The project is architected into four main modules:

##### Module A – Data Ingestion
- This module is responsible for receiving live video streams (or batches of images) from cameras that are installed at different critical locations.
- It essentially treats each video frame as an image input and sends it to the computer vision processing unit.

##### Module B – Computer Vision Processing (Face Detector & Recognizer)
- It contains various subcomponents (implemented in the Computer_Vision_Module) that run multiple detection algorithms like HAAR, YOLO, YOLO Faces, and finally MTCNN. This shows a progression through different techniques to ultimately achieve optimal face detection.
- Once a face is detected, the module further processes it with face recognition algorithms using CNN-based transfer learning combined with SVM, as detailed in the README. This allows the system to reliably identify employees based on very few registered images.
- This module is divided into:
- B.1 – Detection: Extracting face regions.
- B.2 – Recognition: Classifying and confirming the identity using feature extraction methods and classifiers.

##### Module C – Attendance Logic
- Implemented in the Attendance_Logic_Module, this module is responsible for processing log files generated by the cameras.
- It includes routines for combining logs from all cameras, sorting them by employee name, timestamp, and camera ID; reducing redundant data from multiple cameras; and applying a confidence threshold (e.g., the 5 consecutive frames rule) to ensure accuracy.
- It calculates the duration an employee is present, as well as the “wasted” time spent in non-productive zones (like a fun area).

##### Module D – Web Application (Attendance Admin Panel)
- Built using Django (as evidenced by the Activity_Tracking_Web_App and Attendance_Tracking_System_Using_Computer_Vision directories), this module presents a user-friendly interface to interact with the attendance data.
- It incorporates an admin panel for managing employees, adding photos (for facial recognition training), and performing CRUD operations on employee and activity records.
- The web app connects to a database (likely MySQL, as mentioned in the README) to persist attendance records and related metadata.

A. Identify the Main Components and Their Roles:
- Computer Vision Processing Unit: Represent it as a block that contains both face detection (with its submodules: HAAR, YOLO, YOLO Faces, MTCNN) and face recognition (implemented with CNN, Transfer Learning, SVM).
- Attendance Logic Engine: Represent the module that ingests face recognition output and log files to compute employee attendance metrics.
- Web Application Interface: Represent the Django-based web application, including models for Employee, Activity, Picture, and Test.
- Storage: Represent the database system (MySQL, as noted) and any file-based storage (for storing videos and log files).

- That the Django web application not only retrieves data from the database but also allows for operations (such as retraining using new employee images).

C. Highlight Architectural Patterns / Design Principles:
- A modular, pipeline-based architecture is used—each module (ingestion, computer vision processing, attendance logic, and web interface) is relatively self-contained.
- Separation of concerns (i.e., one module handles CV tasks while another handles business logic and yet another handles web presentation).
- That the system supports extensibility: for example, the face recognition module can be updated or switched to a different algorithm as needed without affecting the attendance logic or web interface.

D. Include Relevant Technologies and Frameworks:
- Django Framework for the web application (Activity_Tracking_Web_App and project settings in Attendance_Tracking_System_Using_Computer_Vision).
- Python scripts and modules used within Computer_Vision_Module for machine learning and image processing.
- MySQL (or similar) as the backend database.
- Virtual environment setup and package requirements (as shown in requirements.txt).

- Incorporate annotation for key flows, such as “Face Detection”, “Feature Extraction”, “Log Processing”, and “Web CRUD Operations”.

F. Visual Elements to Include:
- Clear labels for every component/module.

1. The modular architecture (data ingestion, computer vision, attendance logic, web application).
2. The interactions and dependencies between modules.
3. The underlying technologies and architectural patterns that support scalability, modularity, and accuracy in attendance tracking.

## Diagram (Mermaid)

```mermaid
graph TD
    A["Camera Feeds"]:::camera
    B["Data Ingestion Module"]:::ingestion
    A -->|"video/image streams"| B

    subgraph "Computer Vision Processing"
        subgraph "Detection Submodule"
            DC1["Extract Faces"]:::cv
            DC2["Video Test"]:::cv
        end
        DR["Detection Result"]:::cv
        DC1 -->|"aggregates"| DR
        DC2 -->|"aggregates"| DR
        
        subgraph "Recognition Submodule"
            RC1["SVM Classifier"]:::recognition
            RC2["Get Embeddings"]:::recognition
            RC3["Model Training"]:::recognition
        end
        DR -->|"detected faces"| RC1
        RC1 -->|"features"| RC2
        RC2 -->|"trained model"| RC3
        RR["Recognition Result"]:::cv
        RC3 --> RR
    end
    B -->|"sends frames"| DC1

    RR -->|"recognized data"| L["Attendance Logic Engine"]:::logic
    L -->|"logs & metrics"| DB["MySQL Database"]:::database

    subgraph "Web Application Interface"
        WA1["Activity Tracking Web App"]:::webapp
        WA2["Attendance Tracking System (Django)"]:::webapp
    end
    DB -->|"data retrieval"| WA1
    DB -->|"data retrieval"| WA2

    click DC1 "https://github.com/mohammedsamirmahmoud/attendance-tracking-system-using-computer-vision/blob/master/Computer_Vision_Module/Extract_Faces.py"
    click DC2 "https://github.com/mohammedsamirmahmoud/attendance-tracking-system-using-computer-vision/blob/master/Computer_Vision_Module/Video_Test.py"
    click RC1 "https://github.com/mohammedsamirmahmoud/attendance-tracking-system-using-computer-vision/blob/master/Computer_Vision_Module/SVM_Classifier.py"
    click RC2 "https://github.com/mohammedsamirmahmoud/attendance-tracking-system-using-computer-vision/blob/master/Computer_Vision_Module/Get_Embeddings.py"
    click RC3 "https://github.com/mohammedsamirmahmoud/attendance-tracking-system-using-computer-vision/blob/master/Computer_Vision_Module/Model_Training.py"
    click L "https://github.com/mohammedsamirmahmoud/attendance-tracking-system-using-computer-vision/tree/master/Attendance_Logic_Module"
    click WA1 "https://github.com/mohammedsamirmahmoud/attendance-tracking-system-using-computer-vision/tree/master/Activity_Tracking_Web_App"
    click WA2 "https://github.com/mohammedsamirmahmoud/attendance-tracking-system-using-computer-vision/tree/master/Attendance_Tracking_System_Using_Computer_Vision"

    classDef camera fill:#AED6F1,stroke:#1F618D,stroke-width:2px;
    classDef ingestion fill:#D5F5E3,stroke:#229954,stroke-width:2px;
    classDef cv fill:#FAD7A0,stroke:#C0392B,stroke-width:2px;
    classDef recognition fill:#F9E79F,stroke:#B9770E,stroke-width:2px;
    classDef logic fill:#F5B7B1,stroke:#922B21,stroke-width:2px;
    classDef database fill:#A3E4D7,stroke:#117864,stroke-width:2px;
    classDef webapp fill:#D2B4DE,stroke:#6C3483,stroke-width:2px;
```
