# mostafakamal22/sprints-mern-e-banking-system architecture

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

- Interactive diagram: https://gitdiagram.com/mostafakamal22/sprints-mern-e-banking-system
- Repository: https://github.com/mostafakamal22/sprints-mern-e-banking-system

## Overview

##### Project type and purpose
- This is a Full-Stack MERN (MongoDB, Express.js, React, Node.js) E-Banking system.
- Purpose: Allow end users to register, log in, manage accounts (deposit, withdraw, transfer), and allow admins/owners to review and approve account requests, manage users, and monitor transactions via a dashboard.

##### File structure
- Top level divides into Backend/ and Frontend/.
- Backend follows an MVC-style layout:
- config (DB connection, CORS)
- controllers (account, accountRequest, admin, user)
- middlewares (authentication, authorization, rate limiting, notifications)
- models (Mongoose schemas for accounts, requests, users, admins, notifications)
- routes (Express routers per resource)
- server.js (app entrypoint)
- Frontend is a React Vite project using Tailwindcss and Redux Toolkit:
- src/components (feature-based UI components for account flows, admin flows, forms, shared UI)
- src/state (Redux slices + async services for User Auth, Admin Auth, Account, AccountRequests, etc.)
- src/views (route-level pages for guest, user, admin)
- main.jsx (React entrypoint)
- Build/deployment files: Procfile (Render), .babelrc, vite.config.js, tailwind.config.js

##### README for additional insights
- Confirms MERN stack, JWT security, responsive Tailwind UI, admin/public API for first owner creation, environment-based API URL configuration.
- Usage instructions hint at two logical API entrypoints: /api/users and /api/admins and account routes under /api/account.

##### Elements
- Clear labeled rectangles for each logical component (UI, Store, HTTP Client, API Server, DB).
- UI → Redux Actions → Services → API → Middleware → Controllers → DB → back to UI
- Blue for frontend modules, green for backend modules, orange for the database.

