# bhumilshah26/bankingsystem architecture

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

- Interactive diagram: https://gitdiagram.com/bhumilshah26/bankingsystem
- Repository: https://github.com/bhumilshah26/bankingsystem

## Overview

##### Project type and purpose
- This is a full-stack web banking system (“BSNB Banking System”) with:
- A React.js + Tailwind CSS single-page application (SPA) frontend
- A Node.js + Express.js REST API backend
- A MySQL database (with triggers) for persistence
- JWT-based authentication & bcrypt password hashing
- Email (mailer) integration for password resets

##### File structure
- Top level:
- backend/ – Express app, MVC-style controllers, routes, middleware, database & mailer configs
- frontend/ – React app with pages, components, API helper
- BSNB_Banking_System_Project.pdf, docs
- backend/src:
- config/ (db.js, mailer.js)
- middleware/authMiddleware.js (JWT auth)
- controllers/ (accountControllers.js, transactionControllers.js, transferControllers.js, userControllers.js)
- routes/ (separate router for each resource)
- server.js & app.js (app bootstrap)
- frontend/src:
- pages/ (login, register, dashboard, transaction history, forgot/reset password)
- components/ (modals, loading spinners, navbars, protected route wrapper)
- api.js (centralized HTTP client for REST calls)

##### Key architecture insights from README
- Layered design:
- Express routes → authentication middleware → controllers → database layer
- Database triggers maintain account balances automatically on transaction inserts
- ACID compliance: manual beginTransaction() / commit()/ rollback() around transfers
- React SPA communicates with the backend via JSON over HTTP; uses JWT stored in client (e.g., localStorage)
- Future external integrations: Twilio for OTP, role-based access, token refresh

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Layer
    subgraph "Client Layer"
        User["User (Browser)"]:::external
        SPA["React SPA"]:::client
        Index["index.js"]:::client
        App["App.js"]:::client
        APIHelper["api.js"]:::client
        ProtectedRoute["ProtectedRoute.jsx"]:::client
        TailwindConfig["tailwind.config.js"]:::client
        CSSIndex["index.css"]:::client
        AppCSS["App.css"]:::client
    end

    User -->|interacts with| SPA
    SPA -->|uses| Index
    SPA -->|uses| App
    SPA -->|calls| APIHelper
    SPA -->|protects routes via| ProtectedRoute
    SPA -->|styles via| TailwindConfig
    SPA -->|styles via| CSSIndex
    SPA -->|styles via| AppCSS

    %% Backend Layer
    subgraph "Express API"
        server["server.js"]:::backend
        app["app.js"]:::backend

        subgraph "Routes"
            UR["userRoutes.js"]:::backend
            AR["accountRoutes.js"]:::backend
            TR["transactionRoutes.js"]:::backend
            TRF["transferRoutes.js"]:::backend
        end

        Auth["authMiddleware.js"]:::backend

        subgraph "Controllers"
            UC["userControllers.js"]:::backend
            AC["accountControllers.js"]:::backend
            TC["transactionControllers.js"]:::backend
            TFC["transferControllers.js"]:::backend
        end

        DBConfig["db.js"]:::backend
        MailerConfig["mailer.js"]:::backend
    end

    SPA <-->|HTTP JSON| server
    server --> app
    app --> UR
    app --> AR
    app --> TR
    app --> TRF

    UR --> Auth
    AR --> Auth
    TR --> Auth
    TRF --> Auth

    Auth --> UC
    Auth --> AC
    Auth --> TC
    Auth --> TFC

    UC --> DBConfig
    AC --> DBConfig
    TC --> DBConfig
    TFC --> DBConfig

    UC --> MailerConfig

    %% Database Layer
    DB["MySQL Database\nTables: users, accounts, transactions, transfers\nTrigger: AFTER INSERT ON transactions → update account balance"]:::database
    DBConfig -->|executes queries| DB

    %% External Services
    Mailer["Mailer/SMTP"]:::external
    MailerConfig -->|sends email| Mailer

    Twilio["Twilio OTP Service (future)"]:::external
    Auth -->|future OTP| Twilio

    %% Click Events
    click Index "https://github.com/bhumilshah26/bankingsystem/blob/main/frontend/src/index.js"
    click App "https://github.com/bhumilshah26/bankingsystem/blob/main/frontend/src/App.js"
    click APIHelper "https://github.com/bhumilshah26/bankingsystem/blob/main/frontend/src/api.js"
    click ProtectedRoute "https://github.com/bhumilshah26/bankingsystem/blob/main/frontend/src/pages/ProtectedRoute.jsx"
    click TailwindConfig "https://github.com/bhumilshah26/bankingsystem/blob/main/frontend/tailwind.config.js"
    click CSSIndex "https://github.com/bhumilshah26/bankingsystem/blob/main/frontend/src/index.css"
    click AppCSS "https://github.com/bhumilshah26/bankingsystem/blob/main/frontend/src/App.css"
    click server "https://github.com/bhumilshah26/bankingsystem/blob/main/backend/src/server.js"
    click app "https://github.com/bhumilshah26/bankingsystem/blob/main/backend/src/app.js"
    click UR "https://github.com/bhumilshah26/bankingsystem/blob/main/backend/src/routes/userRoutes.js"
    click AR "https://github.com/bhumilshah26/bankingsystem/blob/main/backend/src/routes/accountRoutes.js"
    click TR "https://github.com/bhumilshah26/bankingsystem/blob/main/backend/src/routes/transactionRoutes.js"
    click TRF "https://github.com/bhumilshah26/bankingsystem/blob/main/backend/src/routes/transferRoutes.js"
    click Auth "https://github.com/bhumilshah26/bankingsystem/blob/main/backend/src/middleware/authMiddleware.js"
    click UC "https://github.com/bhumilshah26/bankingsystem/blob/main/backend/src/controllers/userControllers.js"
    click AC "https://github.com/bhumilshah26/bankingsystem/blob/main/backend/src/controllers/accountControllers.js"
    click TC "https://github.com/bhumilshah26/bankingsystem/blob/main/backend/src/controllers/transactionControllers.js"
    click TFC "https://github.com/bhumilshah26/bankingsystem/blob/main/backend/src/controllers/transferControllers.js"
    click DBConfig "https://github.com/bhumilshah26/bankingsystem/blob/main/backend/src/config/db.js"
    click MailerConfig "https://github.com/bhumilshah26/bankingsystem/blob/main/backend/src/config/mailer.js"

    %% Styles
    classDef client fill:#a7c7e7,stroke:#000;
    classDef backend fill:#b6d7a8,stroke:#000;
    classDef database fill:#f9cb9c,stroke:#000;
    classDef external stroke:#000,stroke-dasharray:5 5;
```
