# akshay0712-dev/biometric- architecture

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

- Interactive diagram: https://gitdiagram.com/akshay0712-dev/biometric-
- Repository: https://github.com/akshay0712-dev/biometric-

## Overview

##### Project type and purpose
- FaceLog is a full-stack, biometric-based attendance management system.
- Purpose: allow admins to upload attendance files, process biometric data, match it to users, and update attendance records in real time via a responsive web dashboard.

##### File structure
- Top-level directories:
- Frontend/ – React + TailwindCSS single-page application
- Backend/ – Node.js + Express REST API
- Backend substructure follows an MVC-style pattern:
- src/controllers – business logic for admin, user, biometric endpoints
- src/models – Mongoose schemas for User, Biometric, Performance
- src/routes – route definitions for user and admin APIs
- src/middlewares – JWT auth, file upload (multer)
- src/utils – custom error/response wrappers, async handler, Cloudinary config
- public/ – static assets placeholder
- Frontend substructure:
- src/components – UI components (login, register, admin dashboard, profile, reset password, etc.)
- src/utils – className helper
- index.html + 404.html for client-side routing
- Config/build files: package.json, tailwind.config.js, postcss.config.js, render.yaml (deployment), .env variables.

##### README for additional insights
- Data flow: Excel upload → backend Excel parsing → biometric matching → MongoDB update
- Authentication: JWT access & refresh tokens, bcrypt for password hashing
- External service: Cloudinary for uploading/storing profile images or attendance files

##### Main components and interactions
a. Components
1) Browser / Admin Client (React)
2) Frontend Server (served by Vite/dev server or static host)
3) Backend API Server (Express.js)
4) MongoDB Atlas (cloud database)
5) Cloudinary (external file storage)
6) Authentication subsystem (JWT issuance & verification)
b. Relationships & Data Flow
- Admin Client ↔ Frontend API layer (HTTP/WebSocket if used)
- Frontend → Backend (REST calls for login, register, upload, fetch records)
- Backend ↔ MongoDB (CRUD via Mongoose models)
- Backend ↔ Cloudinary (upload/download attendance images/files)
- Backend uses middlewares (auth, multer) before controllers
- Controllers call utility modules (ApiError, ApiResponse)
c. Architectural patterns & principles
- RESTful API design with versioned endpoints (e.g., /api/v1/users)
- MVC-style separation (routes → controllers → models)
- Middleware chain for cross-cutting concerns (auth, file parsing)
- Utility abstraction for consistent error/response handling
d. Key technologies/frameworks
- Frontend: React, TailwindCSS, Vite (npm scripts)
- Backend: Node.js, Express.js, Mongoose, Multer, Cloudinary SDK
- Auth: JWT (access/refresh tokens), bcrypt
- Database: MongoDB Atlas

