# mayank123hangsh00/credit-loan-management-system architecture

> Architecture diagram of the GitHub repository mayank123hangsh00/credit-loan-management-system, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-16). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/mayank123hangsh00/credit-loan-management-system
- Repository: https://github.com/mayank123hangsh00/credit-loan-management-system

## Overview

CreditSea is a borrower loan-application and internal loan-operations platform. Borrowers register, complete eligibility and document steps, configure and submit a loan, then track its status and repayments. Staff manage leads, review and decide applications, disburse sanctioned loans, and record collections through role-based dashboards. The backend provides authentication, authorization, business rules, loan operations, and persistence. Frontend-to-API links reflect the README’s documented REST architecture; some backend relationships are supported by the sampled source and SOURCE INDEX.

Main entry points: [`server/src/app.ts`](https://github.com/mayank123hangsh00/credit-loan-management-system/blob/main/server/src/app.ts) (REST API), [`server/src/routes/borrower.routes.ts`](https://github.com/mayank123hangsh00/credit-loan-management-system/blob/main/server/src/routes/borrower.routes.ts) (Borrower routes), [`client/src/app/(borrower)/apply/page.tsx`](https://github.com/mayank123hangsh00/credit-loan-management-system/blob/main/client/src/app/(borrower)/apply/page.tsx) (Loan application), [`server/src/routes/loan.routes.ts`](https://github.com/mayank123hangsh00/credit-loan-management-system/blob/main/server/src/routes/loan.routes.ts) (Loan routes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_borrower["Borrower experience"]
  node_auth_ui["Sign in and register<br/>[page.tsx]"]
  node_borrower_apply["Loan application<br/>[page.tsx]"]
  node_client_bre["Client eligibility<br/>[bre.ts]"]
  node_loan_calc["Loan calculator<br/>[loanCalc.ts]"]
  node_my_loans["My loans<br/>[page.tsx]"]
  node_auth_context["Auth context<br/>[auth.tsx]"]
end

subgraph group_operations["Operations dashboard"]
  node_sales["Sales leads<br/>[page.tsx]"]
  node_overview["Portfolio overview<br/>[page.tsx]"]
  node_sanction["Sanction review<br/>[page.tsx]"]
  node_disbursement["Fund disbursement<br/>[page.tsx]"]
  node_collection["Collections<br/>[page.tsx]"]
end

subgraph group_backend["API and services"]
  node_api["REST API<br/>[app.ts]"]
  node_auth_routes["Authentication routes<br/>[auth.routes.ts]"]
  node_auth_controller["Authentication<br/>[auth.controller.ts]"]
  node_borrower_routes["Borrower routes<br/>[borrower.routes.ts]"]
  node_borrower_controller["Borrower application"]
  node_bre_service["Authoritative BRE<br/>[bre.service.ts]"]
  node_loan_routes["Loan routes<br/>[loan.routes.ts]"]
  node_loan_controller["Loan operations<br/>[loan.controller.ts]"]
  node_dashboard_routes["Operations routes"]
  node_dashboard_controller["Operations logic"]
  node_auth_middleware["JWT authentication<br/>[auth.ts]"]
  node_rbac["Role authorization<br/>[rbac.ts]"]
  node_upload["Document upload<br/>[upload.ts]"]
  node_loan_service["Loan transitions<br/>[loan.service.ts]"]
end

subgraph group_persistence["Persistence"]
  node_user_model["User records<br/>[User.ts]"]
  node_loan_model["Loan records<br/>[Loan.ts]"]
  node_payment_model["Payment records<br/>[Payment.ts]"]
  node_mongodb[("MongoDB")]
end

node_borrower_actor(("Borrower"))
node_staff_actor(("Operations staff"))

node_borrower_actor -->|"registers or signs in"| node_auth_ui
node_borrower_actor -->|"applies"| node_borrower_apply
node_borrower_apply -->|"checks eligibility"| node_client_bre
node_borrower_apply -->|"calculates repayment"| node_loan_calc
node_borrower_actor -->|"tracks loans"| node_my_loans
node_staff_actor -->|"tracks leads"| node_sales
node_staff_actor -->|"views portfolio"| node_overview
node_staff_actor -->|"reviews applications"| node_sanction
node_staff_actor -->|"releases funds"| node_disbursement
node_staff_actor -->|"records repayments"| node_collection
node_auth_ui -->|"uses REST API"| node_api
node_borrower_apply -->|"uses REST API"| node_api
node_my_loans -->|"uses REST API"| node_api
node_sales -->|"uses REST API"| node_api
node_overview -->|"uses REST API"| node_api
node_sanction -->|"uses REST API"| node_api
node_disbursement -->|"uses REST API"| node_api
node_collection -->|"uses REST API"| node_api
node_api -->|"mounts routes"| node_auth_routes
node_api -->|"mounts routes"| node_borrower_routes
node_api -->|"mounts routes"| node_loan_routes
node_api -->|"mounts routes"| node_dashboard_routes
node_auth_routes -->|"dispatches"| node_auth_controller
node_borrower_routes -->|"dispatches"| node_borrower_controller
node_borrower_controller -->|"checks eligibility"| node_bre_service
node_loan_routes -->|"dispatches"| node_loan_controller
node_dashboard_routes -->|"dispatches"| node_dashboard_controller
node_auth_routes -->|"requires authentication"| node_auth_middleware
node_borrower_routes -->|"requires authentication"| node_auth_middleware
node_loan_routes -->|"requires authentication"| node_auth_middleware
node_dashboard_routes -->|"requires authentication"| node_auth_middleware
node_borrower_routes -->|"checks borrower role"| node_rbac
node_loan_routes -->|"checks roles"| node_rbac
node_dashboard_routes -->|"checks staff roles"| node_rbac
node_borrower_routes -->|"accepts salary slip"| node_upload
node_auth_controller -->|"reads and creates users"| node_user_model
node_borrower_controller -->|"updates borrower"| node_user_model
node_loan_controller -->|"manages loans"| node_loan_model
node_loan_controller -->|"delegates transitions"| node_loan_service
node_dashboard_controller -->|"reads and updates loans"| node_loan_model
node_dashboard_controller -->|"queries borrowers"| node_user_model
node_dashboard_controller -->|"records payments"| node_payment_model
node_user_model -.->|"persists users"| node_mongodb
node_loan_model -.->|"persists loans"| node_mongodb
node_payment_model -.->|"persists payments"| node_mongodb

click node_auth_ui "https://github.com/mayank123hangsh00/credit-loan-management-system/blob/main/client/src/app/login/page.tsx"
click node_borrower_apply "https://github.com/mayank123hangsh00/credit-loan-management-system/blob/main/client/src/app/(borrower)/apply/page.tsx"
click node_client_bre "https://github.com/mayank123hangsh00/credit-loan-management-system/blob/main/client/src/lib/bre.ts"
click node_loan_calc "https://github.com/mayank123hangsh00/credit-loan-management-system/blob/main/client/src/lib/loanCalc.ts"
click node_my_loans "https://github.com/mayank123hangsh00/credit-loan-management-system/blob/main/client/src/app/(borrower)/my-loans/page.tsx"
click node_auth_context "https://github.com/mayank123hangsh00/credit-loan-management-system/blob/main/client/src/lib/auth.tsx"
click node_sales "https://github.com/mayank123hangsh00/credit-loan-management-system/blob/main/client/src/app/(dashboard)/dashboard/sales/page.tsx"
click node_overview "https://github.com/mayank123hangsh00/credit-loan-management-system/blob/main/client/src/app/(dashboard)/dashboard/overview/page.tsx"
click node_sanction "https://github.com/mayank123hangsh00/credit-loan-management-system/blob/main/client/src/app/(dashboard)/dashboard/sanction/page.tsx"
click node_disbursement "https://github.com/mayank123hangsh00/credit-loan-management-system/blob/main/client/src/app/(dashboard)/dashboard/disbursement/page.tsx"
click node_collection "https://github.com/mayank123hangsh00/credit-loan-management-system/blob/main/client/src/app/(dashboard)/dashboard/collection/page.tsx"
click node_api "https://github.com/mayank123hangsh00/credit-loan-management-system/blob/main/server/src/app.ts"
click node_auth_routes "https://github.com/mayank123hangsh00/credit-loan-management-system/blob/main/server/src/routes/auth.routes.ts"
click node_auth_controller "https://github.com/mayank123hangsh00/credit-loan-management-system/blob/main/server/src/controllers/auth.controller.ts"
click node_borrower_routes "https://github.com/mayank123hangsh00/credit-loan-management-system/blob/main/server/src/routes/borrower.routes.ts"
click node_borrower_controller "https://github.com/mayank123hangsh00/credit-loan-management-system/blob/main/server/src/controllers/borrower.controller.ts"
click node_bre_service "https://github.com/mayank123hangsh00/credit-loan-management-system/blob/main/server/src/services/bre.service.ts"
click node_loan_routes "https://github.com/mayank123hangsh00/credit-loan-management-system/blob/main/server/src/routes/loan.routes.ts"
click node_loan_controller "https://github.com/mayank123hangsh00/credit-loan-management-system/blob/main/server/src/controllers/loan.controller.ts"
click node_dashboard_routes "https://github.com/mayank123hangsh00/credit-loan-management-system/blob/main/server/src/routes/dashboard.routes.ts"
click node_dashboard_controller "https://github.com/mayank123hangsh00/credit-loan-management-system/blob/main/server/src/controllers/dashboard.controller.ts"
click node_auth_middleware "https://github.com/mayank123hangsh00/credit-loan-management-system/blob/main/server/src/middleware/auth.ts"
click node_rbac "https://github.com/mayank123hangsh00/credit-loan-management-system/blob/main/server/src/middleware/rbac.ts"
click node_upload "https://github.com/mayank123hangsh00/credit-loan-management-system/blob/main/server/src/middleware/upload.ts"
click node_loan_service "https://github.com/mayank123hangsh00/credit-loan-management-system/blob/main/server/src/services/loan.service.ts"
click node_user_model "https://github.com/mayank123hangsh00/credit-loan-management-system/blob/main/server/src/models/User.ts"
click node_loan_model "https://github.com/mayank123hangsh00/credit-loan-management-system/blob/main/server/src/models/Loan.ts"
click node_payment_model "https://github.com/mayank123hangsh00/credit-loan-management-system/blob/main/server/src/models/Payment.ts"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_auth_ui,node_borrower_apply,node_client_bre,node_loan_calc,node_my_loans,node_auth_context toneBlue
class node_sales,node_overview,node_sanction,node_disbursement,node_collection toneAmber
class node_api,node_auth_routes,node_auth_controller,node_borrower_routes,node_borrower_controller,node_bre_service,node_loan_routes,node_loan_controller,node_dashboard_routes,node_dashboard_controller,node_auth_middleware,node_rbac,node_upload,node_loan_service toneMint
class node_user_model,node_loan_model,node_payment_model,node_mongodb toneRose
class node_borrower_actor,node_staff_actor toneIndigo
```

## Components

### Borrower experience

- [Sign in and register](https://github.com/mayank123hangsh00/credit-loan-management-system/blob/main/client/src/app/login/page.tsx): `client/src/app/login/page.tsx`
- [Loan application](https://github.com/mayank123hangsh00/credit-loan-management-system/blob/main/client/src/app/(borrower)/apply/page.tsx): `client/src/app/(borrower)/apply/page.tsx`
- [Client eligibility](https://github.com/mayank123hangsh00/credit-loan-management-system/blob/main/client/src/lib/bre.ts): `client/src/lib/bre.ts`
- [Loan calculator](https://github.com/mayank123hangsh00/credit-loan-management-system/blob/main/client/src/lib/loanCalc.ts): `client/src/lib/loanCalc.ts`
- [My loans](https://github.com/mayank123hangsh00/credit-loan-management-system/blob/main/client/src/app/(borrower)/my-loans/page.tsx): `client/src/app/(borrower)/my-loans/page.tsx`
- [Auth context](https://github.com/mayank123hangsh00/credit-loan-management-system/blob/main/client/src/lib/auth.tsx): `client/src/lib/auth.tsx`

### Operations dashboard

- [Sales leads](https://github.com/mayank123hangsh00/credit-loan-management-system/blob/main/client/src/app/(dashboard)/dashboard/sales/page.tsx): `client/src/app/(dashboard)/dashboard/sales/page.tsx`
- [Portfolio overview](https://github.com/mayank123hangsh00/credit-loan-management-system/blob/main/client/src/app/(dashboard)/dashboard/overview/page.tsx): `client/src/app/(dashboard)/dashboard/overview/page.tsx`
- [Sanction review](https://github.com/mayank123hangsh00/credit-loan-management-system/blob/main/client/src/app/(dashboard)/dashboard/sanction/page.tsx): `client/src/app/(dashboard)/dashboard/sanction/page.tsx`
- [Fund disbursement](https://github.com/mayank123hangsh00/credit-loan-management-system/blob/main/client/src/app/(dashboard)/dashboard/disbursement/page.tsx): `client/src/app/(dashboard)/dashboard/disbursement/page.tsx`
- [Collections](https://github.com/mayank123hangsh00/credit-loan-management-system/blob/main/client/src/app/(dashboard)/dashboard/collection/page.tsx): `client/src/app/(dashboard)/dashboard/collection/page.tsx`

### API and services

- [REST API](https://github.com/mayank123hangsh00/credit-loan-management-system/blob/main/server/src/app.ts): `server/src/app.ts`
- [Authentication routes](https://github.com/mayank123hangsh00/credit-loan-management-system/blob/main/server/src/routes/auth.routes.ts): `server/src/routes/auth.routes.ts`
- [Authentication](https://github.com/mayank123hangsh00/credit-loan-management-system/blob/main/server/src/controllers/auth.controller.ts): `server/src/controllers/auth.controller.ts`
- [Borrower routes](https://github.com/mayank123hangsh00/credit-loan-management-system/blob/main/server/src/routes/borrower.routes.ts): `server/src/routes/borrower.routes.ts`
- [Borrower application](https://github.com/mayank123hangsh00/credit-loan-management-system/blob/main/server/src/controllers/borrower.controller.ts): `server/src/controllers/borrower.controller.ts`
- [Authoritative BRE](https://github.com/mayank123hangsh00/credit-loan-management-system/blob/main/server/src/services/bre.service.ts): `server/src/services/bre.service.ts`
- [Loan routes](https://github.com/mayank123hangsh00/credit-loan-management-system/blob/main/server/src/routes/loan.routes.ts): `server/src/routes/loan.routes.ts`
- [Loan operations](https://github.com/mayank123hangsh00/credit-loan-management-system/blob/main/server/src/controllers/loan.controller.ts): `server/src/controllers/loan.controller.ts`
- [Operations routes](https://github.com/mayank123hangsh00/credit-loan-management-system/blob/main/server/src/routes/dashboard.routes.ts): `server/src/routes/dashboard.routes.ts`
- [Operations logic](https://github.com/mayank123hangsh00/credit-loan-management-system/blob/main/server/src/controllers/dashboard.controller.ts): `server/src/controllers/dashboard.controller.ts`
- [JWT authentication](https://github.com/mayank123hangsh00/credit-loan-management-system/blob/main/server/src/middleware/auth.ts): `server/src/middleware/auth.ts`
- [Role authorization](https://github.com/mayank123hangsh00/credit-loan-management-system/blob/main/server/src/middleware/rbac.ts): `server/src/middleware/rbac.ts`
- [Document upload](https://github.com/mayank123hangsh00/credit-loan-management-system/blob/main/server/src/middleware/upload.ts): `server/src/middleware/upload.ts`
- [Loan transitions](https://github.com/mayank123hangsh00/credit-loan-management-system/blob/main/server/src/services/loan.service.ts): `server/src/services/loan.service.ts`

### Persistence

- [User records](https://github.com/mayank123hangsh00/credit-loan-management-system/blob/main/server/src/models/User.ts): `server/src/models/User.ts`
- [Loan records](https://github.com/mayank123hangsh00/credit-loan-management-system/blob/main/server/src/models/Loan.ts): `server/src/models/Loan.ts`
- [Payment records](https://github.com/mayank123hangsh00/credit-loan-management-system/blob/main/server/src/models/Payment.ts): `server/src/models/Payment.ts`
- **MongoDB**

### Other components

- **Borrower**
- **Operations staff**

## Connections

- Borrower → Sign in and register: registers or signs in (evidence: `README.md`)
- Borrower → Loan application: applies (evidence: `README.md`)
- Loan application → Client eligibility: checks eligibility (evidence: `README.md`)
- Loan application → Loan calculator: calculates repayment (evidence: `README.md`)
- Borrower → My loans: tracks loans (evidence: `README.md`)
- Operations staff → Sales leads: tracks leads (evidence: `README.md`)
- Operations staff → Portfolio overview: views portfolio (evidence: `README.md`)
- Operations staff → Sanction review: reviews applications (evidence: `README.md`)
- Operations staff → Fund disbursement: releases funds (evidence: `README.md`)
- Operations staff → Collections: records repayments (evidence: `README.md`)
- Sign in and register → REST API: uses REST API (evidence: `README.md`)
- Loan application → REST API: uses REST API (evidence: `README.md`)
- My loans → REST API: uses REST API (evidence: `README.md`)
- Sales leads → REST API: uses REST API (evidence: `README.md`)
- Portfolio overview → REST API: uses REST API (evidence: `README.md`)
- Sanction review → REST API: uses REST API (evidence: `README.md`)
- Fund disbursement → REST API: uses REST API (evidence: `README.md`)
- Collections → REST API: uses REST API (evidence: `README.md`)
- REST API → Authentication routes: mounts routes (evidence: `server/src/app.ts`)
- REST API → Borrower routes: mounts routes (evidence: `server/src/app.ts`)
- REST API → Loan routes: mounts routes (evidence: `server/src/app.ts`)
- REST API → Operations routes: mounts routes (evidence: `server/src/app.ts`)
- Authentication routes → Authentication: dispatches (evidence: `server/src/routes/auth.routes.ts`)
- Borrower routes → Borrower application: dispatches (evidence: `server/src/routes/borrower.routes.ts`)
- Borrower application → Authoritative BRE: checks eligibility (evidence: `server/src/controllers/borrower.controller.ts`)
- Loan routes → Loan operations: dispatches (evidence: `server/src/routes/loan.routes.ts`)
- Operations routes → Operations logic: dispatches (evidence: `server/src/routes/dashboard.routes.ts`)
- Authentication routes → JWT authentication: requires authentication (evidence: `server/src/routes/auth.routes.ts`)
- Borrower routes → JWT authentication: requires authentication (evidence: `server/src/routes/borrower.routes.ts`)
- Loan routes → JWT authentication: requires authentication (evidence: `server/src/routes/loan.routes.ts`)
- Operations routes → JWT authentication: requires authentication (evidence: `server/src/routes/dashboard.routes.ts`)
- Borrower routes → Role authorization: checks borrower role (evidence: `server/src/routes/borrower.routes.ts`)
- Loan routes → Role authorization: checks roles (evidence: `server/src/routes/loan.routes.ts`)
- Operations routes → Role authorization: checks staff roles (evidence: `server/src/routes/dashboard.routes.ts`)
- Borrower routes → Document upload: accepts salary slip (evidence: `server/src/routes/borrower.routes.ts`)
- Authentication → User records: reads and creates users (evidence: `server/src/controllers/auth.controller.ts`)
- Borrower application → User records: updates borrower (evidence: `server/src/controllers/borrower.controller.ts`)
- Loan operations → Loan records: manages loans (evidence: `server/src/controllers/loan.controller.ts`)
- Loan operations → Loan transitions: delegates transitions (evidence: `server/src/controllers/loan.controller.ts`)
- Operations logic → Loan records: reads and updates loans (evidence: `server/src/controllers/dashboard.controller.ts`)
- Operations logic → User records: queries borrowers (evidence: `server/src/controllers/dashboard.controller.ts`)
- Operations logic → Payment records: records payments (evidence: `server/src/controllers/dashboard.controller.ts`)
- User records → MongoDB: persists users
- Loan records → MongoDB: persists loans
- Payment records → MongoDB: persists payments
