# rohan28107/home-loan-calculator architecture

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

- Interactive diagram: https://gitdiagram.com/rohan28107/home-loan-calculator
- Repository: https://github.com/rohan28107/home-loan-calculator

## Overview

Home Loan Tracker combines an interactive loan dashboard with an Express API. Users enter loan terms, floating-rate changes, and prepayments; the frontend requests EMI, amortisation, and prepayment-impact results, then presents schedule and summary views. Optional JWT accounts restore and save a user’s loan. Groups and edges reflect documented capabilities and the shown imports/calls; unsampled UI and server wiring are represented only where the README or SOURCE INDEX supports them.

Main entry points: [`frontend/src/App.jsx`](https://github.com/rohan28107/home-loan-calculator/blob/main/frontend/src/App.jsx) (Dashboard shell), [`backend/routes/loan.js`](https://github.com/rohan28107/home-loan-calculator/blob/main/backend/routes/loan.js) (Loan routes), [`backend/controllers/loanController.js`](https://github.com/rohan28107/home-loan-calculator/blob/main/backend/controllers/loanController.js) (Loan handlers), [`backend/controllers/authController.js`](https://github.com/rohan28107/home-loan-calculator/blob/main/backend/controllers/authController.js) (Auth handlers)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_dashboard["Loan dashboard"]
  node_app["Dashboard shell<br/>[App.jsx]"]
  node_loanstate["Loan state<br/>[useLoan.js]"]
  node_calculator["EMI calculator<br/>[CalculatorTab.jsx]"]
  node_rates["Rate history<br/>[RateChangesTab.jsx]"]
  node_prepayments["Prepayment log<br/>[PrepaymentsTab.jsx]"]
  node_scheduleview["Schedule view<br/>[ScheduleTab.jsx]"]
  node_summaryview["Loan summary<br/>[SummaryTab.jsx]"]
end

subgraph group_api["Loan API"]
  node_loanapi["Loan API client<br/>[loanApi.js]"]
  node_httpclient["HTTP client<br/>[client.js]"]
  node_loanroutes["Loan routes<br/>[loan.js]"]
  node_loancontroller["Loan handlers<br/>[loanController.js]"]
end

subgraph group_engine["Calculation engine"]
  node_calculatorengine["EMI and schedule engine<br/>[loanCalculator.js]"]
  node_savedloan[("Saved loan<br/>[Loan.js]")]
end

subgraph group_identity["Accounts"]
  node_authui["Account controls<br/>[AuthModal.jsx]"]
  node_authstate["Session state<br/>[useAuth.js]"]
  node_authapi["Auth API client<br/>[authApi.js]"]
  node_authroutes["Auth routes<br/>[auth.js]"]
  node_authcontroller["Auth handlers<br/>[authController.js]"]
  node_authmiddleware["Token guard<br/>[requireAuth.js]"]
  node_authutils["Token utilities<br/>[auth.js]"]
  node_users[("User records<br/>[User.js]")]
end

node_borrower(("Borrower"))

node_borrower -->|"uses"| node_app
node_app -->|"manages"| node_loanstate
node_app -->|"renders"| node_calculator
node_app -->|"renders"| node_rates
node_app -->|"renders"| node_prepayments
node_app -->|"renders"| node_scheduleview
node_app -->|"renders"| node_summaryview
node_loanstate -->|"requests results"| node_loanapi
node_loanapi -->|"sends requests"| node_httpclient
node_httpclient -->|"calls API"| node_loanroutes
node_loanroutes -->|"dispatches"| node_loancontroller
node_loancontroller -->|"calculates"| node_calculatorengine
node_loancontroller -->|"reads and writes"| node_savedloan
node_app -->|"renders"| node_authui
node_app -->|"uses"| node_authstate
node_authstate -->|"requests session"| node_authapi
node_authapi -->|"sends requests"| node_httpclient
node_authroutes -->|"dispatches"| node_authcontroller
node_authroutes -->|"guards profile"| node_authmiddleware
node_loanroutes -->|"guards saved loan"| node_authmiddleware
node_authcontroller -->|"hashes and signs"| node_authutils
node_authmiddleware -->|"verifies token"| node_authutils
node_authcontroller -->|"reads and creates"| node_users

click node_app "https://github.com/rohan28107/home-loan-calculator/blob/main/frontend/src/App.jsx"
click node_loanstate "https://github.com/rohan28107/home-loan-calculator/blob/main/frontend/src/hooks/useLoan.js"
click node_calculator "https://github.com/rohan28107/home-loan-calculator/blob/main/frontend/src/components/CalculatorTab.jsx"
click node_rates "https://github.com/rohan28107/home-loan-calculator/blob/main/frontend/src/components/RateChangesTab.jsx"
click node_prepayments "https://github.com/rohan28107/home-loan-calculator/blob/main/frontend/src/components/PrepaymentsTab.jsx"
click node_scheduleview "https://github.com/rohan28107/home-loan-calculator/blob/main/frontend/src/components/ScheduleTab.jsx"
click node_summaryview "https://github.com/rohan28107/home-loan-calculator/blob/main/frontend/src/components/SummaryTab.jsx"
click node_loanapi "https://github.com/rohan28107/home-loan-calculator/blob/main/frontend/src/api/loanApi.js"
click node_httpclient "https://github.com/rohan28107/home-loan-calculator/blob/main/frontend/src/api/client.js"
click node_loanroutes "https://github.com/rohan28107/home-loan-calculator/blob/main/backend/routes/loan.js"
click node_loancontroller "https://github.com/rohan28107/home-loan-calculator/blob/main/backend/controllers/loanController.js"
click node_calculatorengine "https://github.com/rohan28107/home-loan-calculator/blob/main/backend/utils/loanCalculator.js"
click node_savedloan "https://github.com/rohan28107/home-loan-calculator/blob/main/backend/models/Loan.js"
click node_authui "https://github.com/rohan28107/home-loan-calculator/blob/main/frontend/src/components/AuthModal.jsx"
click node_authstate "https://github.com/rohan28107/home-loan-calculator/blob/main/frontend/src/hooks/useAuth.js"
click node_authapi "https://github.com/rohan28107/home-loan-calculator/blob/main/frontend/src/api/authApi.js"
click node_authroutes "https://github.com/rohan28107/home-loan-calculator/blob/main/backend/routes/auth.js"
click node_authcontroller "https://github.com/rohan28107/home-loan-calculator/blob/main/backend/controllers/authController.js"
click node_authmiddleware "https://github.com/rohan28107/home-loan-calculator/blob/main/backend/middleware/requireAuth.js"
click node_authutils "https://github.com/rohan28107/home-loan-calculator/blob/main/backend/utils/auth.js"
click node_users "https://github.com/rohan28107/home-loan-calculator/blob/main/backend/models/User.js"

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_app,node_loanstate,node_calculator,node_rates,node_prepayments,node_scheduleview,node_summaryview toneBlue
class node_loanapi,node_httpclient,node_loanroutes,node_loancontroller toneAmber
class node_calculatorengine,node_savedloan toneMint
class node_authui,node_authstate,node_authapi,node_authroutes,node_authcontroller,node_authmiddleware,node_authutils,node_users toneRose
class node_borrower toneIndigo
```

## Components

### Loan dashboard

- [Dashboard shell](https://github.com/rohan28107/home-loan-calculator/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Loan state](https://github.com/rohan28107/home-loan-calculator/blob/main/frontend/src/hooks/useLoan.js): `frontend/src/hooks/useLoan.js`
- [EMI calculator](https://github.com/rohan28107/home-loan-calculator/blob/main/frontend/src/components/CalculatorTab.jsx): `frontend/src/components/CalculatorTab.jsx`
- [Rate history](https://github.com/rohan28107/home-loan-calculator/blob/main/frontend/src/components/RateChangesTab.jsx): `frontend/src/components/RateChangesTab.jsx`
- [Prepayment log](https://github.com/rohan28107/home-loan-calculator/blob/main/frontend/src/components/PrepaymentsTab.jsx): `frontend/src/components/PrepaymentsTab.jsx`
- [Schedule view](https://github.com/rohan28107/home-loan-calculator/blob/main/frontend/src/components/ScheduleTab.jsx): `frontend/src/components/ScheduleTab.jsx`
- [Loan summary](https://github.com/rohan28107/home-loan-calculator/blob/main/frontend/src/components/SummaryTab.jsx): `frontend/src/components/SummaryTab.jsx`

### Loan API

- [Loan API client](https://github.com/rohan28107/home-loan-calculator/blob/main/frontend/src/api/loanApi.js): `frontend/src/api/loanApi.js`
- [HTTP client](https://github.com/rohan28107/home-loan-calculator/blob/main/frontend/src/api/client.js): `frontend/src/api/client.js`
- [Loan routes](https://github.com/rohan28107/home-loan-calculator/blob/main/backend/routes/loan.js): `backend/routes/loan.js`
- [Loan handlers](https://github.com/rohan28107/home-loan-calculator/blob/main/backend/controllers/loanController.js): `backend/controllers/loanController.js`

### Calculation engine

- [EMI and schedule engine](https://github.com/rohan28107/home-loan-calculator/blob/main/backend/utils/loanCalculator.js): `backend/utils/loanCalculator.js`
- [Saved loan](https://github.com/rohan28107/home-loan-calculator/blob/main/backend/models/Loan.js): `backend/models/Loan.js`

### Accounts

- [Account controls](https://github.com/rohan28107/home-loan-calculator/blob/main/frontend/src/components/AuthModal.jsx): `frontend/src/components/AuthModal.jsx`
- [Session state](https://github.com/rohan28107/home-loan-calculator/blob/main/frontend/src/hooks/useAuth.js): `frontend/src/hooks/useAuth.js`
- [Auth API client](https://github.com/rohan28107/home-loan-calculator/blob/main/frontend/src/api/authApi.js): `frontend/src/api/authApi.js`
- [Auth routes](https://github.com/rohan28107/home-loan-calculator/blob/main/backend/routes/auth.js): `backend/routes/auth.js`
- [Auth handlers](https://github.com/rohan28107/home-loan-calculator/blob/main/backend/controllers/authController.js): `backend/controllers/authController.js`
- [Token guard](https://github.com/rohan28107/home-loan-calculator/blob/main/backend/middleware/requireAuth.js): `backend/middleware/requireAuth.js`
- [Token utilities](https://github.com/rohan28107/home-loan-calculator/blob/main/backend/utils/auth.js): `backend/utils/auth.js`
- [User records](https://github.com/rohan28107/home-loan-calculator/blob/main/backend/models/User.js): `backend/models/User.js`

### Other components

- **Borrower**

## Connections

- Borrower → Dashboard shell: uses (evidence: `README.md`)
- Dashboard shell → Loan state: manages (evidence: `frontend/src/App.jsx`)
- Dashboard shell → EMI calculator: renders (evidence: `frontend/src/App.jsx`)
- Dashboard shell → Rate history: renders (evidence: `frontend/src/App.jsx`)
- Dashboard shell → Prepayment log: renders (evidence: `frontend/src/App.jsx`)
- Dashboard shell → Schedule view: renders (evidence: `frontend/src/App.jsx`)
- Dashboard shell → Loan summary: renders (evidence: `frontend/src/App.jsx`)
- Loan state → Loan API client: requests results (evidence: `frontend/src/hooks/useLoan.js`)
- Loan API client → HTTP client: sends requests (evidence: `frontend/src/api/loanApi.js`)
- HTTP client → Loan routes: calls API (evidence: `README.md`)
- Loan routes → Loan handlers: dispatches (evidence: `backend/routes/loan.js`)
- Loan handlers → EMI and schedule engine: calculates (evidence: `backend/controllers/loanController.js`)
- Loan handlers → Saved loan: reads and writes (evidence: `backend/controllers/loanController.js`)
- Dashboard shell → Account controls: renders (evidence: `frontend/src/App.jsx`)
- Dashboard shell → Session state: uses (evidence: `frontend/src/App.jsx`)
- Session state → Auth API client: requests session (evidence: `frontend/src/hooks/useAuth.js`)
- Auth API client → HTTP client: sends requests (evidence: `frontend/src/api/authApi.js`)
- Auth routes → Auth handlers: dispatches (evidence: `backend/routes/auth.js`)
- Auth routes → Token guard: guards profile (evidence: `backend/routes/auth.js`)
- Loan routes → Token guard: guards saved loan (evidence: `backend/routes/loan.js`)
- Auth handlers → Token utilities: hashes and signs (evidence: `backend/controllers/authController.js`)
- Token guard → Token utilities: verifies token (evidence: `backend/middleware/requireAuth.js`)
- Auth handlers → User records: reads and creates (evidence: `backend/controllers/authController.js`)
