# mewindev/gdfi-dms architecture

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

- Interactive diagram: https://gitdiagram.com/mewindev/gdfi-dms
- Repository: https://github.com/mewindev/gdfi-dms

## Overview

GDFI DMS is a loan-document management application for tracking physical and digital loan records from release through archival retention. Its central workflow lets a Loan Associate search a promissory note (PN) in MyLoans, preview and open a DMS loan file, then work through classification, transactions, checklist and document-ID stages, assignments, and notifications; later lifecycle stages are represented in the Journey view. The product also includes funds requests, job and custody tracking, monitoring, administration, and CSV import. Edges use README statements or shown/indexed references; unsampled implementation details are not asserted.

Main entry points: [`lib/db.ts`](https://github.com/mewindev/gdfi-dms/blob/main/lib/db.ts) (PostgreSQL), [`app/(app)/loans/[pn]/page.tsx`](https://github.com/mewindev/gdfi-dms/blob/main/app/(app)/loans/%5Bpn%5D/page.tsx) (Loan File), [`lib/services/borrower-review.ts`](https://github.com/mewindev/gdfi-dms/blob/main/lib/services/borrower-review.ts) (Borrower Review), [`lib/myloans/client.ts`](https://github.com/mewindev/gdfi-dms/blob/main/lib/myloans/client.ts) (MyLoans Adapter)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_loan_flow["Loan File Workflow"]
  node_search["PN Search<br/>[page.tsx]"]
  node_myloans["MyLoans Adapter<br/>[client.ts]"]
  node_loan_file["Loan File<br/>[page.tsx]"]
  node_source_review["Source Review<br/>[source-review.ts]"]
  node_borrower_review["Borrower Review<br/>[borrower-review.ts]"]
  node_journey["Loan Journey<br/>[journey-client.tsx]"]
end

subgraph group_operations["Operations"]
  node_jobs["Job Tracking<br/>[page.tsx]"]
  node_funds["Cash Advances<br/>[page.tsx]"]
  node_funds_rules["Funds Rules<br/>[rules.ts]"]
  node_monitoring["Monitoring<br/>[page.tsx]"]
end

subgraph group_admin["Administration"]
  node_branches["Branch Management<br/>[branches.ts]"]
  node_settings["System Settings<br/>[settings.ts]"]
  node_csv_import["CSV Import<br/>[importer.ts]"]
end

subgraph group_platform["Application Services"]
  node_notifications["Notifications<br/>[notify.ts]"]
  node_email_outbox["Email Outbox<br/>[outbox.ts]"]
  node_auth["Authentication<br/>[current-user.ts]"]
  node_database[("PostgreSQL<br/>[db.ts]")]
end

node_associate(("Loan Associate"))
node_admin_user(("Admin"))
node_email_service["Email Provider"]

node_associate -->|"searches PN"| node_search
node_search -->|"looks up PN"| node_myloans
node_associate -->|"opens loan"| node_loan_file
node_loan_file -->|"refreshes from"| node_myloans
node_loan_file -->|"reviews changes"| node_source_review
node_loan_file -->|"reviews borrower"| node_borrower_review
node_loan_file -->|"shows stages"| node_journey
node_myloans -->|"reads records"| node_database
node_source_review -->|"reads and writes"| node_database
node_borrower_review -->|"updates loan"| node_database
node_borrower_review -->|"notifies reviewers"| node_notifications
node_funds -->|"applies rules"| node_funds_rules
node_funds -->|"reads and writes"| node_database
node_funds_rules -->|"uses calendar settings"| node_database
node_monitoring -->|"loads monitoring"| node_database
node_admin_user -->|"manages branches"| node_branches
node_branches -.->|"manages branch data"| node_database
node_admin_user -->|"configures system"| node_settings
node_settings -->|"reads and writes"| node_database
node_admin_user -->|"imports data"| node_csv_import
node_csv_import -.->|"imports records"| node_database
node_email_outbox -->|"stores outbox"| node_database
node_email_outbox -.->|"sends messages"| node_email_service
node_associate -->|"signs in"| node_auth
node_admin_user -->|"signs in"| node_auth
node_auth -->|"loads user"| node_database

click node_search "https://github.com/mewindev/gdfi-dms/blob/main/app/(app)/search/page.tsx"
click node_myloans "https://github.com/mewindev/gdfi-dms/blob/main/lib/myloans/client.ts"
click node_loan_file "https://github.com/mewindev/gdfi-dms/blob/main/app/(app)/loans/%5Bpn%5D/page.tsx"
click node_source_review "https://github.com/mewindev/gdfi-dms/blob/main/lib/services/source-review.ts"
click node_borrower_review "https://github.com/mewindev/gdfi-dms/blob/main/lib/services/borrower-review.ts"
click node_journey "https://github.com/mewindev/gdfi-dms/blob/main/components/loan/journey/journey-client.tsx"
click node_jobs "https://github.com/mewindev/gdfi-dms/blob/main/app/(app)/jobs/%5Bid%5D/page.tsx"
click node_funds "https://github.com/mewindev/gdfi-dms/blob/main/app/(app)/funds/page.tsx"
click node_funds_rules "https://github.com/mewindev/gdfi-dms/blob/main/lib/funds/rules.ts"
click node_monitoring "https://github.com/mewindev/gdfi-dms/blob/main/app/(app)/monitoring/page.tsx"
click node_branches "https://github.com/mewindev/gdfi-dms/blob/main/lib/services/branches.ts"
click node_settings "https://github.com/mewindev/gdfi-dms/blob/main/lib/settings.ts"
click node_csv_import "https://github.com/mewindev/gdfi-dms/blob/main/lib/import/importer.ts"
click node_notifications "https://github.com/mewindev/gdfi-dms/blob/main/lib/notify.ts"
click node_email_outbox "https://github.com/mewindev/gdfi-dms/blob/main/lib/email/outbox.ts"
click node_auth "https://github.com/mewindev/gdfi-dms/blob/main/lib/auth/current-user.ts"
click node_database "https://github.com/mewindev/gdfi-dms/blob/main/lib/db.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_search,node_myloans,node_loan_file,node_source_review,node_borrower_review,node_journey toneBlue
class node_jobs,node_funds,node_funds_rules,node_monitoring toneAmber
class node_branches,node_settings,node_csv_import toneMint
class node_notifications,node_email_outbox,node_auth,node_database toneRose
class node_associate,node_admin_user,node_email_service toneIndigo
```

## Components

### Loan File Workflow

- [PN Search](https://github.com/mewindev/gdfi-dms/blob/main/app/(app)/search/page.tsx): `app/(app)/search/page.tsx`
- [MyLoans Adapter](https://github.com/mewindev/gdfi-dms/blob/main/lib/myloans/client.ts): `lib/myloans/client.ts`
- [Loan File](https://github.com/mewindev/gdfi-dms/blob/main/app/(app)/loans/%5Bpn%5D/page.tsx): `app/(app)/loans/[pn]/page.tsx`
- [Source Review](https://github.com/mewindev/gdfi-dms/blob/main/lib/services/source-review.ts): `lib/services/source-review.ts`
- [Borrower Review](https://github.com/mewindev/gdfi-dms/blob/main/lib/services/borrower-review.ts): `lib/services/borrower-review.ts`
- [Loan Journey](https://github.com/mewindev/gdfi-dms/blob/main/components/loan/journey/journey-client.tsx): `components/loan/journey/journey-client.tsx`

### Operations

- [Job Tracking](https://github.com/mewindev/gdfi-dms/blob/main/app/(app)/jobs/%5Bid%5D/page.tsx): `app/(app)/jobs/[id]/page.tsx`
- [Cash Advances](https://github.com/mewindev/gdfi-dms/blob/main/app/(app)/funds/page.tsx): `app/(app)/funds/page.tsx`
- [Funds Rules](https://github.com/mewindev/gdfi-dms/blob/main/lib/funds/rules.ts): `lib/funds/rules.ts`
- [Monitoring](https://github.com/mewindev/gdfi-dms/blob/main/app/(app)/monitoring/page.tsx): `app/(app)/monitoring/page.tsx`

### Administration

- [Branch Management](https://github.com/mewindev/gdfi-dms/blob/main/lib/services/branches.ts): `lib/services/branches.ts`
- [System Settings](https://github.com/mewindev/gdfi-dms/blob/main/lib/settings.ts): `lib/settings.ts`
- [CSV Import](https://github.com/mewindev/gdfi-dms/blob/main/lib/import/importer.ts): `lib/import/importer.ts`

### Application Services

- [Notifications](https://github.com/mewindev/gdfi-dms/blob/main/lib/notify.ts): `lib/notify.ts`
- [Email Outbox](https://github.com/mewindev/gdfi-dms/blob/main/lib/email/outbox.ts): `lib/email/outbox.ts`
- [Authentication](https://github.com/mewindev/gdfi-dms/blob/main/lib/auth/current-user.ts): `lib/auth/current-user.ts`
- [PostgreSQL](https://github.com/mewindev/gdfi-dms/blob/main/lib/db.ts): `lib/db.ts`

### Other components

- **Loan Associate**
- **Admin**
- **Email Provider**

## Connections

- Loan Associate → PN Search: searches PN
- PN Search → MyLoans Adapter: looks up PN
- Loan Associate → Loan File: opens loan
- Loan File → MyLoans Adapter: refreshes from
- Loan File → Source Review: reviews changes
- Loan File → Borrower Review: reviews borrower
- Loan File → Loan Journey: shows stages
- MyLoans Adapter → PostgreSQL: reads records (evidence: `lib/myloans/client.ts`)
- Source Review → PostgreSQL: reads and writes (evidence: `lib/services/source-review.ts`)
- Borrower Review → PostgreSQL: updates loan (evidence: `lib/services/borrower-review.ts`)
- Borrower Review → Notifications: notifies reviewers (evidence: `lib/services/borrower-review.ts`)
- Cash Advances → Funds Rules: applies rules (evidence: `app/(app)/funds/page.tsx`)
- Cash Advances → PostgreSQL: reads and writes (evidence: `app/(app)/funds/page.tsx`)
- Funds Rules → PostgreSQL: uses calendar settings (evidence: `lib/funds/rules.ts`)
- Monitoring → PostgreSQL: loads monitoring (evidence: `app/(app)/monitoring/page.tsx`)
- Admin → Branch Management: manages branches
- Branch Management → PostgreSQL: manages branch data
- Admin → System Settings: configures system
- System Settings → PostgreSQL: reads and writes (evidence: `lib/settings.ts`)
- Admin → CSV Import: imports data
- CSV Import → PostgreSQL: imports records
- Email Outbox → PostgreSQL: stores outbox (evidence: `lib/email/outbox.ts`)
- Email Outbox → Email Provider: sends messages
- Loan Associate → Authentication: signs in (evidence: `lib/auth/current-user.ts`)
- Admin → Authentication: signs in (evidence: `lib/auth/current-user.ts`)
- Authentication → PostgreSQL: loads user (evidence: `lib/auth/current-user.ts`)
