# nightfury217836/digital-facial-recognisation-attendance-system architecture

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

- Interactive diagram: https://gitdiagram.com/nightfury217836/digital-facial-recognisation-attendance-system
- Repository: https://github.com/nightfury217836/digital-facial-recognisation-attendance-system

## Overview

##### Project Type and Purpose
- This is a full-stack, web-based attendance management system using facial recognition.
- Purpose: automate attendance recording via real-time computer vision and AI; provide an admin dashboard for user and record management.

##### File Structure
- app.py: main Flask application (HTTP routes, controller logic).
- model.py: facial recognition and ML logic (OpenCV, Mediapipe, RandomForestClassifier).
- static/: client-side assets
- css/style.css
- js/*.js (camera_add_student.js, camera_mark.js, dashboard.js)
- images/
- templates/: Flask Jinja2 HTML views (index, add_student, mark_attendance, attendance_record).
- README.md: describes features, tech stack (Flask, Python, OpenCV, SQLite3, HTML/CSS/JS).

##### README for Insights
- Architecture hints: browser UI ↔ Flask API ↔ ML model ↔ SQLite database.
- Optional external services: email/SMS APIs.

##### Main Components & Their Interactions
a. Frontend (Browser)
- Static assets (HTML, CSS, JS) loaded from Flask under /static and /templates
- JS modules capture camera feed, call backend endpoints via AJAX/fetch
b. Backend (Flask app.py)
- HTTP controllers:
– GET / → index.html
– GET/POST /add_student → add_student.html
– GET/POST /mark_attendance → mark_attendance.html
– GET /attendance_record → attendance_record.html
- Calls model.py functions for face detection/recognition
- CRUD operations on SQLite3 via Python DB API
- Optional integration with Email/SMS APIs for notifications
c. ML Model Layer (model.py)
- Uses OpenCV & Mediapipe to preprocess camera frames
- Uses FaceRecognition library and RandomForestClassifier for identity matching
- Exposes functions: enroll_face(user_id), recognize_faces(frame)
d. Database (SQLite3)
- Tables: users (id, name, facial_data), attendance_records (user_id, timestamp, status)
e. (Optional) External Services
- Email/SMS provider APIs for alerts

##### Architectural Patterns & Design Principles
- MVC-like separation:
- Views: templates/*.html + static assets
- Controllers: Flask routes in app.py
- Model layer: model.py + SQLite
- Modular design: clear separation between face-recognition logic and web server logic.
- Single service deployment: monolithic Flask app, can be containerized or deployed on a VM.

##### Putting It All Together
- Notes on technologies (Flask, OpenCV, SQLite) next to their components.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Layer
    subgraph "Frontend Layer"
        direction TB
        FE_Templates["Templates (HTML Views)"]:::frontend
        subgraph "Templates"
            direction TB
            Index["index.html"]:::frontend
            AddStu["add_student.html"]:::frontend
            MarkAtt["mark_attendance.html"]:::frontend
            Record["attendance_record.html"]:::frontend
        end
        FE_Static["Static Assets"]:::frontend
        subgraph "CSS"
            StyleCSS["style.css"]:::frontend
        end
        subgraph "JavaScript Modules"
            CAM_Add["camera_add_student.js"]:::frontend
            CAM_Mark["camera_mark.js"]:::frontend
            DashJS["dashboard.js"]:::frontend
        end
    end

    %% Backend Layer
    subgraph "Backend Layer"
        direction TB
        FlaskApp["Flask Application (app.py)"]:::backend
    end

    %% ML Subsystem
    subgraph "ML Subsystem"
        direction TB
        Model["model.py"]:::ml
    end

    %% Database
    DB["SQLite3 Database"]:::database

    %% External Services
    subgraph "External Services" 
        style External fill:none,stroke:#999,stroke-dasharray: 5 5
        External["Email/SMS Provider APIs"]:::external
    end

    %% Interactions
    Browser["Browser/Client"]:::frontend
    Browser -->|"HTTP GET/POST"| FlaskApp
    FlaskApp -->|"loads templates/static"| FE_Templates
    FlaskApp -->|"/static/css/style.css"| StyleCSS
    FlaskApp -->|"/static/js/*"| CAM_Add
    FlaskApp -->|"/static/js/*"| CAM_Mark
    FlaskApp -->|"/static/js/*"| DashJS

    %% Use Cases
    Browser -->|"Enroll Request\n(image frame)"| FlaskApp
    FlaskApp -->|"enroll_face(user_id)"| Model
    Model -->|"INSERT users"| DB

    Browser -->|"Mark Request\n(image frame)"| FlaskApp
    FlaskApp -->|"recognize_faces(frame)"| Model
    Model -->|"SELECT users"| DB
    FlaskApp -->|"INSERT attendance_records"| DB
    FlaskApp -->|"send notification"| External

    Browser -->|"View Records"| FlaskApp
    FlaskApp -->|"SELECT attendance_records"| DB
    DB -->|"records data"| Browser

    %% Click Events
    click Index "https://github.com/nightfury217836/digital-facial-recognisation-attendance-system/blob/main/templates/index.html"
    click AddStu "https://github.com/nightfury217836/digital-facial-recognisation-attendance-system/blob/main/templates/add_student.html"
    click MarkAtt "https://github.com/nightfury217836/digital-facial-recognisation-attendance-system/blob/main/templates/mark_attendance.html"
    click Record "https://github.com/nightfury217836/digital-facial-recognisation-attendance-system/blob/main/templates/attendance_record.html"
    click StyleCSS "https://github.com/nightfury217836/digital-facial-recognisation-attendance-system/blob/main/static/css/style.css"
    click CAM_Add "https://github.com/nightfury217836/digital-facial-recognisation-attendance-system/blob/main/static/js/camera_add_student.js"
    click CAM_Mark "https://github.com/nightfury217836/digital-facial-recognisation-attendance-system/blob/main/static/js/camera_mark.js"
    click DashJS "https://github.com/nightfury217836/digital-facial-recognisation-attendance-system/blob/main/static/js/dashboard.js"
    click FlaskApp "https://github.com/nightfury217836/digital-facial-recognisation-attendance-system/blob/main/app.py"
    click Model "https://github.com/nightfury217836/digital-facial-recognisation-attendance-system/blob/main/model.py"
    click README "https://github.com/nightfury217836/digital-facial-recognisation-attendance-system/blob/main/README.md"

    %% Styles
    classDef frontend fill:#D0E7FF,stroke:#0366D6,color:#0366D6
    classDef backend fill:#D6F5D6,stroke:#28A745,color:#28A745
    classDef ml fill:#FFE5B4,stroke:#FF8C00,color:#FF8C00
    classDef database fill:#FFF3B0,stroke:#E2A300,color:#E2A300
    classDef external fill:#F0F0F0,stroke:#999,color:#555
```
