# manishkandari9/face-recognition-based-attendance-system architecture

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

- Interactive diagram: https://gitdiagram.com/manishkandari9/face-recognition-based-attendance-system
- Repository: https://github.com/manishkandari9/face-recognition-based-attendance-system

## Overview

##### Project type and purpose
- This is a full-stack web application built with Flask (Python) for taking and recording attendance using face recognition.
- Key purpose: authenticate users (students, teachers, admins), capture faces from live video or images, match against known faces, and record attendance in CSV logs.

##### File structure
- app.py: The Flask application entry point defining routes and controllers.
- instance/users.db: SQLite database storing user credentials and roles.
- static/
- face_recognition_model.pkl: Pretrained face-recognition embeddings model.
- haarcascade_frontalface_default.xml: OpenCV face detector.
- faces/: Directory of labeled face images for each enrolled user.
- templates/: Jinja2 HTML templates for login, signup, and dashboards (student, teacher, admin).
- Attendance/: Output CSV files, one per day, logging user presence.
- README.md: (empty) no architecture described here.

##### README for additional insights
- No content—rely solely on structure and file names.

##### Elements
- HTTP request/response between Browser and Flask.
- SQL queries between Flask and DB.
- Image data flow from Flask to Face Detector → Recognition Model.
- File‐write operations to CSV.
- Web components in blue,
- Data stores (DB, CSV folder) in green,
- Processing services (face detection/recognition) in orange.

##### Detail
- Capturing every key module (login, signup, dashboards, recognition).
- Background tasks (e.g., CSV file rotation per day).
- Where configuration files (XML, PKL) live and are loaded at startup.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Presentation Layer
    subgraph "Presentation" 
        direction TB
        Browser["Browser UI"]:::frontend
        subgraph "Templates" 
            direction TB
            LoginT["login.html"]:::frontend
            SignupT["signup.html"]:::frontend
            ListUsersT["listusers.html"]:::frontend
            StudentDashT["student_dashboard.html"]:::frontend
            TeacherDashT["teacher_dashboard.html"]:::frontend
            AdminDashT["admin_dashboard.html"]:::frontend
        end
    end

    %% Application Logic Layer
    subgraph "Application Logic"
        direction TB
        App["Flask Server\n(app.py)"]:::backend
        subgraph "Authentication Module"
            direction TB
            AuthRoutes["/login, /signup, /users"]:::backend
        end
        subgraph "Dashboard Module"
            direction TB
            StudentDashRoute["Student Dashboard"]:::backend
            TeacherDashRoute["Teacher Dashboard"]:::backend
            AdminDashRoute["Admin Dashboard"]:::backend
        end
        subgraph "Face Recognition Service"
            direction TB
            Detector["Face Detector\n(haar cascade)"]:::processing
            Model["Recognition Model\n(.pkl)"]:::processing
            Images["Enrolled Face Images\n(static/faces/)"]:::processing
        end
        Logger["Attendance Logger\n(CSV Writer)"]:::processing
    end

    %% Data Persistence Layer
    subgraph "Data Persistence"
        direction TB
        DB["SQLite DB\n(instance/users.db)"]:::datastore
        CSVStore["Attendance CSV Store\n(Attendance/)"]:::datastore
    end

    %% Connections
    Browser -->|"HTTP Request"| App
    App -->|"Render Templates"| LoginT
    App --> LoginT
    App --> SignupT
    App --> ListUsersT
    App --> StudentDashT
    App --> TeacherDashT
    App --> AdminDashT
    App -->|SQL Queries| DB
    App -->|Image Frames| Detector
    Detector -->|Detected Faces| Model
    Model -->|Compare Embeddings| Images
    App -->|Record Event| Logger
    Logger -->|Write CSV| CSVStore

    %% Click Events
    click LoginT "https://github.com/manishkandari9/face-recognition-based-attendance-system/blob/main/templates/login.html"
    click SignupT "https://github.com/manishkandari9/face-recognition-based-attendance-system/blob/main/templates/signup.html"
    click ListUsersT "https://github.com/manishkandari9/face-recognition-based-attendance-system/blob/main/templates/listusers.html"
    click StudentDashT "https://github.com/manishkandari9/face-recognition-based-attendance-system/blob/main/templates/student_dashboard.html"
    click TeacherDashT "https://github.com/manishkandari9/face-recognition-based-attendance-system/blob/main/templates/teacher_dashboard.html"
    click AdminDashT "https://github.com/manishkandari9/face-recognition-based-attendance-system/blob/main/templates/admin_dashboard.html"
    click App "https://github.com/manishkandari9/face-recognition-based-attendance-system/blob/main/app.py"
    click DB "https://github.com/manishkandari9/face-recognition-based-attendance-system/blob/main/instance/users.db"
    click Detector "https://github.com/manishkandari9/face-recognition-based-attendance-system/blob/main/static/haarcascade_frontalface_default.xml"
    click Model "https://github.com/manishkandari9/face-recognition-based-attendance-system/blob/main/static/face_recognition_model.pkl"
    click Images "https://github.com/manishkandari9/face-recognition-based-attendance-system/tree/main/static/faces/"
    click CSVStore "https://github.com/manishkandari9/face-recognition-based-attendance-system/tree/main/Attendance/"

    %% Styles
    classDef frontend fill:#D6EAF8,stroke:#3498DB,color:#000
    classDef backend fill:#FADBD8,stroke:#E74C3C,color:#000
    classDef processing fill:#FEF9E7,stroke:#F1C40F,color:#000
    classDef datastore fill:#E8F8F5,stroke:#1ABC9C,color:#000
```
