# shashank3876/creditsea architecture

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

- Interactive diagram: https://gitdiagram.com/shashank3876/creditsea
- Repository: https://github.com/shashank3876/creditsea

## Overview

CreditSea is a personal-loan lifecycle product with a borrower portal and a role-restricted operations workspace backed by an Express API. Borrowers register, maintain a profile, check eligibility, upload a salary slip, apply, and track loans; staff review leads, sanction applications, disburse loans, and record collections. The API enforces authentication and role permissions and persists lifecycle records in MongoDB, with private object storage for salary slips. The graph also retains the separate mockup preview app visible in the tree; its relationships are limited to those shown in its excerpt.

Main entry points: [`artifacts/api-server/src/app.ts`](https://github.com/shashank3876/creditsea/blob/main/artifacts/api-server/src/app.ts) (REST API app), [`artifacts/api-server/src/lib/models.ts`](https://github.com/shashank3876/creditsea/blob/main/artifacts/api-server/src/lib/models.ts) (Loan and account models), [`artifacts/api-server/src/routes/borrower.ts`](https://github.com/shashank3876/creditsea/blob/main/artifacts/api-server/src/routes/borrower.ts) (Borrower endpoints), [`artifacts/api-server/src/routes/auth.ts`](https://github.com/shashank3876/creditsea/blob/main/artifacts/api-server/src/routes/auth.ts) (Authentication)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web portal"]
  node_borrower["Borrower portal<br/>[portal.tsx]"]
  node_opsui["Operations workspace<br/>[portal.tsx]"]
  node_authui["Sign-in and signup<br/>[portal.tsx]"]
  node_borrowerpages["Borrower pages"]
  node_opspages["Operations pages"]
end

subgraph group_api["API workflows"]
  node_api["REST API app<br/>[app.ts]"]
  node_auth["Authentication<br/>[auth.ts]"]
  node_borrowerapi["Borrower endpoints<br/>[borrower.ts]"]
  node_sales["Sales review<br/>[operations.ts]"]
  node_sanction["Sanction decisions<br/>[operations.ts]"]
  node_disbursement["Loan disbursement<br/>[operations.ts]"]
  node_collection["Payment collection<br/>[operations.ts]"]
  node_employees["Employee management<br/>[employees.ts]"]
  node_health["Health check<br/>[health.ts]"]
end

subgraph group_core["Domain and security"]
  node_domain["Eligibility and loan rules<br/>[domain.ts]"]
  node_security["Sessions and authorization<br/>[security.ts]"]
  node_validation["Request validation<br/>[validation.ts]"]
  node_dto["Response mapping<br/>[dto.ts]"]
  node_errors["Error handling<br/>[errorHandler.ts]"]
end

subgraph group_state["Persistence and files"]
  node_models[("Loan and account models<br/>[models.ts]")]
  node_mongo[("MongoDB")]
  node_storage[("Private salary-slip storage<br/>[privateStorage.ts]")]
end

subgraph group_preview["Mockup preview"]
  node_previewapp["Preview renderer<br/>[App.tsx]"]
  node_previewmodules["Discovered components<br/>[App.tsx]"]
end

node_actor(("Borrower or staff"))
node_objectstore[("Private object store")]

node_actor -->|"signs in"| node_authui
node_actor -->|"manages loans"| node_borrower
node_actor -->|"handles workflow"| node_opsui
node_borrowerpages -->|"renders"| node_borrower
node_opspages -->|"renders"| node_opsui
node_authui -.->|"calls same-origin API"| node_api
node_borrower -.->|"calls same-origin API"| node_api
node_opsui -.->|"calls same-origin API"| node_api
node_api -->|"routes requests"| node_auth
node_api -->|"routes requests"| node_borrowerapi
node_api -->|"routes requests"| node_sales
node_api -->|"routes requests"| node_sanction
node_api -->|"routes requests"| node_disbursement
node_api -->|"routes requests"| node_collection
node_api -->|"routes requests"| node_employees
node_api -->|"routes requests"| node_health
node_api -->|"handles errors"| node_errors
node_auth -->|"sets sessions"| node_security
node_auth -->|"validates input"| node_validation
node_auth -->|"reads and creates users"| node_models
node_auth -->|"maps users"| node_dto
node_borrowerapi -->|"checks eligibility"| node_domain
node_borrowerapi -->|"reads and writes records"| node_models
node_borrowerapi -->|"saves and streams files"| node_storage
node_borrowerapi -->|"authorizes requests"| node_security
node_borrowerapi -->|"maps responses"| node_dto
node_sales -->|"queries leads"| node_models
node_sales -->|"checks roles"| node_security
node_sanction -->|"checks loan rules"| node_domain
node_sanction -->|"updates loan decisions"| node_models
node_sanction -->|"streams salary slips"| node_storage
node_disbursement -->|"updates loans"| node_models
node_collection -->|"validates payment UTR"| node_domain
node_collection -->|"records payments"| node_models
node_models -.->|"persists records"| node_mongo
node_storage -->|"stores and streams files"| node_objectstore
node_previewapp -->|"loads components"| node_previewmodules

click node_borrower "https://github.com/shashank3876/creditsea/blob/main/artifacts/creditsea-lms/src/components/portal.tsx"
click node_opsui "https://github.com/shashank3876/creditsea/blob/main/artifacts/creditsea-lms/src/components/portal.tsx"
click node_authui "https://github.com/shashank3876/creditsea/blob/main/artifacts/creditsea-lms/src/components/portal.tsx"
click node_borrowerpages "https://github.com/shashank3876/creditsea/tree/main/artifacts/creditsea-lms/src/app/borrower"
click node_opspages "https://github.com/shashank3876/creditsea/tree/main/artifacts/creditsea-lms/src/app/operations"
click node_api "https://github.com/shashank3876/creditsea/blob/main/artifacts/api-server/src/app.ts"
click node_auth "https://github.com/shashank3876/creditsea/blob/main/artifacts/api-server/src/routes/auth.ts"
click node_borrowerapi "https://github.com/shashank3876/creditsea/blob/main/artifacts/api-server/src/routes/borrower.ts"
click node_sales "https://github.com/shashank3876/creditsea/blob/main/artifacts/api-server/src/routes/operations.ts"
click node_sanction "https://github.com/shashank3876/creditsea/blob/main/artifacts/api-server/src/routes/operations.ts"
click node_disbursement "https://github.com/shashank3876/creditsea/blob/main/artifacts/api-server/src/routes/operations.ts"
click node_collection "https://github.com/shashank3876/creditsea/blob/main/artifacts/api-server/src/routes/operations.ts"
click node_employees "https://github.com/shashank3876/creditsea/blob/main/artifacts/api-server/src/routes/employees.ts"
click node_health "https://github.com/shashank3876/creditsea/blob/main/artifacts/api-server/src/routes/health.ts"
click node_domain "https://github.com/shashank3876/creditsea/blob/main/artifacts/api-server/src/lib/domain.ts"
click node_security "https://github.com/shashank3876/creditsea/blob/main/artifacts/api-server/src/lib/security.ts"
click node_validation "https://github.com/shashank3876/creditsea/blob/main/artifacts/api-server/src/lib/validation.ts"
click node_dto "https://github.com/shashank3876/creditsea/blob/main/artifacts/api-server/src/lib/dto.ts"
click node_errors "https://github.com/shashank3876/creditsea/blob/main/artifacts/api-server/src/middlewares/errorHandler.ts"
click node_models "https://github.com/shashank3876/creditsea/blob/main/artifacts/api-server/src/lib/models.ts"
click node_storage "https://github.com/shashank3876/creditsea/blob/main/artifacts/api-server/src/lib/privateStorage.ts"
click node_previewapp "https://github.com/shashank3876/creditsea/blob/main/artifacts/mockup-sandbox/src/App.tsx"
click node_previewmodules "https://github.com/shashank3876/creditsea/blob/main/artifacts/mockup-sandbox/src/App.tsx"

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_borrower,node_opsui,node_authui,node_borrowerpages,node_opspages toneBlue
class node_api,node_auth,node_borrowerapi,node_sales,node_sanction,node_disbursement,node_collection,node_employees,node_health,node_objectstore toneAmber
class node_domain,node_security,node_validation,node_dto,node_errors toneMint
class node_models,node_mongo,node_storage toneRose
class node_previewapp,node_previewmodules,node_actor toneIndigo
```

## Components

### Web portal

- [Borrower portal](https://github.com/shashank3876/creditsea/blob/main/artifacts/creditsea-lms/src/components/portal.tsx): `artifacts/creditsea-lms/src/components/portal.tsx`
- [Operations workspace](https://github.com/shashank3876/creditsea/blob/main/artifacts/creditsea-lms/src/components/portal.tsx): `artifacts/creditsea-lms/src/components/portal.tsx`
- [Sign-in and signup](https://github.com/shashank3876/creditsea/blob/main/artifacts/creditsea-lms/src/components/portal.tsx): `artifacts/creditsea-lms/src/components/portal.tsx`
- [Borrower pages](https://github.com/shashank3876/creditsea/tree/main/artifacts/creditsea-lms/src/app/borrower): `artifacts/creditsea-lms/src/app/borrower`
- [Operations pages](https://github.com/shashank3876/creditsea/tree/main/artifacts/creditsea-lms/src/app/operations): `artifacts/creditsea-lms/src/app/operations`

### API workflows

- [REST API app](https://github.com/shashank3876/creditsea/blob/main/artifacts/api-server/src/app.ts): `artifacts/api-server/src/app.ts`
- [Authentication](https://github.com/shashank3876/creditsea/blob/main/artifacts/api-server/src/routes/auth.ts): `artifacts/api-server/src/routes/auth.ts`
- [Borrower endpoints](https://github.com/shashank3876/creditsea/blob/main/artifacts/api-server/src/routes/borrower.ts): `artifacts/api-server/src/routes/borrower.ts`
- [Sales review](https://github.com/shashank3876/creditsea/blob/main/artifacts/api-server/src/routes/operations.ts): `artifacts/api-server/src/routes/operations.ts`
- [Sanction decisions](https://github.com/shashank3876/creditsea/blob/main/artifacts/api-server/src/routes/operations.ts): `artifacts/api-server/src/routes/operations.ts`
- [Loan disbursement](https://github.com/shashank3876/creditsea/blob/main/artifacts/api-server/src/routes/operations.ts): `artifacts/api-server/src/routes/operations.ts`
- [Payment collection](https://github.com/shashank3876/creditsea/blob/main/artifacts/api-server/src/routes/operations.ts): `artifacts/api-server/src/routes/operations.ts`
- [Employee management](https://github.com/shashank3876/creditsea/blob/main/artifacts/api-server/src/routes/employees.ts): `artifacts/api-server/src/routes/employees.ts`
- [Health check](https://github.com/shashank3876/creditsea/blob/main/artifacts/api-server/src/routes/health.ts): `artifacts/api-server/src/routes/health.ts`

### Domain and security

- [Eligibility and loan rules](https://github.com/shashank3876/creditsea/blob/main/artifacts/api-server/src/lib/domain.ts): `artifacts/api-server/src/lib/domain.ts`
- [Sessions and authorization](https://github.com/shashank3876/creditsea/blob/main/artifacts/api-server/src/lib/security.ts): `artifacts/api-server/src/lib/security.ts`
- [Request validation](https://github.com/shashank3876/creditsea/blob/main/artifacts/api-server/src/lib/validation.ts): `artifacts/api-server/src/lib/validation.ts`
- [Response mapping](https://github.com/shashank3876/creditsea/blob/main/artifacts/api-server/src/lib/dto.ts): `artifacts/api-server/src/lib/dto.ts`
- [Error handling](https://github.com/shashank3876/creditsea/blob/main/artifacts/api-server/src/middlewares/errorHandler.ts): `artifacts/api-server/src/middlewares/errorHandler.ts`

### Persistence and files

- [Loan and account models](https://github.com/shashank3876/creditsea/blob/main/artifacts/api-server/src/lib/models.ts): `artifacts/api-server/src/lib/models.ts`
- **MongoDB**
- [Private salary-slip storage](https://github.com/shashank3876/creditsea/blob/main/artifacts/api-server/src/lib/privateStorage.ts): `artifacts/api-server/src/lib/privateStorage.ts`

### Mockup preview

- [Preview renderer](https://github.com/shashank3876/creditsea/blob/main/artifacts/mockup-sandbox/src/App.tsx): `artifacts/mockup-sandbox/src/App.tsx`
- [Discovered components](https://github.com/shashank3876/creditsea/blob/main/artifacts/mockup-sandbox/src/App.tsx): `artifacts/mockup-sandbox/src/App.tsx`

### Other components

- **Borrower or staff**
- **Private object store**

## Connections

- Borrower or staff → Sign-in and signup: signs in (evidence: `README.md`)
- Borrower or staff → Borrower portal: manages loans (evidence: `README.md`)
- Borrower or staff → Operations workspace: handles workflow (evidence: `README.md`)
- Borrower pages → Borrower portal: renders (evidence: `artifacts/creditsea-lms/src/app/borrower/page.tsx`)
- Operations pages → Operations workspace: renders (evidence: `artifacts/creditsea-lms/src/app/operations/page.tsx`)
- Sign-in and signup → REST API app: calls same-origin API (evidence: `README.md`)
- Borrower portal → REST API app: calls same-origin API (evidence: `README.md`)
- Operations workspace → REST API app: calls same-origin API (evidence: `README.md`)
- REST API app → Authentication: routes requests
- REST API app → Borrower endpoints: routes requests
- REST API app → Sales review: routes requests
- REST API app → Sanction decisions: routes requests
- REST API app → Loan disbursement: routes requests
- REST API app → Payment collection: routes requests
- REST API app → Employee management: routes requests
- REST API app → Health check: routes requests
- REST API app → Error handling: handles errors (evidence: `artifacts/api-server/src/app.ts`)
- Authentication → Sessions and authorization: sets sessions (evidence: `artifacts/api-server/src/routes/auth.ts`)
- Authentication → Request validation: validates input (evidence: `artifacts/api-server/src/routes/auth.ts`)
- Authentication → Loan and account models: reads and creates users (evidence: `artifacts/api-server/src/routes/auth.ts`)
- Authentication → Response mapping: maps users (evidence: `artifacts/api-server/src/routes/auth.ts`)
- Borrower endpoints → Eligibility and loan rules: checks eligibility (evidence: `artifacts/api-server/src/routes/borrower.ts`)
- Borrower endpoints → Loan and account models: reads and writes records (evidence: `artifacts/api-server/src/routes/borrower.ts`)
- Borrower endpoints → Private salary-slip storage: saves and streams files (evidence: `artifacts/api-server/src/routes/borrower.ts`)
- Borrower endpoints → Sessions and authorization: authorizes requests (evidence: `artifacts/api-server/src/routes/borrower.ts`)
- Borrower endpoints → Response mapping: maps responses (evidence: `artifacts/api-server/src/routes/borrower.ts`)
- Sales review → Loan and account models: queries leads (evidence: `artifacts/api-server/src/routes/operations.ts`)
- Sales review → Sessions and authorization: checks roles (evidence: `artifacts/api-server/src/routes/operations.ts`)
- Sanction decisions → Eligibility and loan rules: checks loan rules (evidence: `artifacts/api-server/src/routes/operations.ts`)
- Sanction decisions → Loan and account models: updates loan decisions (evidence: `artifacts/api-server/src/routes/operations.ts`)
- Sanction decisions → Private salary-slip storage: streams salary slips (evidence: `artifacts/api-server/src/routes/operations.ts`)
- Loan disbursement → Loan and account models: updates loans (evidence: `artifacts/api-server/src/routes/operations.ts`)
- Payment collection → Eligibility and loan rules: validates payment UTR (evidence: `artifacts/api-server/src/routes/operations.ts`)
- Payment collection → Loan and account models: records payments (evidence: `artifacts/api-server/src/routes/operations.ts`)
- Loan and account models → MongoDB: persists records (evidence: `README.md`)
- Private salary-slip storage → Private object store: stores and streams files (evidence: `artifacts/api-server/src/lib/privateStorage.ts`)
- Preview renderer → Discovered components: loads components (evidence: `artifacts/mockup-sandbox/src/App.tsx`)
