# thinakaranmanokaran/bank_management architecture

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

- Interactive diagram: https://gitdiagram.com/thinakaranmanokaran/bank_management
- Repository: https://github.com/thinakaranmanokaran/bank_management

## Overview

##### Project Type & Purpose
This is a full-stack banking management web application with three user roles (public, user, employee, admin) and face-authentication.
– Frontend: React SPA built with Vite, loads face-API models in the browser for client-side authentication.
– Backend: Node.js/Express REST API with MVC organization (routes → controllers → models), uses JWT and face recognition middleware, persists data via a database.

##### File Structure
– client/: React code (src/, public/models)
- src/pages/*.jsx – UI pages per role
- src/components/ – reusable components (global, user, employee, admin)
- src/contexts/ – React Contexts for state (AccountContext, BalanceContext, etc.)
- public/models/ – TensorFlow.js/face-api.js model shards & manifests
– server/: Express app
- routes/ (adminRoutes.js, userRoutes.js)
- controllers/ (one folder per role & global)
- models/ (database schemas, face model files)
- middlewares/ (authentication, faceAuth, role-based)
- config/ (db.js, dotenv)
- utils/ (JWT helper, password hashes, accountNo generator)
- server.js – application entry point

##### Key README Insight
Minimal README (“# Bank_Management”), so rely on file names and folder structure to infer features:
- FaceAuthentication in public pages & controllers
- Role-based dashboards and actions (deposit, loan, transactions)

##### Main Components
A. Frontend (Browser)
- React SPA (Vite dev/build)
- Loads face-API models from public/models for client-side faceAuth
- Components & Context API manage UI, state, routing
B. Backend (API Server)
- Express.js with route modules for public, user, employee, admin
- Controllers implement business logic (Authentication, FaceAuth, Account, Deposit, Loan, etc.)
- Middlewares enforce JWT auth and face-based checks
C. Database
- Persistent store (e.g., MongoDB or SQL) defined in server/models & accessed via config/db.js
- Collections/tables: Users, Employees, Admin, Accounts, Transactions, Loans, Notifications
D. External/Internal Services
- face-api.js models (client & server) for face detection/recognition
- JWT service for token issuance/validation

##### Component Interactions
1) User ↔ Browser: UI interactions (login, register, face scan)
2) Browser ↔ Backend: REST calls (HTTP/HTTPS) to /api/public, /api/user, /api/employee, /api/admin
- Tokens in Authorization header
- face-auth endpoint for image/frame payload
3) Backend ↔ DB: CRUD operations for accounts, transactions, profiles, loans
4) Backend ↔ face-API models: load models (server/models/global/facemodels) for server-side checks if any

##### Architectural Patterns & Design Principles
– MVC on the server (routes → controllers → models)
– Layered architecture (presentation, application, domain, persistence)
– Context/state management on frontend (React Context)
– Separation of concerns (faceAuth handled via dedicated middleware & controllers)
– RESTful API design with JWT security

Frontend: React, Vite, React Router, Context API, face-api.js, TensorFlow.js
Backend: Node.js, Express.js, dotenv, JWT, bcrypt (passwordHelper), custom utils
DB: MongoDB or relational (via server/config/db.js)
Models: face-api model shards & manifests

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Frontend Layer
    subgraph "Frontend (Browser)"
        direction TB
        SPA["React SPA Core"]:::frontend
        Routing["Routing Module"]:::frontend
        Pages["Pages (public/user/employee/admin)"]:::frontend
        Components["Reusable Components"]:::frontend
        Contexts["Context Providers"]:::frontend
        FModels["Face-API Models"]:::external
    end

    %% Backend Layer
    subgraph "Backend (API Server)"
        direction TB
        Entry["server.js"]:::backend
        ConfigDB["DB & Env Config"]:::backend
        subgraph "Routes"
            direction TB
            UPRoutes["User/Public Routes"]:::backend
            AdminRoutes["Admin Routes"]:::backend
        end
        subgraph "Controllers"
            direction TB
            AuthCtrl["Authentication Controller"]:::backend
            FaceCtrl["FaceAuth Controller"]:::backend
            UserCtrl["User Controllers"]:::backend
            AdminCtrl["Admin Controllers"]:::backend
        end
        subgraph "Middlewares"
            direction TB
            JWTMid["JWT Auth Middleware"]:::backend
            FaceMid["FaceAuth Middleware"]:::backend
        end
        subgraph "Models"
            direction TB
            GlobalModels["Global Models"]:::backend
            UserModels["User Models"]:::backend
            AdminModels["Admin Models"]:::backend
            ServerFModels["Server-side Face Models"]:::external
        end
        subgraph "Utils"
            direction TB
            JWTHelper["JWT Helper"]:::backend
            PWHelper["Password Helper"]:::backend
            AccNoGen["AccountNo Generator"]:::backend
            FaceToken["Face Token Service"]:::backend
        end
    end

    %% Database
    DB[(Database)]:::database

    %% Interactions
    User((User)):::external -->|uses| SPA
    SPA -->|"HTTP(S)/REST"| Entry
    SPA -->|"loads models"| FModels
    Entry -->|init config| ConfigDB
    Entry -->|"mounts routes"| UPRoutes
    Entry -->|"mounts routes"| AdminRoutes
    UPRoutes -->|calls| AuthCtrl
    UPRoutes -->|calls| FaceCtrl
    UPRoutes -->|calls| UserCtrl
    AdminRoutes -->|calls| AuthCtrl
    AdminRoutes -->|calls| AdminCtrl
    AuthCtrl -->|uses| JWTMid
    FaceCtrl -->|uses| FaceMid
    UserCtrl -->|queries| UserModels
    AdminCtrl -->|queries| AdminModels
    AuthCtrl -->|queries| GlobalModels
    FaceCtrl -->|queries| GlobalModels
    UserCtrl -->|CRUD| DB
    AuthCtrl -->|CRUD| DB
    AdminCtrl -->|CRUD| DB
    FaceMid -->|loads models| ServerFModels

    %% Click events
    click SPA "https://github.com/thinakaranmanokaran/bank_management/blob/main/client/src/App.jsx"
    click Routing "https://github.com/thinakaranmanokaran/bank_management/blob/main/client/src/Routes.jsx"
    click Pages "https://github.com/thinakaranmanokaran/bank_management/tree/main/client/src/pages/"
    click Components "https://github.com/thinakaranmanokaran/bank_management/tree/main/client/src/components/"
    click Contexts "https://github.com/thinakaranmanokaran/bank_management/tree/main/client/src/contexts/"
    click FModels "https://github.com/thinakaranmanokaran/bank_management/tree/main/client/public/models/"
    click Entry "https://github.com/thinakaranmanokaran/bank_management/blob/main/server/server.js"
    click ConfigDB "https://github.com/thinakaranmanokaran/bank_management/blob/main/server/config/db.js"
    click UPRoutes "https://github.com/thinakaranmanokaran/bank_management/blob/main/server/routes/userRoutes.js"
    click AdminRoutes "https://github.com/thinakaranmanokaran/bank_management/blob/main/server/routes/adminRoutes.js"
    click AuthCtrl "https://github.com/thinakaranmanokaran/bank_management/blob/main/server/controllers/global/Authentication.js"
    click FaceCtrl "https://github.com/thinakaranmanokaran/bank_management/blob/main/server/controllers/global/FaceAuth.js"
    click UserCtrl "https://github.com/thinakaranmanokaran/bank_management/blob/main/server/controllers/user/Account.js"
    click JWTHelper "https://github.com/thinakaranmanokaran/bank_management/blob/main/server/utils/jwtHelper.js"

    %% Styles
    classDef frontend fill:#D0E8FF,stroke:#4A90E2,color:#003366;
    classDef backend fill:#E0F8E0,stroke:#28A745,color:#0B6623;
    classDef database fill:#FFE5B4,stroke:#FF8C00,color:#8B4513,stroke-width:2px;
    classDef external fill:none,stroke:#999,stroke-dasharray:5 5,color:#666;
```
