# nandha3d/loanapp architecture

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

- Interactive diagram: https://gitdiagram.com/nandha3d/loanapp
- Repository: https://github.com/nandha3d/loanapp

## Overview

ZoloFund is a multi-tenant financial-services platform for lending and related products. Its principal workflow is managing tenants and customers, originating and servicing loans, collecting repayments, and reviewing operational results; parallel capabilities include chit funds, premium accounting, KYC, and administration. The tree and excerpts support the major product areas, but README provides no product documentation and much of the implementation was not sampled. Dashed links mark plausible user entry points only; solid links are limited to relationships evidenced by excerpts or SOURCE INDEX references.

Main entry points: [`lib/db.ts`](https://github.com/nandha3d/loanapp/blob/main/lib/db.ts) (Application database), [`app/api/v1/customers/route.ts`](https://github.com/nandha3d/loanapp/blob/main/app/api/v1/customers/route.ts) (Customer management), [`app/api/register/email/route.ts`](https://github.com/nandha3d/loanapp/blob/main/app/api/register/email/route.ts) (Tenant registration), [`app/api/v1/loans/route.ts`](https://github.com/nandha3d/loanapp/blob/main/app/api/v1/loans/route.ts) (Loan origination)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_tenant["Tenant and access"]
  node_registration["Tenant registration<br/>[route.ts]"]
  node_tenant_context["Tenant context<br/>[tenant.ts]"]
  node_module_access["Module access<br/>[modules.ts]"]
  node_auth["Authentication<br/>[auth.ts]"]
  node_api_auth["API authentication<br/>[v1-auth.ts]"]
  node_envelope["API responses<br/>[v1-envelope.ts]"]
end

subgraph group_lending["Customer and lending"]
  node_customer_api["Customer management<br/>[route.ts]"]
  node_loan_api["Loan origination<br/>[route.ts]"]
  node_loan_servicing["Loan servicing"]
end

subgraph group_operations["Collections and operations"]
  node_dashboard_api["Operational dashboard<br/>[route.ts]"]
  node_collections["Repayment collection"]
  node_collection_runs["Collection runs<br/>[runActions.ts]"]
  node_approvals["Approvals<br/>[actions.ts]"]
  node_kyc["KYC review"]
end

subgraph group_products["Financial products"]
  node_chits["Chit fund auctions<br/>[bidService.ts]"]
  node_accounting["Premium accounting"]
  node_bureau["Credit bureau<br/>[bureauService.ts]"]
  node_npa["NPA management<br/>[npaService.ts]"]
  node_borrower_portal["Borrower portal"]
end

subgraph group_platform["Platform administration"]
  node_database[("Application database<br/>[db.ts]")]
  node_admin["Tenant administration<br/>[actions.ts]"]
  node_settings["Tenant settings<br/>[actions.ts]"]
end

node_user(("Staff user"))
node_borrower(("Borrower"))

node_user -.->|"registers tenant"| node_registration
node_registration -->|"creates records"| node_database
node_registration -->|"uses tenant"| node_tenant_context
node_registration -->|"selects modules"| node_module_access
node_user -.->|"manages customers"| node_customer_api
node_customer_api -->|"authenticates"| node_api_auth
node_customer_api -->|"reads and writes"| node_database
node_customer_api -->|"loads branding"| node_tenant_context
node_user -.->|"originates loans"| node_loan_api
node_loan_api -->|"authenticates"| node_api_auth
node_loan_api -->|"reads and writes"| node_database
node_loan_api -->|"checks features"| node_module_access
node_user -.->|"views metrics"| node_dashboard_api
node_dashboard_api -->|"authenticates"| node_api_auth
node_dashboard_api -->|"queries operations"| node_database
node_user -.->|"records repayments"| node_collections
node_user -.->|"reconciles collections"| node_collection_runs
node_user -.->|"reviews requests"| node_approvals
node_user -.->|"reviews KYC"| node_kyc
node_kyc -->|"opens customer profile"| node_customer_api
node_user -.->|"runs auctions"| node_chits
node_user -.->|"uses accounting"| node_accounting
node_user -.->|"requests bureau data"| node_bureau
node_user -.->|"manages NPA"| node_npa
node_borrower -.->|"views account"| node_borrower_portal
node_borrower_portal -->|"uses dashboard actions"| node_auth
node_user -.->|"administers tenants"| node_admin
node_admin -->|"uses tenant data"| node_database
node_user -.->|"configures tenant"| node_settings
node_settings -->|"uses tenant data"| node_database
node_api_auth -->|"uses responses"| node_envelope

click node_registration "https://github.com/nandha3d/loanapp/blob/main/app/api/register/email/route.ts"
click node_tenant_context "https://github.com/nandha3d/loanapp/blob/main/lib/tenant.ts"
click node_module_access "https://github.com/nandha3d/loanapp/blob/main/types/modules.ts"
click node_auth "https://github.com/nandha3d/loanapp/blob/main/lib/auth.ts"
click node_database "https://github.com/nandha3d/loanapp/blob/main/lib/db.ts"
click node_customer_api "https://github.com/nandha3d/loanapp/blob/main/app/api/v1/customers/route.ts"
click node_loan_api "https://github.com/nandha3d/loanapp/blob/main/app/api/v1/loans/route.ts"
click node_loan_servicing "https://github.com/nandha3d/loanapp/blob/main/app/(dashboard)/%5Bmodule%5D/loans/%5Bid%5D/LoanDetailClient.tsx"
click node_dashboard_api "https://github.com/nandha3d/loanapp/blob/main/app/api/v1/dashboard/route.ts"
click node_collections "https://github.com/nandha3d/loanapp/blob/main/app/(dashboard)/%5Bmodule%5D/collection/CollectionClient.tsx"
click node_collection_runs "https://github.com/nandha3d/loanapp/blob/main/app/(dashboard)/%5Bmodule%5D/collection/runActions.ts"
click node_approvals "https://github.com/nandha3d/loanapp/blob/main/app/(dashboard)/%5Bmodule%5D/approvals/actions.ts"
click node_kyc "https://github.com/nandha3d/loanapp/blob/main/app/(dashboard)/%5Bmodule%5D/kyc-review/KycReviewClient.tsx"
click node_chits "https://github.com/nandha3d/loanapp/blob/main/lib/chits/bidService.ts"
click node_accounting "https://github.com/nandha3d/loanapp/blob/main/lib/accounting/premiumMobileService.ts"
click node_bureau "https://github.com/nandha3d/loanapp/blob/main/lib/bureau/bureauService.ts"
click node_npa "https://github.com/nandha3d/loanapp/blob/main/lib/npa/npaService.ts"
click node_borrower_portal "https://github.com/nandha3d/loanapp/blob/main/app/borrower/dashboard/BorrowerDashboardClient.tsx"
click node_admin "https://github.com/nandha3d/loanapp/blob/main/app/admin/actions.ts"
click node_settings "https://github.com/nandha3d/loanapp/blob/main/app/(dashboard)/%5Bmodule%5D/settings/actions.ts"
click node_api_auth "https://github.com/nandha3d/loanapp/blob/main/lib/api/v1-auth.ts"
click node_envelope "https://github.com/nandha3d/loanapp/blob/main/lib/api/v1-envelope.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_registration,node_tenant_context,node_module_access,node_auth,node_api_auth,node_envelope,node_user toneBlue
class node_customer_api,node_loan_api,node_loan_servicing toneAmber
class node_dashboard_api,node_collections,node_collection_runs,node_approvals,node_kyc toneMint
class node_chits,node_accounting,node_bureau,node_npa,node_borrower_portal toneRose
class node_database,node_admin,node_settings,node_borrower toneIndigo
```

## Components

### Tenant and access

- [Tenant registration](https://github.com/nandha3d/loanapp/blob/main/app/api/register/email/route.ts): `app/api/register/email/route.ts`
- [Tenant context](https://github.com/nandha3d/loanapp/blob/main/lib/tenant.ts): `lib/tenant.ts`
- [Module access](https://github.com/nandha3d/loanapp/blob/main/types/modules.ts): `types/modules.ts`
- [Authentication](https://github.com/nandha3d/loanapp/blob/main/lib/auth.ts): `lib/auth.ts`
- [API authentication](https://github.com/nandha3d/loanapp/blob/main/lib/api/v1-auth.ts): `lib/api/v1-auth.ts`
- [API responses](https://github.com/nandha3d/loanapp/blob/main/lib/api/v1-envelope.ts): `lib/api/v1-envelope.ts`

### Customer and lending

- [Customer management](https://github.com/nandha3d/loanapp/blob/main/app/api/v1/customers/route.ts): `app/api/v1/customers/route.ts`
- [Loan origination](https://github.com/nandha3d/loanapp/blob/main/app/api/v1/loans/route.ts): `app/api/v1/loans/route.ts`
- [Loan servicing](https://github.com/nandha3d/loanapp/blob/main/app/(dashboard)/%5Bmodule%5D/loans/%5Bid%5D/LoanDetailClient.tsx): `app/(dashboard)/[module]/loans/[id]/LoanDetailClient.tsx`

### Collections and operations

- [Operational dashboard](https://github.com/nandha3d/loanapp/blob/main/app/api/v1/dashboard/route.ts): `app/api/v1/dashboard/route.ts`
- [Repayment collection](https://github.com/nandha3d/loanapp/blob/main/app/(dashboard)/%5Bmodule%5D/collection/CollectionClient.tsx): `app/(dashboard)/[module]/collection/CollectionClient.tsx`
- [Collection runs](https://github.com/nandha3d/loanapp/blob/main/app/(dashboard)/%5Bmodule%5D/collection/runActions.ts): `app/(dashboard)/[module]/collection/runActions.ts`
- [Approvals](https://github.com/nandha3d/loanapp/blob/main/app/(dashboard)/%5Bmodule%5D/approvals/actions.ts): `app/(dashboard)/[module]/approvals/actions.ts`
- [KYC review](https://github.com/nandha3d/loanapp/blob/main/app/(dashboard)/%5Bmodule%5D/kyc-review/KycReviewClient.tsx): `app/(dashboard)/[module]/kyc-review/KycReviewClient.tsx`

### Financial products

- [Chit fund auctions](https://github.com/nandha3d/loanapp/blob/main/lib/chits/bidService.ts): `lib/chits/bidService.ts`
- [Premium accounting](https://github.com/nandha3d/loanapp/blob/main/lib/accounting/premiumMobileService.ts): `lib/accounting/premiumMobileService.ts`
- [Credit bureau](https://github.com/nandha3d/loanapp/blob/main/lib/bureau/bureauService.ts): `lib/bureau/bureauService.ts`
- [NPA management](https://github.com/nandha3d/loanapp/blob/main/lib/npa/npaService.ts): `lib/npa/npaService.ts`
- [Borrower portal](https://github.com/nandha3d/loanapp/blob/main/app/borrower/dashboard/BorrowerDashboardClient.tsx): `app/borrower/dashboard/BorrowerDashboardClient.tsx`

### Platform administration

- [Application database](https://github.com/nandha3d/loanapp/blob/main/lib/db.ts): `lib/db.ts`
- [Tenant administration](https://github.com/nandha3d/loanapp/blob/main/app/admin/actions.ts): `app/admin/actions.ts`
- [Tenant settings](https://github.com/nandha3d/loanapp/blob/main/app/(dashboard)/%5Bmodule%5D/settings/actions.ts): `app/(dashboard)/[module]/settings/actions.ts`

### Other components

- **Staff user**
- **Borrower**

## Connections

- Staff user → Tenant registration: registers tenant
- Tenant registration → Application database: creates records (evidence: `app/api/register/email/route.ts`)
- Tenant registration → Tenant context: uses tenant (evidence: `app/api/register/email/route.ts`)
- Tenant registration → Module access: selects modules (evidence: `app/api/register/email/route.ts`)
- Staff user → Customer management: manages customers
- Customer management → API authentication: authenticates (evidence: `app/api/v1/customers/route.ts`)
- Customer management → Application database: reads and writes (evidence: `app/api/v1/customers/route.ts`)
- Customer management → Tenant context: loads branding (evidence: `app/api/v1/customers/route.ts`)
- Staff user → Loan origination: originates loans
- Loan origination → API authentication: authenticates (evidence: `app/api/v1/loans/route.ts`)
- Loan origination → Application database: reads and writes (evidence: `app/api/v1/loans/route.ts`)
- Loan origination → Module access: checks features (evidence: `app/api/v1/loans/route.ts`)
- Staff user → Operational dashboard: views metrics
- Operational dashboard → API authentication: authenticates (evidence: `app/api/v1/dashboard/route.ts`)
- Operational dashboard → Application database: queries operations (evidence: `app/api/v1/dashboard/route.ts`)
- Staff user → Repayment collection: records repayments
- Staff user → Collection runs: reconciles collections
- Staff user → Approvals: reviews requests
- Staff user → KYC review: reviews KYC
- KYC review → Customer management: opens customer profile (evidence: `app/(dashboard)/[module]/kyc-review/KycReviewClient.tsx`)
- Staff user → Chit fund auctions: runs auctions
- Staff user → Premium accounting: uses accounting
- Staff user → Credit bureau: requests bureau data
- Staff user → NPA management: manages NPA
- Borrower → Borrower portal: views account
- Borrower portal → Authentication: uses dashboard actions (evidence: `app/borrower/dashboard/BorrowerDashboardClient.tsx`)
- Staff user → Tenant administration: administers tenants
- Tenant administration → Application database: uses tenant data (evidence: `app/admin/actions.ts`)
- Staff user → Tenant settings: configures tenant
- Tenant settings → Application database: uses tenant data (evidence: `app/(dashboard)/[module]/settings/actions.ts`)
- API authentication → API responses: uses responses (evidence: `lib/api/v1-auth.ts`)
