# mahendrasingh2003/project architecture

> Architecture diagram of the GitHub repository mahendrasingh2003/project, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-09-20). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/mahendrasingh2003/project
- Repository: https://github.com/mahendrasingh2003/project

## Overview

##### Project type and purpose
- This is a monolithic full-stack web application for logging employee attendance via facial recognition.
- The README confirms it’s built with Python/Flask, uses OpenCV, dlib, face_recognition and deepface for face-matching, and SQLite for storage.

##### File structure
- Top-level files:
- app.py – the Flask application entry point (routes, controllers, business logic)
- EmployeeDB.db – SQLite database file
- msenv.yml – conda environment spec
- Directories:
- /static – client assets (CSS, JS, audio, training images, CSV output files)
- /templates – Jinja2 HTML templates (login, signup, OTP, record pages, recognition page)
- Patterns:
- MVC-style separation: templates = views, app.py = controller & business logic, EmployeeDB.db = model/data store
- File-based datastore for training images and CSV exports

##### Key insights from README
- Technologies & libraries: Flask, SQLite, OpenCV, dlib, face_recognition, deepface
- Workflows: user signup/login → webcam capture → face encoding/recognition → attendance marking → report generation
- No external microservices or messaging queues—purely server-side monolith

##### Main components
a. Client Layer (Browser)
- Static UI (HTML/CSS/JS in /templates & /static)
- Camera integration via JS to capture images
b. Web Server Layer (Flask app.py)
- HTTP API endpoints for login, signup, reset password, record insertion, recognition
- Controller logic invoking face recognition routines
c. Face Recognition Engine
- OpenCV/dlib preprocessing
- face_recognition & deepface libraries for encoding & matching
d. Data Layer
- SQLite database (EmployeeDB.db storing user profiles & attendance records)
- File storage (/static/TrainingImages for reference face images; /static/records.csv and todayAttendance.csv for exports)
e. External Libraries & Environment
- conda environment (msenv.yml)
- Python runtime
- External dependencies (OpenCV, dlib, face_recognition, deepface)

##### Relationships and data flows
- Browser → Flask HTTP request → Flask Route
- Flask → Database read/write (SQLite queries)
- Flask → Face Recognition Engine (image in → encoding/matching → result)
- Flask → File System for reading training images & writing CSV exports
- Flask → Browser HTTP response / real-time marking feedback

##### Architectural patterns & design principles
- MVC pattern (Views in templates, Controllers in app.py, Model as SQLite)
- Single-process synchronous request handling (no queueing or async microservices)
- Modularization by feature: authentication, attendance, reporting, recognition
- Separation of concerns: static assets served separately from dynamic routes

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Client Layer"
        Browser["Browser"]:::ui
        Static["Static Assets"]:::ui
        Templates["HTML Templates"]:::ui
    end

    subgraph "Web Server Layer"
        App["Flask Server\n(app.py)"]:::server
        Recognition["Face Recognition Module"]:::server
        Env["Conda Env & Python"]:::lib
    end

    subgraph "Recognition Engine"
        OpenCV["OpenCV / dlib"]:::lib
        FR["face_recognition & deepface"]:::lib
    end

    subgraph "Data Layer"
        DB["SQLite DB\n(EmployeeDB.db)"]:::storage
        Training["Training Images\n(static/TrainingImages/)"]:::storage
        CSV1["records.csv"]:::storage
        CSV2["todayAttendance.csv"]:::storage
    end

    README["README.md"]:::doc

    Browser -->|"HTTP Requests"| App
    App -->|"HTTP Responses"| Browser
    App -->|"Serve files"| Static
    App -->|"Render views"| Templates

    App -->|"invoke face recognition"| Recognition
    Recognition -->|"preprocess image"| OpenCV
    Recognition -->|"encode & match"| FR
    OpenCV --> Recognition
    FR --> Recognition
    Recognition --> App

    App -->|"SQL Read/Write"| DB
    App -->|"Read training images"| Training
    App -->|"Write export"| CSV1
    App -->|"Write export"| CSV2

    App --> Env

    README -.-> App

    click Static "https://github.com/mahendrasingh2003/project/tree/main/static/"
    click Templates "https://github.com/mahendrasingh2003/project/tree/main/templates/"
    click App "https://github.com/mahendrasingh2003/project/blob/main/app.py"
    click DB "https://github.com/mahendrasingh2003/project/blob/main/EmployeeDB.db"
    click Training "https://github.com/mahendrasingh2003/project/tree/main/static/TrainingImages/"
    click CSV1 "https://github.com/mahendrasingh2003/project/blob/main/static/records.csv"
    click CSV2 "https://github.com/mahendrasingh2003/project/blob/main/static/todayAttendance.csv"
    click Env "https://github.com/mahendrasingh2003/project/blob/main/msenv.yml"
    click README "https://github.com/mahendrasingh2003/project/blob/main/README.md"

    classDef ui fill:#D0E8FF,stroke:#0288D1,color:#01579B;
    classDef server fill:#E0F2F1,stroke:#00796B,color:#004D40;
    classDef lib fill:#F3E5F5,stroke:#6A1B9A,color:#4A148C;
    classDef storage fill:#FFF3E0,stroke:#E65100,color:#BF360C;
    classDef doc fill:#ECEFF1,stroke:#546E7A,color:#263238;
```
