# vasanthselvamani/lending architecture

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

- Interactive diagram: https://gitdiagram.com/vasanthselvamani/lending
- Repository: https://github.com/vasanthselvamani/lending

## Overview

Meridian Lending Office is an internal lending-operations system for home loans and several loan-against-property products. Staff sign in, manage customers and applications, track documents, issue sanction letters and Key Fact Statements, record transactions, and review dashboards and reports. The React workspace calls an authenticated Express API; the server applies lending calculations and reporting, generates PDFs, and persists operational records in protected local CSV files. The README documents backup, restore, settings, and role-based controls. Some subsystem links are documented rather than visible in the sampled server routes.

Main entry points: [`src/App.tsx`](https://github.com/vasanthselvamani/lending/blob/main/src/App.tsx) (Workspace Shell), [`src/lib/api.ts`](https://github.com/vasanthselvamani/lending/blob/main/src/lib/api.ts) (Bearer API Client), [`server.ts`](https://github.com/vasanthselvamani/lending/blob/main/server.ts) (Express API), [`server/lib/csvEngine.ts`](https://github.com/vasanthselvamani/lending/blob/main/server/lib/csvEngine.ts) (CSV Storage)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_workspace["Staff Workspace"]
  node_app["Workspace Shell<br/>[App.tsx]"]
  node_authview["Sign In<br/>[AuthScreen.tsx]"]
  node_api["Bearer API Client<br/>[api.ts]"]
end

subgraph group_operations["Loan Operations"]
  node_customers["Customers<br/>[CustomersView.tsx]"]
  node_applications["Applications"]
  node_documents["Document Checklist<br/>[DocumentsView.tsx]"]
  node_sanction["Sanction Letters"]
  node_kfs["KFS and Repayment"]
  node_dashboard["Dashboard<br/>[DashboardView.tsx]"]
  node_reportsview["Reports<br/>[ReportsView.tsx]"]
end

subgraph group_server["API Services"]
  node_serverapi["Express API<br/>[server.ts]"]
  node_calculator["Loan Calculator<br/>[loanCalculator.ts]"]
  node_analytics["Analytics Engine"]
  node_pdf["PDF Generator<br/>[pdfGenerator.ts]"]
end

subgraph group_records["Records and Controls"]
  node_csv[("CSV Storage<br/>[csvEngine.ts]")]
  node_auth["Authentication and RBAC<br/>[auth.ts]"]
  node_settings["Office Settings<br/>[settingsStore.ts]"]
  node_backup["Backup and Restore"]
  node_users["Staff Accounts<br/>[UsersView.tsx]"]
  node_settingsview["Settings UI<br/>[SettingsView.tsx]"]
  node_seed["Initial Sample Data<br/>[seedData.ts]"]
  node_types["Lending Domain Types<br/>[lending.ts]"]
end

node_staff(("Office Staff"))

node_staff -->|"uses"| node_app
node_app -->|"renders"| node_authview
node_app -->|"selects view"| node_customers
node_app -->|"selects view"| node_applications
node_app -->|"selects view"| node_documents
node_app -->|"selects view"| node_sanction
node_app -->|"selects view"| node_kfs
node_app -->|"selects view"| node_dashboard
node_app -->|"selects view"| node_reportsview
node_app -->|"selects view"| node_backup
node_app -->|"selects view"| node_users
node_app -->|"selects view"| node_settingsview
node_authview -->|"submits credentials"| node_api
node_app -->|"checks session"| node_api
node_customers -->|"requests data"| node_api
node_applications -->|"updates records"| node_api
node_documents -->|"requests data"| node_api
node_sanction -->|"requests issuance"| node_api
node_kfs -->|"requests issuance"| node_api
node_dashboard -->|"loads metrics"| node_api
node_reportsview -->|"loads reports"| node_api
node_backup -->|"requests backups"| node_api
node_users -->|"manages users"| node_api
node_settingsview -->|"updates settings"| node_api
node_api -->|"sends HTTP requests"| node_serverapi
node_serverapi -->|"enforces access"| node_auth
node_serverapi -->|"reads and writes"| node_csv
node_serverapi -->|"calculates loans"| node_calculator
node_serverapi -->|"builds reports"| node_analytics
node_serverapi -->|"generates documents"| node_pdf
node_serverapi -->|"loads configuration"| node_settings
node_serverapi -->|"seeds on startup"| node_seed
node_serverapi -->|"initializes storage"| node_csv
node_backup -->|"requests restore"| node_serverapi
node_auth -->|"reads accounts"| node_csv
node_seed -->|"writes sample records"| node_csv
node_seed -->|"calculates samples"| node_calculator
node_seed -->|"uses defaults"| node_settings
node_serverapi -->|"uses domain types"| node_types
node_calculator -->|"uses calculation types"| node_types
node_analytics -->|"uses report types"| node_types
node_csv -->|"uses storage types"| node_types

click node_app "https://github.com/vasanthselvamani/lending/blob/main/src/App.tsx"
click node_authview "https://github.com/vasanthselvamani/lending/blob/main/src/components/AuthScreen.tsx"
click node_api "https://github.com/vasanthselvamani/lending/blob/main/src/lib/api.ts"
click node_customers "https://github.com/vasanthselvamani/lending/blob/main/src/components/CustomersView.tsx"
click node_applications "https://github.com/vasanthselvamani/lending/blob/main/src/components/ApplicationsView.tsx"
click node_documents "https://github.com/vasanthselvamani/lending/blob/main/src/components/DocumentsView.tsx"
click node_sanction "https://github.com/vasanthselvamani/lending/blob/main/src/components/SanctionLetterView.tsx"
click node_kfs "https://github.com/vasanthselvamani/lending/blob/main/src/components/KfsGeneratorView.tsx"
click node_dashboard "https://github.com/vasanthselvamani/lending/blob/main/src/components/DashboardView.tsx"
click node_reportsview "https://github.com/vasanthselvamani/lending/blob/main/src/components/ReportsView.tsx"
click node_serverapi "https://github.com/vasanthselvamani/lending/blob/main/server.ts"
click node_calculator "https://github.com/vasanthselvamani/lending/blob/main/server/lib/loanCalculator.ts"
click node_analytics "https://github.com/vasanthselvamani/lending/blob/main/server/lib/analyticsAndReports.ts"
click node_pdf "https://github.com/vasanthselvamani/lending/blob/main/server/lib/pdfGenerator.ts"
click node_csv "https://github.com/vasanthselvamani/lending/blob/main/server/lib/csvEngine.ts"
click node_auth "https://github.com/vasanthselvamani/lending/blob/main/server/lib/auth.ts"
click node_settings "https://github.com/vasanthselvamani/lending/blob/main/server/lib/settingsStore.ts"
click node_backup "https://github.com/vasanthselvamani/lending/blob/main/src/components/BackupRestoreView.tsx"
click node_users "https://github.com/vasanthselvamani/lending/blob/main/src/components/UsersView.tsx"
click node_settingsview "https://github.com/vasanthselvamani/lending/blob/main/src/components/SettingsView.tsx"
click node_seed "https://github.com/vasanthselvamani/lending/blob/main/server/lib/seedData.ts"
click node_types "https://github.com/vasanthselvamani/lending/blob/main/src/types/lending.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_app,node_authview,node_api toneBlue
class node_customers,node_applications,node_documents,node_sanction,node_kfs,node_dashboard,node_reportsview toneAmber
class node_serverapi,node_calculator,node_analytics,node_pdf toneMint
class node_csv,node_auth,node_settings,node_backup,node_users,node_settingsview,node_seed,node_types toneRose
class node_staff toneIndigo
```

## Components

### Staff Workspace

- [Workspace Shell](https://github.com/vasanthselvamani/lending/blob/main/src/App.tsx): `src/App.tsx`
- [Sign In](https://github.com/vasanthselvamani/lending/blob/main/src/components/AuthScreen.tsx): `src/components/AuthScreen.tsx`
- [Bearer API Client](https://github.com/vasanthselvamani/lending/blob/main/src/lib/api.ts): `src/lib/api.ts`

### Loan Operations

- [Customers](https://github.com/vasanthselvamani/lending/blob/main/src/components/CustomersView.tsx): `src/components/CustomersView.tsx`
- [Applications](https://github.com/vasanthselvamani/lending/blob/main/src/components/ApplicationsView.tsx): `src/components/ApplicationsView.tsx`
- [Document Checklist](https://github.com/vasanthselvamani/lending/blob/main/src/components/DocumentsView.tsx): `src/components/DocumentsView.tsx`
- [Sanction Letters](https://github.com/vasanthselvamani/lending/blob/main/src/components/SanctionLetterView.tsx): `src/components/SanctionLetterView.tsx`
- [KFS and Repayment](https://github.com/vasanthselvamani/lending/blob/main/src/components/KfsGeneratorView.tsx): `src/components/KfsGeneratorView.tsx`
- [Dashboard](https://github.com/vasanthselvamani/lending/blob/main/src/components/DashboardView.tsx): `src/components/DashboardView.tsx`
- [Reports](https://github.com/vasanthselvamani/lending/blob/main/src/components/ReportsView.tsx): `src/components/ReportsView.tsx`

### API Services

- [Express API](https://github.com/vasanthselvamani/lending/blob/main/server.ts): `server.ts`
- [Loan Calculator](https://github.com/vasanthselvamani/lending/blob/main/server/lib/loanCalculator.ts): `server/lib/loanCalculator.ts`
- [Analytics Engine](https://github.com/vasanthselvamani/lending/blob/main/server/lib/analyticsAndReports.ts): `server/lib/analyticsAndReports.ts`
- [PDF Generator](https://github.com/vasanthselvamani/lending/blob/main/server/lib/pdfGenerator.ts): `server/lib/pdfGenerator.ts`

### Records and Controls

- [CSV Storage](https://github.com/vasanthselvamani/lending/blob/main/server/lib/csvEngine.ts): `server/lib/csvEngine.ts`
- [Authentication and RBAC](https://github.com/vasanthselvamani/lending/blob/main/server/lib/auth.ts): `server/lib/auth.ts`
- [Office Settings](https://github.com/vasanthselvamani/lending/blob/main/server/lib/settingsStore.ts): `server/lib/settingsStore.ts`
- [Backup and Restore](https://github.com/vasanthselvamani/lending/blob/main/src/components/BackupRestoreView.tsx): `src/components/BackupRestoreView.tsx`
- [Staff Accounts](https://github.com/vasanthselvamani/lending/blob/main/src/components/UsersView.tsx): `src/components/UsersView.tsx`
- [Settings UI](https://github.com/vasanthselvamani/lending/blob/main/src/components/SettingsView.tsx): `src/components/SettingsView.tsx`
- [Initial Sample Data](https://github.com/vasanthselvamani/lending/blob/main/server/lib/seedData.ts): `server/lib/seedData.ts`
- [Lending Domain Types](https://github.com/vasanthselvamani/lending/blob/main/src/types/lending.ts): `src/types/lending.ts`

### Other components

- **Office Staff**

## Connections

- Office Staff → Workspace Shell: uses (evidence: `README.md`)
- Workspace Shell → Sign In: renders (evidence: `src/App.tsx`)
- Workspace Shell → Customers: selects view (evidence: `src/App.tsx`)
- Workspace Shell → Applications: selects view (evidence: `src/App.tsx`)
- Workspace Shell → Document Checklist: selects view (evidence: `src/App.tsx`)
- Workspace Shell → Sanction Letters: selects view (evidence: `src/App.tsx`)
- Workspace Shell → KFS and Repayment: selects view (evidence: `src/App.tsx`)
- Workspace Shell → Dashboard: selects view (evidence: `src/App.tsx`)
- Workspace Shell → Reports: selects view (evidence: `src/App.tsx`)
- Workspace Shell → Backup and Restore: selects view (evidence: `src/App.tsx`)
- Workspace Shell → Staff Accounts: selects view (evidence: `src/App.tsx`)
- Workspace Shell → Settings UI: selects view (evidence: `src/App.tsx`)
- Sign In → Bearer API Client: submits credentials (evidence: `src/components/AuthScreen.tsx`)
- Workspace Shell → Bearer API Client: checks session (evidence: `src/App.tsx`)
- Customers → Bearer API Client: requests data (evidence: `src/components/CustomersView.tsx`)
- Applications → Bearer API Client: updates records (evidence: `src/components/ApplicationsView.tsx`)
- Document Checklist → Bearer API Client: requests data (evidence: `src/components/DocumentsView.tsx`)
- Sanction Letters → Bearer API Client: requests issuance (evidence: `src/components/SanctionLetterView.tsx`)
- KFS and Repayment → Bearer API Client: requests issuance (evidence: `src/components/KfsGeneratorView.tsx`)
- Dashboard → Bearer API Client: loads metrics (evidence: `src/components/DashboardView.tsx`)
- Reports → Bearer API Client: loads reports (evidence: `src/components/ReportsView.tsx`)
- Backup and Restore → Bearer API Client: requests backups (evidence: `src/components/BackupRestoreView.tsx`)
- Staff Accounts → Bearer API Client: manages users (evidence: `src/components/UsersView.tsx`)
- Settings UI → Bearer API Client: updates settings (evidence: `src/components/SettingsView.tsx`)
- Bearer API Client → Express API: sends HTTP requests (evidence: `README.md`)
- Express API → Authentication and RBAC: enforces access (evidence: `server.ts`)
- Express API → CSV Storage: reads and writes (evidence: `server.ts`)
- Express API → Loan Calculator: calculates loans (evidence: `server.ts`)
- Express API → Analytics Engine: builds reports (evidence: `server.ts`)
- Express API → PDF Generator: generates documents (evidence: `README.md`)
- Express API → Office Settings: loads configuration (evidence: `README.md`)
- Express API → Initial Sample Data: seeds on startup (evidence: `server.ts`)
- Express API → CSV Storage: initializes storage (evidence: `README.md`)
- Backup and Restore → Express API: requests restore (evidence: `src/components/BackupRestoreView.tsx`)
- Authentication and RBAC → CSV Storage: reads accounts (evidence: `server/lib/auth.ts`)
- Initial Sample Data → CSV Storage: writes sample records (evidence: `server/lib/seedData.ts`)
- Initial Sample Data → Loan Calculator: calculates samples (evidence: `server/lib/seedData.ts`)
- Initial Sample Data → Office Settings: uses defaults (evidence: `server/lib/seedData.ts`)
- Express API → Lending Domain Types: uses domain types (evidence: `server.ts`)
- Loan Calculator → Lending Domain Types: uses calculation types (evidence: `server/lib/loanCalculator.ts`)
- Analytics Engine → Lending Domain Types: uses report types (evidence: `server/lib/analyticsAndReports.ts`)
- CSV Storage → Lending Domain Types: uses storage types (evidence: `server/lib/csvEngine.ts`)