##### Be detailed and capture essential elements
- Frontend: Components, State Management, API Layer
- Backend: Routing, Middleware, Business Logic (Controllers/Helpers), Data Access (Models)
- Cross-component concerns like auth, notifications, and rate limiting as separate middleware blocks.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Layer
    subgraph "Frontend (React SPA)"
        direction TB
        UI["UI Components"]:::frontend
        Views["Route-Level Pages"]:::frontend
        Store["Redux Store"]:::frontend
        Slices["Redux Slices & Async Services"]:::frontend
        APIClient["HTTP Client Modules"]:::frontend
        UI -->|renders| Views
        Views -->|dispatch| Store
        Store -->|dispatch| Slices
        Slices -->|call| APIClient
    end

    %% Backend Layer
    subgraph "Backend (Express API)"
        direction TB
        Server["Express API Server"]:::backend
        subgraph "Configuration"
            DBConfig["MongoDB Connection"]:::config
            CORSConfig["CORS Settings"]:::config
        end
        subgraph "Middlewares"
            AuthUser["User Auth Middlewares"]:::middleware
            AuthAdmin["Admin Auth Middlewares"]:::middleware
            RateLimit["Rate Limiting"]:::middleware
            Notify["Notification Dispatch"]:::middleware
            AccountChecks["Account Checks"]:::middleware
            ReqChecks["AccountRequest Validation"]:::middleware
        end
        subgraph "Controllers"
            UsersCtrl["UsersController"]:::controller
            AdminsCtrl["AdminsController"]:::controller
            AccountCtrl["AccountController"]:::controller
            ReqCtrl["AccountRequestController"]:::controller
        end
        subgraph "Routes"
            UserRoutes["User Routes"]:::route
            AdminRoutes["Admin Routes"]:::route
            AccountRoutes["Account Routes"]:::route
            ReqRoutes["AccountRequest Routes"]:::route
        end
        subgraph "Models"
            UserModel["User Model"]:::model
            AdminModel["Admin Model"]:::model
            AccountModel["Account Model"]:::model
            ReqModel["AccountRequest Model"]:::model
            NotifyModel["Notification Model"]:::model
        end
        Server -->|uses| DBConfig
        Server -->|uses| CORSConfig
        Server -->|applies| AuthUser
        Server -->|applies| AuthAdmin
        Server -->|applies| RateLimit
        Server -->|applies| Notify
        Server -->|applies| AccountChecks
        Server -->|applies| ReqChecks
        Server -->|routes| UserRoutes
        Server -->|routes| AdminRoutes
        Server -->|routes| AccountRoutes
        Server -->|routes| ReqRoutes

        UserRoutes -->|control| UsersCtrl
        AdminRoutes -->|control| AdminsCtrl
        AccountRoutes -->|control| AccountCtrl
        ReqRoutes -->|control| ReqCtrl

        UsersCtrl -->|CRUD| UserModel
        AdminsCtrl -->|CRUD| AdminModel
        AccountCtrl -->|CRUD| AccountModel
        ReqCtrl -->|CRUD| ReqModel
        Notify -->|persist| NotifyModel
    end

    %% Database
    DB["MongoDB Cluster\n(users, admins, accounts,\naccountRequests, notifications)"]:::db

    %% Interactions
    UI -->|HTTP requests| Server
    Server -->|queries| DB
    DB -->|responses| Server
    Server -->|HTTP responses| UI

    %% Deployment / Environment
    subgraph "Env / Deployment"
        Proc["Procfile"]:::config
        Vite["vite.config.js"]:::config
        Tailwind["tailwind.config.js"]:::config
        Proc -.->|deploys| Server
        Vite -.->|builds| UI
        Tailwind -.->|styles| UI
    end

    %% Click Events
    click UI "https://github.com/mostafakamal22/sprints-mern-e-banking-system/tree/main/Frontend/src/components"
    click Views "https://github.com/mostafakamal22/sprints-mern-e-banking-system/tree/main/Frontend/src/views"
    click Store "https://github.com/mostafakamal22/sprints-mern-e-banking-system/blob/main/Frontend/src/state/store/store.js"
    click Slices "https://github.com/mostafakamal22/sprints-mern-e-banking-system/blob/main/Frontend/src/state/features/User/Auth/authSlice.js"
    click Slices "https://github.com/mostafakamal22/sprints-mern-e-banking-system/blob/main/Frontend/src/state/features/User/Auth/authServices.js"
    click Slices "https://github.com/mostafakamal22/sprints-mern-e-banking-system/blob/main/Frontend/src/state/features/Account/accountSlice.js"
    click Slices "https://github.com/mostafakamal22/sprints-mern-e-banking-system/blob/main/Frontend/src/state/features/Account/accountServices.js"
    click Slices "https://github.com/mostafakamal22/sprints-mern-e-banking-system/blob/main/Frontend/src/state/features/Admin/Auth/adminAuthSlice.js"
    click Slices "https://github.com/mostafakamal22/sprints-mern-e-banking-system/blob/main/Frontend/src/state/features/Admin/Auth/adminAuthServices.js"
    click Slices "https://github.com/mostafakamal22/sprints-mern-e-banking-system/blob/main/Frontend/src/state/features/Admin/AccountRequests/accountRequestsSlice.js"
    click Slices "https://github.com/mostafakamal22/sprints-mern-e-banking-system/blob/main/Frontend/src/state/features/Admin/AccountRequests/accountRequestsServices.js"
    click Slices "https://github.com/mostafakamal22/sprints-mern-e-banking-system/blob/main/Frontend/src/state/features/Admin/UsersActions/usersSlice.js"
    click Slices "https://github.com/mostafakamal22/sprints-mern-e-banking-system/blob/main/Frontend/src/state/features/Admin/UsersActions/usersServices.js"
    click Slices "https://github.com/mostafakamal22/sprints-mern-e-banking-system/blob/main/Frontend/src/state/features/Admin/Owner/ownerSlice.js"
    click Slices "https://github.com/mostafakamal22/sprints-mern-e-banking-system/blob/main/Frontend/src/state/features/Admin/Owner/ownerServices.js"
    click main "https://github.com/mostafakamal22/sprints-mern-e-banking-system/blob/main/Frontend/src/main.jsx"
    click App "https://github.com/mostafakamal22/sprints-mern-e-banking-system/blob/main/Frontend/src/App.jsx"
    click Server "https://github.com/mostafakamal22/sprints-mern-e-banking-system/blob/main/Backend/server.js"
    click DBConfig "https://github.com/mostafakamal22/sprints-mern-e-banking-system/blob/main/Backend/config/db.js"
    click CORSConfig "https://github.com/mostafakamal22/sprints-mern-e-banking-system/blob/main/Backend/config/corsConfig.js"
    click AuthUser "https://github.com/mostafakamal22/sprints-mern-e-banking-system/blob/main/Backend/middlewares/userMiddleware/authUsersMiddleware.js"
    click AuthUser "https://github.com/mostafakamal22/sprints-mern-e-banking-system/blob/main/Backend/middlewares/userMiddleware/checkUserStatus.js"
    click AuthAdmin "https://github.com/mostafakamal22/sprints-mern-e-banking-system/blob/main/Backend/middlewares/adminMiddlewares/authAdminsMiddleware.js"
    click AuthAdmin "https://github.com/mostafakamal22/sprints-mern-e-banking-system/blob/main/Backend/middlewares/adminMiddlewares/roleAuthMiddleware.js"
    click RateLimit "https://github.com/mostafakamal22/sprints-mern-e-banking-system/blob/main/Backend/middlewares/rateLimitMiddleware/rateLimitMiddleware.js"
    click Notify "https://github.com/mostafakamal22/sprints-mern-e-banking-system/blob/main/Backend/middlewares/notificationMiddleware/sendNotificationMiddleware.js"
    click AccountChecks "https://github.com/mostafakamal22/sprints-mern-e-banking-system/blob/main/Backend/middlewares/accountMiddlewares/checkAccount.js"
    click AccountChecks "https://github.com/mostafakamal22/sprints-mern-e-banking-system/blob/main/Backend/middlewares/accountMiddlewares/checkBalance.js"
    click ReqChecks "https://github.com/mostafakamal22/sprints-mern-e-banking-system/blob/main/Backend/middlewares/accountRequestMiddlewares/CheckExistingAccountRequest.js"
    click UsersCtrl "https://github.com/mostafakamal22/sprints-mern-e-banking-system/blob/main/Backend/controllers/usersControllers.js"
    click AdminsCtrl "https://github.com/mostafakamal22/sprints-mern-e-banking-system/blob/main/Backend/controllers/adminsControllers.js"
    click AccountCtrl "https://github.com/mostafakamal22/sprints-mern-e-banking-system/blob/main/Backend/controllers/accountController.js"
    click ReqCtrl "https://github.com/mostafakamal22/sprints-mern-e-banking-system/blob/main/Backend/controllers/accountRequestController.js"
    click UserRoutes "https://github.com/mostafakamal22/sprints-mern-e-banking-system/blob/main/Backend/routes/usersRoutes.js"
    click AdminRoutes "https://github.com/mostafakamal22/sprints-mern-e-banking-system/blob/main/Backend/routes/adminRoutes.js"
    click AccountRoutes "https://github.com/mostafakamal22/sprints-mern-e-banking-system/blob/main/Backend/routes/accountRoutes.js"
    click ReqRoutes "https://github.com/mostafakamal22/sprints-mern-e-banking-system/blob/main/Backend/routes/accountRequestRoutes.js"
    click UserModel "https://github.com/mostafakamal22/sprints-mern-e-banking-system/blob/main/Backend/models/userModel.js"
    click AdminModel "https://github.com/mostafakamal22/sprints-mern-e-banking-system/blob/main/Backend/models/adminModel.js"
    click AccountModel "https://github.com/mostafakamal22/sprints-mern-e-banking-system/blob/main/Backend/models/accountModel.js"
    click ReqModel "https://github.com/mostafakamal22/sprints-mern-e-banking-system/blob/main/Backend/models/accountRequestModel.js"
    click NotifyModel "https://github.com/mostafakamal22/sprints-mern-e-banking-system/blob/main/Backend/models/notificationSchema.js"
    click Proc "https://github.com/mostafakamal22/sprints-mern-e-banking-system/tree/main/Procfile"
    click Vite "https://github.com/mostafakamal22/sprints-mern-e-banking-system/blob/main/Frontend/vite.config.js"
    click Tailwind "https://github.com/mostafakamal22/sprints-mern-e-banking-system/blob/main/Frontend/tailwind.config.js"

    %% Styles
    classDef frontend fill:#cce5ff,stroke:#004085
    classDef backend fill:#d4edda,stroke:#155724
    classDef config fill:#e2e3e5,stroke:#6c757d,stroke-dasharray: 5 5
    classDef middleware fill:#fff3cd,stroke:#856404
    classDef controller fill:#f8d7da,stroke:#721c24
    classDef route fill:#d1ecf1,stroke:#0c5460
    classDef model fill:#f5c6cb,stroke:#721c24
    classDef db fill:#ffeeba,stroke:#856404
```
