# jakirul458/gfst-frontend architecture

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

- Interactive diagram: https://gitdiagram.com/jakirul458/gfst-frontend
- Repository: https://github.com/jakirul458/gfst-frontend

## Overview

##### Project type and purpose
- This is a full-stack MERN (MongoDB, Express.js, React.js, Node.js) financial management SPA.
- Purpose: allow village users to sign up/in, manage savings, loans, investments, donations, expenditures, view dashboards, and receive email notifications.

##### File structure
- Top-level frontend:
- index.html, public/ → static assets
- src/ → React application
- vite.config.js → build tool config
- vercel.json → deployment config
- src/ splits into:
- src/pages/… → feature pages (auth, savings, loan, investment, society)
- src/components/… → shared UI (Navbar, Footer, Sidebar)
- src/Route/… → Routing logic & protected routes
- src/context/AuthContext.jsx → global auth state (Context API)
- src/api/index.js → wrapper for HTTP calls to the backend
- src/store/ & src/util/ → local utilities
- README describes backend dependencies (Express, Mongoose, Nodemailer) but backend code is hosted separately or in another repo.

##### README for additional insights
- Highlights RESTful APIs for account, transaction, loan, investment, donation, expenditure.
- Email notifications via Nodemailer.
- Uses Mongoose schemas to interact with MongoDB.

a. Main components:
- Client (React SPA)
- API Gateway / Web Server (Express.js)
- Business-Logic Layer (Express routes + controllers + services)
- Database (MongoDB)
- External Service (Email / SMTP via Nodemailer)
- Deployment Platform (Vercel for frontend, Node host or Vercel Functions for API)
b. Relationships & interactions:
1. User’s Browser loads React SPA from Vercel.
2. SPA uses React Router and AuthContext to manage client-side routing and auth state.
3. On actions (signin, CRUD on accounts, transactions), SPA calls Express REST endpoints via src/api/index.js.
4. Express controllers validate requests, use Mongoose to read/write MongoDB collections (users, savings, loans, investments, donations, expenditures).
5. For events (deposit, withdrawal, donation), Node triggers Nodemailer service to send email through SMTP.
6. Responses flow back to SPA, updates UI.
c. Architectural patterns & principles:
- Layered architecture:
– Presentation Layer (React components/pages)
– Application Layer (client-side routing, context)
– API Layer (Express routes/controllers/services)
– Data Layer (MongoDB + Mongoose)
- Separation of concerns: UI vs API vs data persistence vs external integration.
- ProtectedRoute enforces frontend auth; server also enforces auth (JWT/session).
d. Relevant technologies & libraries:
– Frontend: React.js + Vite, React Router, Context API, Axios/fetch
– Backend: Node.js, Express.js, Mongoose, Nodemailer
– DB: MongoDB Atlas (cloud) or local
– Deployment: Vercel (frontend), Heroku/AWS/Vercel Functions (backend)

## Diagram (Mermaid)