– Auth Middleware → Controllers → Models
– File Upload Middleware → Biometric Controller
– Utilities (ApiError, ApiResponse)
- Client → API: login/register, upload attendance, fetch records
- API → MongoDB: user queries, attendance updates
- API → Cloudinary: file upload
- API → Client: JSON responses including JWT tokens

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Client Layer
    subgraph "Client Layer"
        SPA["React SPA"]:::frontend
        Entry["Entry Point (main.jsx)"]:::frontend
        Components["UI Components"]:::frontend
        HTML1["HTML Templates (index.html)"]:::frontend
        HTML2["HTML Templates (404.html)"]:::frontend
        TailwindConfig["tailwind.config.js"]:::frontend
        PostcssConfig["postcss.config.js"]:::frontend
        Pkg["package.json"]:::frontend
    end

    %% API Server Layer
    subgraph "API Server (Express)"
        API["Express API Server"]:::backend

        subgraph "Routes"
            AdminRoutes["admin.routes.js"]:::backend
            UserRoutes["user.routes.js"]:::backend
        end

        subgraph "Middlewares"
            Auth["Auth Middleware"]:::backend
            Multer["File-Upload Middleware"]:::backend
        end

        subgraph "Controllers"
            AdminCtrl["Admin Controller"]:::backend
            BiometricCtrl["Biometric Controller"]:::backend
            UserCtrl["User Controller"]:::backend
        end

        subgraph "Models"
            UserModel["User Model"]:::backend
            BiometricModel["Biometric Model"]:::backend
            PerfModel["Performance Model"]:::backend
        end

        subgraph "Utilities"
            ApiErr["ApiError"]:::backend
            ApiResp["ApiResponse"]:::backend
            AsyncH["asyncHandler"]:::backend
            CloudUtil["Cloudinary Config"]:::backend
        end

        DBConn["DB Connection"]:::backend
        Static["Static Assets Placeholder"]:::backend
        Deploy["Deployment & Env Config"]:::backend
    end

    %% External Services
    DB["MongoDB Atlas"]:::database
    Cloud["Cloudinary"]:::external

    %% Connections
    SPA -->|HTTP/JSON| API
    API -->|REST Calls| AdminRoutes
    API -->|REST Calls| UserRoutes
    AdminRoutes -->|routes to| Controllers
    UserRoutes -->|routes to| Controllers
    API -->|CRUD| DB
    API -->|upload/download| Cloud
    API -->|issues/verifies JWT| Auth
    Auth -->|protects| Controllers
    Multer -->|file parsing| Controllers
    Controllers -->|DB ops| Models
    Controllers -->|use utils| Utilities
    DBConn -->|connects| DB
    API -->|serves| Static
    Deploy -->|configures| API

    %% Click Events
    click SPA "https://github.com/akshay0712-dev/biometric-/tree/main/Frontend/src"
    click Entry "https://github.com/akshay0712-dev/biometric-/blob/main/Frontend/src/main.jsx"
    click Components "https://github.com/akshay0712-dev/biometric-/tree/main/Frontend/src/components"
    click HTML1 "https://github.com/akshay0712-dev/biometric-/blob/main/Frontend/index.html"
    click HTML2 "https://github.com/akshay0712-dev/biometric-/blob/main/Frontend/404.html"
    click TailwindConfig "https://github.com/akshay0712-dev/biometric-/blob/main/Frontend/tailwind.config.js"
    click PostcssConfig "https://github.com/akshay0712-dev/biometric-/blob/main/Frontend/postcss.config.js"
    click Pkg "https://github.com/akshay0712-dev/biometric-/blob/main/Frontend/package.json"
    click API "https://github.com/akshay0712-dev/biometric-/blob/main/Backend/src/index.js"
    click AdminRoutes "https://github.com/akshay0712-dev/biometric-/blob/main/Backend/src/routes/admin.routes.js"
    click UserRoutes "https://github.com/akshay0712-dev/biometric-/blob/main/Backend/src/routes/user.routes.js"
    click Auth "https://github.com/akshay0712-dev/biometric-/blob/main/Backend/src/middlewares/auth.middleware.js"
    click Multer "https://github.com/akshay0712-dev/biometric-/blob/main/Backend/src/middlewares/multer.middleware.js"
    click AdminCtrl "https://github.com/akshay0712-dev/biometric-/blob/main/Backend/src/controllers/admin.controllerrs.js"
    click BiometricCtrl "https://github.com/akshay0712-dev/biometric-/blob/main/Backend/src/controllers/biometric.controllers.js"
    click UserCtrl "https://github.com/akshay0712-dev/biometric-/blob/main/Backend/src/controllers/user.controllers.js"
    click UserModel "https://github.com/akshay0712-dev/biometric-/blob/main/Backend/src/models/user.model.js"
    click BiometricModel "https://github.com/akshay0712-dev/biometric-/blob/main/Backend/src/models/biometric.model.js"
    click PerfModel "https://github.com/akshay0712-dev/biometric-/blob/main/Backend/src/models/Performance.model.js"
    click DBConn "https://github.com/akshay0712-dev/biometric-/blob/main/Backend/src/db/index.js"
    click CloudUtil "https://github.com/akshay0712-dev/biometric-/blob/main/Backend/src/utils/cloudinary.js"
    click ApiErr "https://github.com/akshay0712-dev/biometric-/blob/main/Backend/src/utils/ApiError.js"
    click ApiResp "https://github.com/akshay0712-dev/biometric-/blob/main/Backend/src/utils/ApiResponse.js"
    click AsyncH "https://github.com/akshay0712-dev/biometric-/blob/main/Backend/src/utils/asyncHandler.js"
    click Static "https://github.com/akshay0712-dev/biometric-/blob/main/Backend/public/temp/.gitkeep"
    click Deploy "https://github.com/akshay0712-dev/biometric-/blob/main/Backend/render.yaml"

    %% Styles
    classDef frontend fill:#E0F7FA,stroke:#006064,color:#000;
    classDef backend fill:#E3F2FD,stroke:#0D47A1,color:#000;
    classDef database fill:#E8F5E9,stroke:#2E7D32,color:#000;
    classDef external fill:#FFF3E0,stroke:#EF6C00,color:#000;
```
