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

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

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

## Overview

##### Project type and purpose
- This is a lightweight full-stack web application for automated attendance tracking using face recognition.
- The user visits a web page, the system captures a live camera feed, detects and recognizes faces, and records attendance.

##### File structure
- Top-level files:
- app.py – the main Flask application, routes, and orchestration
- haarcascade_frontalface_default.xml – OpenCV face-detection model
- README.md – high-level description
- templates/home.html – frontend UI served by Flask

##### README for additional insights
- No explicit database schema called out, but screenshot implies real-time detection UI.
- Likely stores attendance in CSV or simple SQLite (we’ll show “Data Storage” as a component).

##### Main components and interactions
a. Client (Web Browser)
– Renders home.html, streams video via JavaScript or HTML5 canvas
– Sends “start capture” requests to Flask
b. Web Server (Flask app.py)
– Route “/” serves UI
– Route “/recognize” handles video frames or image uploads
– Orchestrates face detection & recognition workflows
c. Face Detection Module (OpenCV + haarcascade)
d. Face Recognition Module (e.g. LBPH or FaceNet)
– Compares detected faces against known embeddings
e. Attendance Manager
– Applies business rules: timestamp, duplicate checks
f. Data Storage
– CSV file or SQLite database containing “user_id, name, timestamp”
g. Hardware & External Dependencies
– Webcam or camera feed
– OpenCV library

Data Flow:
1. Browser → Flask “/recognize” (frame/image)
2. Flask → Detection Module → face coordinates
3. Flask → Recognition Module → match ID
4. Recognition result → Attendance Manager → Data Storage
5. Flask → Browser (current attendance view/confirmation)

##### Architectural patterns & design principles
- Monolithic MVC:
- Model = Data Storage
- View = home.html
- Controller = Flask routes + manager code
- Separation of concerns: detection vs. recognition vs. data management

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Title
    title["Face Recognition Attendance System Architecture"]

    %% Client Side
    subgraph "Client Side"
        Browser["Browser"]:::ui
        Home["home.html"]:::ui
        Camera["Camera"]:::io
    end

    %% Server Side
    subgraph "Server Side"
        Flask["Flask app (app.py)"]:::server
        subgraph "Processing Modules"
            Detection["Face Detection Module"]:::processing
            Recognition["Face Recognition Module"]:::processing
            Attendance["Attendance Manager"]:::processing
        end
        DataStorage["Data Storage (CSV/SQLite)"]:::storage
    end

    %% External Documentation
    Doc["README.md"]:::doc

    %% Connections
    Browser -->|"Loads UI"| Home
    Browser -->|"Streams Frame"| Flask
    Camera -->|"Video Feed"| Detection
    Flask -->|"POST /recognize"| Detection
    Detection -->|"face coordinates"| Recognition
    Recognition -->|"match ID"| Attendance
    Attendance -->| writes | DataStorage
    Flask -->|"Updates View"| Browser
    Doc -.->| references | Flask

    %% Click Events
    click Home "https://github.com/sharmaji27/face-recognition-based-attendance-system/blob/master/templates/home.html"
    click Flask "https://github.com/sharmaji27/face-recognition-based-attendance-system/blob/master/app.py"
    click Detection "https://github.com/sharmaji27/face-recognition-based-attendance-system/blob/master/haarcascade_frontalface_default.xml"
    click Doc "https://github.com/sharmaji27/face-recognition-based-attendance-system/blob/master/README.md"

    %% Styles
    classDef ui fill:#ADD8E6,stroke:#000,stroke-width:1px
    classDef server fill:#90EE90,stroke:#000,stroke-width:1px
    classDef processing fill:#FFA500,stroke:#000,stroke-width:1px
    classDef storage fill:#FFFF00,stroke:#000,stroke-width:1px
    classDef io fill:#F0E68C,stroke:#000,stroke-width:1px
    classDef doc fill:#D3D3D3,stroke:#000,stroke-width:1px
```
