# drenbuqa/debtloanrecovery architecture

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

- Interactive diagram: https://gitdiagram.com/drenbuqa/debtloanrecovery
- Repository: https://github.com/drenbuqa/debtloanrecovery

## Overview

DLR is a debt-recovery management application: staff work cases and collection activities, record payments, manage related documents and agreements, and review reports. The tree shows a Next.js dashboard and a NestJS API, with Prisma persistence. Backend controller-to-service and service-to-database links are supported by excerpts or the source index; the README is empty, and frontend request wiring was not shown, so those links are marked unverified rather than asserted.

Main entry points: [`api/src/prisma/prisma.service.ts`](https://github.com/drenbuqa/debtloanrecovery/blob/main/api/src/prisma/prisma.service.ts) (Application database), [`api/src/audit/audit.service.ts`](https://github.com/drenbuqa/debtloanrecovery/blob/main/api/src/audit/audit.service.ts) (Audit logging), [`api/src/cases/cases.service.ts`](https://github.com/drenbuqa/debtloanrecovery/blob/main/api/src/cases/cases.service.ts) (Case management), [`api/src/auth/auth.service.ts`](https://github.com/drenbuqa/debtloanrecovery/blob/main/api/src/auth/auth.service.ts) (Authentication)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Staff dashboard"]
  node_dashboard["Dashboard<br/>[page.tsx]"]
  node_case_ui["Case workspace<br/>[page.tsx]"]
  node_import_ui["Import workspace<br/>[page.tsx]"]
  node_payment_ui["Payments screen<br/>[page.tsx]"]
  node_report_ui["Reports screen<br/>[page.tsx]"]
end

subgraph group_casework["Casework"]
  node_cases["Case management<br/>[cases.service.ts]"]
  node_activities["Collection activities"]
  node_agreements["Agreements"]
  node_documents["Case documents"]
end

subgraph group_collections["Collections and finance"]
  node_payments["Payment records"]
  node_performance["Performance tracking"]
  node_reports["Exports and reports<br/>[reports.service.ts]"]
end

subgraph group_operations["Operations"]
  node_import["Bulk data import<br/>[import.service.ts]"]
  node_leave["Leave management<br/>[leave.service.ts]"]
  node_legal["Legal records<br/>[legal.service.ts]"]
end

subgraph group_platform["Access and persistence"]
  node_users["User administration<br/>[users.service.ts]"]
  node_auth["Authentication<br/>[auth.service.ts]"]
  node_roles["Role authorization<br/>[roles.guard.ts]"]
  node_audit["Audit logging<br/>[audit.service.ts]"]
  node_db[("Application database<br/>[prisma.service.ts]")]
end

node_staff(("Staff user"))

node_staff -.->|"opens"| node_dashboard
node_staff -.->|"works cases"| node_case_ui
node_staff -.->|"starts imports"| node_import_ui
node_staff -.->|"records payments"| node_payment_ui
node_staff -.->|"views reports"| node_report_ui
node_case_ui -.->|"requests data"| node_cases
node_import_ui -.->|"uploads data"| node_import
node_payment_ui -.->|"requests data"| node_payments
node_report_ui -.->|"requests exports"| node_reports
node_cases -->|"reads and writes"| node_db
node_activities -->|"reads and writes"| node_db
node_agreements -->|"reads and writes"| node_db
node_documents -->|"reads and writes"| node_db
node_payments -->|"reads and writes"| node_db
node_performance -->|"reads and writes"| node_db
node_reports -->|"reads and writes"| node_db
node_import -->|"reads and writes"| node_db
node_leave -->|"reads and writes"| node_db
node_legal -->|"reads and writes"| node_db
node_users -->|"reads and writes"| node_db
node_auth -->|"uses user service"| node_users
node_auth -->|"checks credentials"| node_db
node_auth -->|"records login events"| node_audit
node_audit -->|"writes audit entries"| node_db
node_cases -->|"logs case changes"| node_audit
node_activities -->|"logs activity changes"| node_audit
node_payments -->|"logs payment changes"| node_audit
node_users -->|"logs user changes"| node_audit
node_roles -.->|"guards requests"| node_cases

click node_dashboard "https://github.com/drenbuqa/debtloanrecovery/blob/main/web/src/app/(dashboard)/dashboard/page.tsx"
click node_case_ui "https://github.com/drenbuqa/debtloanrecovery/blob/main/web/src/app/(dashboard)/cases/%5Bid%5D/page.tsx"
click node_import_ui "https://github.com/drenbuqa/debtloanrecovery/blob/main/web/src/app/(dashboard)/import/page.tsx"
click node_payment_ui "https://github.com/drenbuqa/debtloanrecovery/blob/main/web/src/app/(dashboard)/payments/page.tsx"
click node_report_ui "https://github.com/drenbuqa/debtloanrecovery/blob/main/web/src/app/(dashboard)/reports/page.tsx"
click node_cases "https://github.com/drenbuqa/debtloanrecovery/blob/main/api/src/cases/cases.service.ts"
click node_activities "https://github.com/drenbuqa/debtloanrecovery/blob/main/api/src/activities/activities.service.ts"
click node_agreements "https://github.com/drenbuqa/debtloanrecovery/blob/main/api/src/agreements/agreements.service.ts"
click node_documents "https://github.com/drenbuqa/debtloanrecovery/blob/main/api/src/documents/documents.service.ts"
click node_payments "https://github.com/drenbuqa/debtloanrecovery/blob/main/api/src/payments/payments.service.ts"
click node_performance "https://github.com/drenbuqa/debtloanrecovery/blob/main/api/src/performance/performance.service.ts"
click node_reports "https://github.com/drenbuqa/debtloanrecovery/blob/main/api/src/reports/reports.service.ts"
click node_import "https://github.com/drenbuqa/debtloanrecovery/blob/main/api/src/import/import.service.ts"
click node_leave "https://github.com/drenbuqa/debtloanrecovery/blob/main/api/src/leave/leave.service.ts"
click node_legal "https://github.com/drenbuqa/debtloanrecovery/blob/main/api/src/legal/legal.service.ts"
click node_users "https://github.com/drenbuqa/debtloanrecovery/blob/main/api/src/users/users.service.ts"
click node_auth "https://github.com/drenbuqa/debtloanrecovery/blob/main/api/src/auth/auth.service.ts"
click node_roles "https://github.com/drenbuqa/debtloanrecovery/blob/main/api/src/auth/roles.guard.ts"
click node_audit "https://github.com/drenbuqa/debtloanrecovery/blob/main/api/src/audit/audit.service.ts"
click node_db "https://github.com/drenbuqa/debtloanrecovery/blob/main/api/src/prisma/prisma.service.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_dashboard,node_case_ui,node_import_ui,node_payment_ui,node_report_ui,node_staff toneBlue
class node_cases,node_activities,node_agreements,node_documents toneAmber
class node_payments,node_performance,node_reports toneMint
class node_import,node_leave,node_legal toneRose
class node_users,node_auth,node_roles,node_audit,node_db toneIndigo
```

## Components

### Staff dashboard

- [Dashboard](https://github.com/drenbuqa/debtloanrecovery/blob/main/web/src/app/(dashboard)/dashboard/page.tsx): `web/src/app/(dashboard)/dashboard/page.tsx`
- [Case workspace](https://github.com/drenbuqa/debtloanrecovery/blob/main/web/src/app/(dashboard)/cases/%5Bid%5D/page.tsx): `web/src/app/(dashboard)/cases/[id]/page.tsx`
- [Import workspace](https://github.com/drenbuqa/debtloanrecovery/blob/main/web/src/app/(dashboard)/import/page.tsx): `web/src/app/(dashboard)/import/page.tsx`
- [Payments screen](https://github.com/drenbuqa/debtloanrecovery/blob/main/web/src/app/(dashboard)/payments/page.tsx): `web/src/app/(dashboard)/payments/page.tsx`
- [Reports screen](https://github.com/drenbuqa/debtloanrecovery/blob/main/web/src/app/(dashboard)/reports/page.tsx): `web/src/app/(dashboard)/reports/page.tsx`

### Casework

- [Case management](https://github.com/drenbuqa/debtloanrecovery/blob/main/api/src/cases/cases.service.ts): `api/src/cases/cases.service.ts`
- [Collection activities](https://github.com/drenbuqa/debtloanrecovery/blob/main/api/src/activities/activities.service.ts): `api/src/activities/activities.service.ts`
- [Agreements](https://github.com/drenbuqa/debtloanrecovery/blob/main/api/src/agreements/agreements.service.ts): `api/src/agreements/agreements.service.ts`
- [Case documents](https://github.com/drenbuqa/debtloanrecovery/blob/main/api/src/documents/documents.service.ts): `api/src/documents/documents.service.ts`

### Collections and finance

- [Payment records](https://github.com/drenbuqa/debtloanrecovery/blob/main/api/src/payments/payments.service.ts): `api/src/payments/payments.service.ts`
- [Performance tracking](https://github.com/drenbuqa/debtloanrecovery/blob/main/api/src/performance/performance.service.ts): `api/src/performance/performance.service.ts`
- [Exports and reports](https://github.com/drenbuqa/debtloanrecovery/blob/main/api/src/reports/reports.service.ts): `api/src/reports/reports.service.ts`

### Operations

- [Bulk data import](https://github.com/drenbuqa/debtloanrecovery/blob/main/api/src/import/import.service.ts): `api/src/import/import.service.ts`
- [Leave management](https://github.com/drenbuqa/debtloanrecovery/blob/main/api/src/leave/leave.service.ts): `api/src/leave/leave.service.ts`
- [Legal records](https://github.com/drenbuqa/debtloanrecovery/blob/main/api/src/legal/legal.service.ts): `api/src/legal/legal.service.ts`

### Access and persistence

- [User administration](https://github.com/drenbuqa/debtloanrecovery/blob/main/api/src/users/users.service.ts): `api/src/users/users.service.ts`
- [Authentication](https://github.com/drenbuqa/debtloanrecovery/blob/main/api/src/auth/auth.service.ts): `api/src/auth/auth.service.ts`
- [Role authorization](https://github.com/drenbuqa/debtloanrecovery/blob/main/api/src/auth/roles.guard.ts): `api/src/auth/roles.guard.ts`
- [Audit logging](https://github.com/drenbuqa/debtloanrecovery/blob/main/api/src/audit/audit.service.ts): `api/src/audit/audit.service.ts`
- [Application database](https://github.com/drenbuqa/debtloanrecovery/blob/main/api/src/prisma/prisma.service.ts): `api/src/prisma/prisma.service.ts`

### Other components

- **Staff user**

## Connections

- Staff user → Dashboard: opens
- Staff user → Case workspace: works cases
- Staff user → Import workspace: starts imports
- Staff user → Payments screen: records payments
- Staff user → Reports screen: views reports
- Case workspace → Case management: requests data
- Import workspace → Bulk data import: uploads data
- Payments screen → Payment records: requests data
- Reports screen → Exports and reports: requests exports
- Case management → Application database: reads and writes (evidence: `api/src/cases/cases.service.ts`)
- Collection activities → Application database: reads and writes (evidence: `api/src/activities/activities.service.ts`)
- Agreements → Application database: reads and writes (evidence: `api/src/agreements/agreements.service.ts`)
- Case documents → Application database: reads and writes (evidence: `api/src/documents/documents.service.ts`)
- Payment records → Application database: reads and writes (evidence: `api/src/payments/payments.service.ts`)
- Performance tracking → Application database: reads and writes (evidence: `api/src/performance/performance.service.ts`)
- Exports and reports → Application database: reads and writes (evidence: `api/src/reports/reports.service.ts`)
- Bulk data import → Application database: reads and writes (evidence: `api/src/import/import.service.ts`)
- Leave management → Application database: reads and writes (evidence: `api/src/leave/leave.service.ts`)
- Legal records → Application database: reads and writes (evidence: `api/src/legal/legal.service.ts`)
- User administration → Application database: reads and writes (evidence: `api/src/users/users.service.ts`)
- Authentication → User administration: uses user service (evidence: `api/src/auth/auth.service.ts`)
- Authentication → Application database: checks credentials (evidence: `api/src/auth/auth.service.ts`)
- Authentication → Audit logging: records login events (evidence: `api/src/auth/auth.service.ts`)
- Audit logging → Application database: writes audit entries (evidence: `api/src/audit/audit.service.ts`)
- Case management → Audit logging: logs case changes (evidence: `api/src/cases/cases.controller.ts`)
- Collection activities → Audit logging: logs activity changes (evidence: `api/src/activities/activities.controller.ts`)
- Payment records → Audit logging: logs payment changes (evidence: `api/src/payments/payments.controller.ts`)
- User administration → Audit logging: logs user changes (evidence: `api/src/users/users.controller.ts`)
- Role authorization → Case management: guards requests
