# rajesh-kumar495/my-finance-app architecture

> Architecture diagram of the GitHub repository rajesh-kumar495/my-finance-app, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/rajesh-kumar495/my-finance-app
- Repository: https://github.com/rajesh-kumar495/my-finance-app

## Overview

This is a multi-role lending and finance application with an associated used-bike marketplace. Financiers manage offices, customers and loans; repayments, income and expenses feed reporting. Borrowers can request loans and track repayment status, while marketplace users browse and list bikes and financiers can register interest. The tree also shows office administration, financier approval and consulting workflows. Connections below follow sampled route behavior and explicit calls; many other routes and their client wiring are represented by their exact tree paths but were not sampled.

Main entry points: [`src/lib/prisma.ts`](https://github.com/rajesh-kumar495/my-finance-app/blob/master/src/lib/prisma.ts) (Application database), [`src/lib/validateUserOfficeAccess.ts`](https://github.com/rajesh-kumar495/my-finance-app/blob/master/src/lib/validateUserOfficeAccess.ts) (Office access checks), [`src/app/api/customers/add/route.ts`](https://github.com/rajesh-kumar495/my-finance-app/blob/master/src/app/api/customers/add/route.ts) (Create customer loan), [`src/app/api/loan-requests/route.ts`](https://github.com/rajesh-kumar495/my-finance-app/blob/master/src/app/api/loan-requests/route.ts) (Loan requests)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_access["Access and offices"]
  node_auth["Authentication<br/>[route.ts]"]
  node_office["Office settings<br/>[route.ts]"]
  node_office_access["Office access checks"]
end

subgraph group_lending["Lending operations"]
  node_customer_ui["Customer management<br/>[CustomerList.tsx]"]
  node_customer_create["Create customer loan<br/>[route.ts]"]
  node_loan_requests["Loan requests<br/>[route.ts]"]
  node_repayments["Repayment tracking<br/>[route.ts]"]
  node_borrower_loan_ui["Borrower loan dashboard<br/>[page.tsx]"]
end

subgraph group_finance["Accounting and reports"]
  node_income["Income records<br/>[route.ts]"]
  node_expenses["Expense records<br/>[route.ts]"]
  node_reports["Finance reports<br/>[route.ts]"]
  node_dashboard["Financier dashboard"]
end

subgraph group_market["Bike marketplace"]
  node_bikes["Bike listings<br/>[route.ts]"]
  node_bike_search["Bike search"]
  node_bike_interest["Finance interest<br/>[route.ts]"]
  node_consulting["Consulting marketplace"]
end

subgraph group_admin["Administration and consulting"]
  node_approval["Financier approval<br/>[route.ts]"]
  node_enquiries["Marketplace enquiries<br/>[route.ts]"]
end

node_financier(("Financier or accountant"))
node_borrower(("Borrower"))
node_shopper(("Marketplace user"))
node_database[("Application database<br/>[prisma.ts]")]
node_storage["Supabase image storage<br/>[supabaseAdmin.ts]"]

node_customer_ui -->|"creates loan"| node_customer_create
node_customer_create -->|"checks access"| node_office_access
node_customer_create -->|"creates customer, bike; updates cash"| node_database
node_loan_requests -->|"checks access"| node_office_access
node_loan_requests -->|"reads and writes requests"| node_database
node_repayments -->|"checks access"| node_office_access
node_repayments -->|"updates repayment balance"| node_database
node_income -->|"checks access"| node_office_access
node_income -->|"reads and writes income"| node_database
node_expenses -->|"checks access"| node_office_access
node_expenses -->|"reads and writes expenses"| node_database
node_reports -->|"checks access"| node_office_access
node_reports -->|"reads income and repayments"| node_database
node_bike_search -->|"posts interest"| node_bike_interest
node_bike_interest -->|"records interest"| node_database
node_customer_create -.->|"deletes customer images"| node_storage

click node_auth "https://github.com/rajesh-kumar495/my-finance-app/blob/master/src/app/api/auth/%5B...nextauth%5D/route.ts"
click node_office "https://github.com/rajesh-kumar495/my-finance-app/blob/master/src/app/api/office/update/route.ts"
click node_office_access "https://github.com/rajesh-kumar495/my-finance-app/blob/master/src/lib/validateUserOfficeAccess.ts"
click node_customer_ui "https://github.com/rajesh-kumar495/my-finance-app/blob/master/src/app/financier/components/customers/CustomerList.tsx"
click node_customer_create "https://github.com/rajesh-kumar495/my-finance-app/blob/master/src/app/api/customers/add/route.ts"
click node_loan_requests "https://github.com/rajesh-kumar495/my-finance-app/blob/master/src/app/api/loan-requests/route.ts"
click node_repayments "https://github.com/rajesh-kumar495/my-finance-app/blob/master/src/app/api/repayments/markpaid/route.ts"
click node_borrower_loan_ui "https://github.com/rajesh-kumar495/my-finance-app/blob/master/src/app/user/loan-dashboard/page.tsx"
click node_income "https://github.com/rajesh-kumar495/my-finance-app/blob/master/src/app/api/income/route.ts"
click node_expenses "https://github.com/rajesh-kumar495/my-finance-app/blob/master/src/app/api/expenses/route.ts"
click node_reports "https://github.com/rajesh-kumar495/my-finance-app/blob/master/src/app/api/reports/overall-incomes/route.ts"
click node_dashboard "https://github.com/rajesh-kumar495/my-finance-app/blob/master/src/app/financier/components/home/DashboardHomePage.tsx"
click node_bikes "https://github.com/rajesh-kumar495/my-finance-app/blob/master/src/app/api/bikes/route.ts"
click node_bike_search "https://github.com/rajesh-kumar495/my-finance-app/blob/master/src/app/user/components/SearchBikeClient.tsx"
click node_bike_interest "https://github.com/rajesh-kumar495/my-finance-app/blob/master/src/app/api/bike-interest/%5BbikeId%5D/route.ts"
click node_consulting "https://github.com/rajesh-kumar495/my-finance-app/blob/master/src/app/consulting/components/ConsultingBikesPage.tsx"
click node_approval "https://github.com/rajesh-kumar495/my-finance-app/blob/master/src/app/api/approve-financier/route.ts"
click node_enquiries "https://github.com/rajesh-kumar495/my-finance-app/blob/master/src/app/api/enquiries/route.ts"
click node_database "https://github.com/rajesh-kumar495/my-finance-app/blob/master/src/lib/prisma.ts"
click node_storage "https://github.com/rajesh-kumar495/my-finance-app/blob/master/src/lib/supabaseAdmin.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,node_office,node_office_access,node_shopper toneBlue
class node_customer_ui,node_customer_create,node_loan_requests,node_repayments,node_borrower_loan_ui,node_database,node_storage toneAmber
class node_income,node_expenses,node_reports,node_dashboard toneMint
class node_bikes,node_bike_search,node_bike_interest,node_consulting toneRose
class node_approval,node_enquiries,node_financier,node_borrower toneIndigo
```

## Components

### Access and offices

- [Authentication](https://github.com/rajesh-kumar495/my-finance-app/blob/master/src/app/api/auth/%5B...nextauth%5D/route.ts): `src/app/api/auth/[...nextauth]/route.ts`
- [Office settings](https://github.com/rajesh-kumar495/my-finance-app/blob/master/src/app/api/office/update/route.ts): `src/app/api/office/update/route.ts`
- [Office access checks](https://github.com/rajesh-kumar495/my-finance-app/blob/master/src/lib/validateUserOfficeAccess.ts): `src/lib/validateUserOfficeAccess.ts`

### Lending operations

- [Customer management](https://github.com/rajesh-kumar495/my-finance-app/blob/master/src/app/financier/components/customers/CustomerList.tsx): `src/app/financier/components/customers/CustomerList.tsx`
- [Create customer loan](https://github.com/rajesh-kumar495/my-finance-app/blob/master/src/app/api/customers/add/route.ts): `src/app/api/customers/add/route.ts`
- [Loan requests](https://github.com/rajesh-kumar495/my-finance-app/blob/master/src/app/api/loan-requests/route.ts): `src/app/api/loan-requests/route.ts`
- [Repayment tracking](https://github.com/rajesh-kumar495/my-finance-app/blob/master/src/app/api/repayments/markpaid/route.ts): `src/app/api/repayments/markpaid/route.ts`
- [Borrower loan dashboard](https://github.com/rajesh-kumar495/my-finance-app/blob/master/src/app/user/loan-dashboard/page.tsx): `src/app/user/loan-dashboard/page.tsx`

### Accounting and reports

- [Income records](https://github.com/rajesh-kumar495/my-finance-app/blob/master/src/app/api/income/route.ts): `src/app/api/income/route.ts`
- [Expense records](https://github.com/rajesh-kumar495/my-finance-app/blob/master/src/app/api/expenses/route.ts): `src/app/api/expenses/route.ts`
- [Finance reports](https://github.com/rajesh-kumar495/my-finance-app/blob/master/src/app/api/reports/overall-incomes/route.ts): `src/app/api/reports/overall-incomes/route.ts`
- [Financier dashboard](https://github.com/rajesh-kumar495/my-finance-app/blob/master/src/app/financier/components/home/DashboardHomePage.tsx): `src/app/financier/components/home/DashboardHomePage.tsx`

### Bike marketplace

- [Bike listings](https://github.com/rajesh-kumar495/my-finance-app/blob/master/src/app/api/bikes/route.ts): `src/app/api/bikes/route.ts`
- [Bike search](https://github.com/rajesh-kumar495/my-finance-app/blob/master/src/app/user/components/SearchBikeClient.tsx): `src/app/user/components/SearchBikeClient.tsx`
- [Finance interest](https://github.com/rajesh-kumar495/my-finance-app/blob/master/src/app/api/bike-interest/%5BbikeId%5D/route.ts): `src/app/api/bike-interest/[bikeId]/route.ts`
- [Consulting marketplace](https://github.com/rajesh-kumar495/my-finance-app/blob/master/src/app/consulting/components/ConsultingBikesPage.tsx): `src/app/consulting/components/ConsultingBikesPage.tsx`

### Administration and consulting

- [Financier approval](https://github.com/rajesh-kumar495/my-finance-app/blob/master/src/app/api/approve-financier/route.ts): `src/app/api/approve-financier/route.ts`
- [Marketplace enquiries](https://github.com/rajesh-kumar495/my-finance-app/blob/master/src/app/api/enquiries/route.ts): `src/app/api/enquiries/route.ts`

### Other components

- **Financier or accountant**
- **Borrower**
- **Marketplace user**
- [Application database](https://github.com/rajesh-kumar495/my-finance-app/blob/master/src/lib/prisma.ts): `src/lib/prisma.ts`
- [Supabase image storage](https://github.com/rajesh-kumar495/my-finance-app/blob/master/src/lib/supabaseAdmin.ts): `src/lib/supabaseAdmin.ts`

## Connections

- Customer management → Create customer loan: creates loan
- Create customer loan → Office access checks: checks access
- Create customer loan → Application database: creates customer, bike; updates cash
- Loan requests → Office access checks: checks access
- Loan requests → Application database: reads and writes requests
- Repayment tracking → Office access checks: checks access
- Repayment tracking → Application database: updates repayment balance
- Income records → Office access checks: checks access
- Income records → Application database: reads and writes income
- Expense records → Office access checks: checks access
- Expense records → Application database: reads and writes expenses
- Finance reports → Office access checks: checks access
- Finance reports → Application database: reads income and repayments
- Bike search → Finance interest: posts interest
- Finance interest → Application database: records interest
- Create customer loan → Supabase image storage: deletes customer images