```mermaid
flowchart TB
  classDef frontend fill:#D0E8FF,stroke:#0366d6,color:#000
  classDef api fill:#DFFFE0,stroke:#28a745,color:#000
  classDef db fill:#F0F0F0,stroke:#555,color:#000
  classDef external fill:#FFEFD5,stroke:#D2691E,color:#000

  subgraph "Client (React SPA)"
    direction TB
    Browser["User's Browser"]:::frontend
    C0["index.html & public"]:::frontend
    C1["src/main.jsx"]:::frontend
    C2["src/App.jsx"]:::frontend

    subgraph "Routing Layer"
      R1["Routing.jsx"]:::frontend
      R2["ProtectedRoute.jsx"]:::frontend
    end

    C3["AuthContext.jsx"]:::frontend
    C4["API Client (src/api/index.js)"]:::frontend

    subgraph "UI Components"
      UI1["Navbar"]:::frontend
      UI2["Footer"]:::frontend
      UI3["Sidebar"]:::frontend
    end

    subgraph "Pages"
      AuthSignIn["SignIn"]:::frontend
      AuthSignUp["SignUp"]:::frontend
      AuthLogOut["LogOut"]:::frontend
      SavingsAllAcc["AllAccounts"]:::frontend
      SavingsAllTrans["AllTransactions"]:::frontend
      SavingsCreateAcc["CreateAccount"]:::frontend
      SavingsDeposit["Deposit"]:::frontend
      LoanAllAcc["LoanAllAccounts"]:::frontend
      InvestAllAcc["InvestmentAllAccounts"]:::frontend
      SocDashboard["Dashboard"]:::frontend
    end

    subgraph "Utilities & Config"
      Const["path.constants.js"]:::frontend
      Store["store/index.js"]:::frontend
      Util["FormatDate.js"]:::frontend
      LayoutJS["MainLayout.jsx"]:::frontend
      LayoutCSS["Layout.css"]:::frontend
      Vite["vite.config.js"]:::frontend
      VercelCFG["vercel.json"]:::frontend
      ESLint[".eslintrc.cjs"]:::frontend
      PKG["package.json"]:::frontend
    end
  end

  subgraph "Server (Express API)"
    direction TB
    S1["AuthRouter"]:::api
    S2["SavingsRouter"]:::api
    S3["LoanRouter"]:::api
    S4["InvestmentRouter"]:::api
    S5["SocietyRouter"]:::api
    S6["Controllers & Services"]:::api
    S7["Mongoose Models"]:::api
    S8["Email Service (Nodemailer)"]:::external
  end

  DB[(MongoDB)]:::db
  SMTP["SMTP Server"]:::external

  Browser -->|HTTP GET| C0
  C0 -->|loads| C1
  C1 --> C2
  C2 -->|uses| R1
  R1 -->|calls| R2
  R2 -->|gates| AuthSignIn & SavingsAllAcc & LoanAllAcc & InvestAllAcc & SocDashboard
  C2 --> C3
  C2 --> C4
  C2 --> UI1 & UI2 & UI3
  C2 --> Const & Store & Util & LayoutJS & LayoutCSS

  C4 -->|REST calls| S1 & S2 & S3 & S4 & S5
  S1 & S2 & S3 & S4 & S5 -->|invoke| S6
  S6 -->|uses| S7
  S7 -->|read/write| DB
  S6 -->|triggers| S8
  S8 -->|SMTP| SMTP

  click C1 "https://github.com/jakirul458/gfst-frontend/blob/main/src/main.jsx"
  click C2 "https://github.com/jakirul458/gfst-frontend/blob/main/src/App.jsx"
  click R1 "https://github.com/jakirul458/gfst-frontend/blob/main/src/Route/Routing.jsx"
  click R2 "https://github.com/jakirul458/gfst-frontend/blob/main/src/Route/ProtectedRoute.jsx"
  click C3 "https://github.com/jakirul458/gfst-frontend/blob/main/src/context/AuthContext.jsx"
  click C4 "https://github.com/jakirul458/gfst-frontend/blob/main/src/api/index.js"
  click UI1 "https://github.com/jakirul458/gfst-frontend/blob/main/src/components/Navbar/Navbar.jsx"
  click UI2 "https://github.com/jakirul458/gfst-frontend/blob/main/src/components/Footer/Footer.jsx"
  click UI3 "https://github.com/jakirul458/gfst-frontend/blob/main/src/components/Sidebar/SideBar.jsx"
  click LayoutJS "https://github.com/jakirul458/gfst-frontend/blob/main/src/layout/MainLayout.jsx"
  click LayoutCSS "https://github.com/jakirul458/gfst-frontend/blob/main/src/layout/Layout.css"
  click AuthSignIn "https://github.com/jakirul458/gfst-frontend/blob/main/src/pages/auth/SignIn/SignIn.jsx"
  click AuthSignUp "https://github.com/jakirul458/gfst-frontend/blob/main/src/pages/auth/SignUp/Signup.jsx"
  click AuthLogOut "https://github.com/jakirul458/gfst-frontend/blob/main/src/pages/auth/LogOut/logout.jsx"
  click SavingsAllAcc "https://github.com/jakirul458/gfst-frontend/blob/main/src/pages/savings/AllAccounts/AllAccounts.jsx"
  click SavingsAllTrans "https://github.com/jakirul458/gfst-frontend/blob/main/src/pages/savings/AllTransactions/MonthlySavingAudit.jsx"
  click SavingsCreateAcc "https://github.com/jakirul458/gfst-frontend/blob/main/src/pages/savings/CreateAccount/CreateSavingAccount.jsx"
  click SavingsDeposit "https://github.com/jakirul458/gfst-frontend/blob/main/src/pages/savings/Deposit/Deposit.jsx"
  click LoanAllAcc "https://github.com/jakirul458/gfst-frontend/blob/main/src/pages/loan/AllAccounts/LoanAcounts.jsx"
  click InvestAllAcc "https://github.com/jakirul458/gfst-frontend/blob/main/src/pages/investment/AllAccounts/InvestmentAccounts.jsx"
  click SocDashboard "https://github.com/jakirul458/gfst-frontend/blob/main/src/pages/society/Dashboard/Dashboard.jsx"
  click Const "https://github.com/jakirul458/gfst-frontend/blob/main/src/constants/path.constants.js"
  click Store "https://github.com/jakirul458/gfst-frontend/blob/main/src/store/index.js"
  click Util "https://github.com/jakirul458/gfst-frontend/blob/main/src/util/FormatDate.js"
  click Vite "https://github.com/jakirul458/gfst-frontend/blob/main/vite.config.js"
  click VercelCFG "https://github.com/jakirul458/gfst-frontend/blob/main/vercel.json"
  click ESLint "https://github.com/jakirul458/gfst-frontend/blob/main/.eslintrc.cjs"
  click PKG "https://github.com/jakirul458/gfst-frontend/blob/main/package.json"
  click S1 "https://github.com/jakirul458/gfst-frontend/tree/main/app/AuthRouter"
  click S2 "https://github.com/jakirul458/gfst-frontend/tree/main/app/SavingsRouter"
  click S3 "https://github.com/jakirul458/gfst-frontend/tree/main/app/LoanRouter"
  click S4 "https://github.com/jakirul458/gfst-frontend/tree/main/app/InvestmentRouter"
  click S5 "https://github.com/jakirul458/gfst-frontend/tree/main/app/SocietyRouter"
```
