# uttamkamar/loan-book architecture

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

- Interactive diagram: https://gitdiagram.com/uttamkamar/loan-book
- Repository: https://github.com/uttamkamar/loan-book

## Overview

This is a private-lending ledger for managing loans, repayments, borrower records, and supporting files. A lender uses the React dashboard to review balances, create or edit loans, record interest-first repayments and extensions, inspect loan dossiers, and import or export Excel data. The SPA calls an Express API, which applies loan-state accounting and persists records through a MySQL/SQLite database layer; uploaded documents and images are stored on disk. The backend excerpts are partial, so some capability links are documented rather than verified in route handlers.

Main entry points: [`src/App.jsx`](https://github.com/uttamkamar/loan-book/blob/main/src/App.jsx) (Dashboard app), [`server/index.js`](https://github.com/uttamkamar/loan-book/blob/main/server/index.js) (Express API), [`server/config/db.js`](https://github.com/uttamkamar/loan-book/blob/main/server/config/db.js) (Database adapter), [`src/api/client.js`](https://github.com/uttamkamar/loan-book/blob/main/src/api/client.js) (REST client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Ledger dashboard"]
  node_app["Dashboard app<br/>[App.jsx]"]
  node_navbar["Privacy controls<br/>[Navbar.jsx]"]
  node_stats["Financial overview<br/>[StatsOverview.jsx]"]
  node_table["Loan ledger<br/>[LoanTable.jsx]"]
  node_loanform["Loan entry form<br/>[LoanFormModal.jsx]"]
  node_installmentui["Repayment modal"]
  node_dossier["Loan dossier"]
  node_paperwork["Paperwork manager<br/>[PaperworkModal.jsx]"]
  node_collateral["Collateral gallery"]
  node_proofgallery["Payment proof viewer"]
  node_excelui["Excel transfer<br/>[ExcelModal.jsx]"]
end

subgraph group_api["Loan application API"]
  node_api_client["REST client<br/>[client.js]"]
  node_server["Express API<br/>[index.js]"]
  node_upload["Upload handling<br/>[upload.js]"]
end

subgraph group_accounting["Loan accounting"]
  node_interest["Interest accounting<br/>[interest.js]"]
  node_excel["Excel processing<br/>[excel.js]"]
end

subgraph group_persistence["Data and files"]
  node_db_layer["Database adapter<br/>[db.js]"]
  node_database[("Loan database<br/>[schema.sql]")]
  node_disk[("Uploaded files")]
end

node_lender(("Lender"))
node_mysql[("MySQL")]
node_sqlite[("SQLite fallback")]

node_lender -->|"uses"| node_app
node_app -->|"renders"| node_navbar
node_app -->|"renders"| node_stats
node_app -->|"renders"| node_table
node_app -->|"renders"| node_loanform
node_app -->|"renders"| node_installmentui
node_app -->|"renders"| node_dossier
node_app -->|"renders"| node_paperwork
node_app -->|"renders"| node_collateral
node_app -->|"renders"| node_proofgallery
node_app -->|"renders"| node_excelui
node_app -->|"loads and mutates"| node_api_client
node_excelui -->|"imports through"| node_api_client
node_dossier -->|"opens viewer"| node_proofgallery
node_api_client -->|"requests API"| node_server
node_server -->|"queries"| node_db_layer
node_server -->|"uses middleware"| node_upload
node_server -->|"calculates loan state"| node_interest
node_server -->|"handles spreadsheets"| node_excel
node_db_layer -->|"connects by default"| node_mysql
node_db_layer -->|"fails over"| node_sqlite
node_db_layer -.->|"uses schema"| node_database
node_server -->|"stores uploads"| node_disk
node_upload -->|"writes files"| node_disk

click node_app "https://github.com/uttamkamar/loan-book/blob/main/src/App.jsx"
click node_navbar "https://github.com/uttamkamar/loan-book/blob/main/src/components/Navbar.jsx"
click node_stats "https://github.com/uttamkamar/loan-book/blob/main/src/components/StatsOverview.jsx"
click node_table "https://github.com/uttamkamar/loan-book/blob/main/src/components/LoanTable.jsx"
click node_loanform "https://github.com/uttamkamar/loan-book/blob/main/src/components/LoanFormModal.jsx"
click node_installmentui "https://github.com/uttamkamar/loan-book/blob/main/src/components/InstallmentModal.jsx"
click node_dossier "https://github.com/uttamkamar/loan-book/blob/main/src/components/FullLoanDetailsModal.jsx"
click node_paperwork "https://github.com/uttamkamar/loan-book/blob/main/src/components/PaperworkModal.jsx"
click node_collateral "https://github.com/uttamkamar/loan-book/blob/main/src/components/CollateralGalleryModal.jsx"
click node_proofgallery "https://github.com/uttamkamar/loan-book/blob/main/src/components/PaymentProofGalleryModal.jsx"
click node_excelui "https://github.com/uttamkamar/loan-book/blob/main/src/components/ExcelModal.jsx"
click node_api_client "https://github.com/uttamkamar/loan-book/blob/main/src/api/client.js"
click node_server "https://github.com/uttamkamar/loan-book/blob/main/server/index.js"
click node_upload "https://github.com/uttamkamar/loan-book/blob/main/server/middleware/upload.js"
click node_interest "https://github.com/uttamkamar/loan-book/blob/main/server/utils/interest.js"
click node_excel "https://github.com/uttamkamar/loan-book/blob/main/server/utils/excel.js"
click node_db_layer "https://github.com/uttamkamar/loan-book/blob/main/server/config/db.js"
click node_database "https://github.com/uttamkamar/loan-book/blob/main/server/db/schema.sql"
click node_disk "https://github.com/uttamkamar/loan-book/tree/main/uploads"

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_navbar,node_stats,node_table,node_loanform,node_installmentui,node_dossier,node_paperwork,node_collateral,node_proofgallery,node_excelui toneBlue
class node_api_client,node_server,node_upload,node_mysql,node_sqlite toneAmber
class node_interest,node_excel toneMint
class node_db_layer,node_database,node_disk toneRose
class node_lender toneIndigo
```

## Components

### Ledger dashboard

- [Dashboard app](https://github.com/uttamkamar/loan-book/blob/main/src/App.jsx): `src/App.jsx`
- [Privacy controls](https://github.com/uttamkamar/loan-book/blob/main/src/components/Navbar.jsx): `src/components/Navbar.jsx`
- [Financial overview](https://github.com/uttamkamar/loan-book/blob/main/src/components/StatsOverview.jsx): `src/components/StatsOverview.jsx`
- [Loan ledger](https://github.com/uttamkamar/loan-book/blob/main/src/components/LoanTable.jsx): `src/components/LoanTable.jsx`
- [Loan entry form](https://github.com/uttamkamar/loan-book/blob/main/src/components/LoanFormModal.jsx): `src/components/LoanFormModal.jsx`
- [Repayment modal](https://github.com/uttamkamar/loan-book/blob/main/src/components/InstallmentModal.jsx): `src/components/InstallmentModal.jsx`
- [Loan dossier](https://github.com/uttamkamar/loan-book/blob/main/src/components/FullLoanDetailsModal.jsx): `src/components/FullLoanDetailsModal.jsx`
- [Paperwork manager](https://github.com/uttamkamar/loan-book/blob/main/src/components/PaperworkModal.jsx): `src/components/PaperworkModal.jsx`
- [Collateral gallery](https://github.com/uttamkamar/loan-book/blob/main/src/components/CollateralGalleryModal.jsx): `src/components/CollateralGalleryModal.jsx`
- [Payment proof viewer](https://github.com/uttamkamar/loan-book/blob/main/src/components/PaymentProofGalleryModal.jsx): `src/components/PaymentProofGalleryModal.jsx`
- [Excel transfer](https://github.com/uttamkamar/loan-book/blob/main/src/components/ExcelModal.jsx): `src/components/ExcelModal.jsx`

### Loan application API

- [REST client](https://github.com/uttamkamar/loan-book/blob/main/src/api/client.js): `src/api/client.js`
- [Express API](https://github.com/uttamkamar/loan-book/blob/main/server/index.js): `server/index.js`
- [Upload handling](https://github.com/uttamkamar/loan-book/blob/main/server/middleware/upload.js): `server/middleware/upload.js`

### Loan accounting

- [Interest accounting](https://github.com/uttamkamar/loan-book/blob/main/server/utils/interest.js): `server/utils/interest.js`
- [Excel processing](https://github.com/uttamkamar/loan-book/blob/main/server/utils/excel.js): `server/utils/excel.js`

### Data and files

- [Database adapter](https://github.com/uttamkamar/loan-book/blob/main/server/config/db.js): `server/config/db.js`
- [Loan database](https://github.com/uttamkamar/loan-book/blob/main/server/db/schema.sql): `server/db/schema.sql`
- [Uploaded files](https://github.com/uttamkamar/loan-book/tree/main/uploads): `uploads`

### Other components

- **Lender**
- **MySQL**
- **SQLite fallback**

## Connections

- Lender → Dashboard app: uses (evidence: `README.md`)
- Dashboard app → Privacy controls: renders (evidence: `src/App.jsx`)
- Dashboard app → Financial overview: renders (evidence: `src/App.jsx`)
- Dashboard app → Loan ledger: renders (evidence: `src/App.jsx`)
- Dashboard app → Loan entry form: renders (evidence: `src/App.jsx`)
- Dashboard app → Repayment modal: renders (evidence: `src/App.jsx`)
- Dashboard app → Loan dossier: renders (evidence: `src/App.jsx`)
- Dashboard app → Paperwork manager: renders (evidence: `src/App.jsx`)
- Dashboard app → Collateral gallery: renders (evidence: `src/App.jsx`)
- Dashboard app → Payment proof viewer: renders (evidence: `src/App.jsx`)
- Dashboard app → Excel transfer: renders (evidence: `src/App.jsx`)
- Dashboard app → REST client: loads and mutates (evidence: `src/App.jsx`)
- Excel transfer → REST client: imports through (evidence: `src/components/ExcelModal.jsx`)
- Loan dossier → Payment proof viewer: opens viewer (evidence: `src/components/FullLoanDetailsModal.jsx`)
- REST client → Express API: requests API (evidence: `src/api/client.js`)
- Express API → Database adapter: queries (evidence: `server/index.js`)
- Express API → Upload handling: uses middleware (evidence: `server/index.js`)
- Express API → Interest accounting: calculates loan state (evidence: `server/index.js`)
- Express API → Excel processing: handles spreadsheets (evidence: `server/index.js`)
- Database adapter → MySQL: connects by default (evidence: `README.md`)
- Database adapter → SQLite fallback: fails over (evidence: `README.md`)
- Database adapter → Loan database: uses schema
- Express API → Uploaded files: stores uploads (evidence: `server/index.js`)
- Upload handling → Uploaded files: writes files (evidence: `server/middleware/upload.js`)
