# nishant443/nts-app architecture

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

- Interactive diagram: https://gitdiagram.com/nishant443/nts-app
- Repository: https://github.com/nishant443/nts-app

## Overview

NTS Operations & HR is a role-aware business and workforce platform. Employees and administrators use its pages and forms to manage business records and staff workflows; requests pass through server-side access checks to application data, with exports, PDFs, and file handling as supporting outputs. The README documents the major capabilities and high-level request architecture. Many feature implementations were not sampled, so feature links below reflect documented relationships rather than inferred calls.

Main entry points: [`src/app/actions`](https://github.com/nishant443/nts-app/tree/main/src/app/actions) (Server actions), [`src/app/api`](https://github.com/nishant443/nts-app/tree/main/src/app/api) (Route handlers), [`src/lib/services/list-export.ts`](https://github.com/nishant443/nts-app/blob/main/src/lib/services/list-export.ts) (PDF / Excel exports), [`src/lib/dal.ts`](https://github.com/nishant443/nts-app/blob/main/src/lib/dal.ts) (Data access & auth)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["Application workflows"]
  node_pages["App pages"]
  node_actions["Server actions"]
  node_api["Route handlers"]
end

subgraph group_business["Business records"]
  node_customers["Customers"]
  node_salesdocs["Quotes &amp; invoices"]
  node_payments["Payments"]
  node_purchasing["Purchase orders"]
  node_documents["Business documents"]
end

subgraph group_people["People operations"]
  node_tasks["Tasks"]
  node_attendance["Attendance &amp; leave"]
  node_worklogs["Daily work"]
  node_expenses["Expenses"]
  node_payroll["Payroll &amp; payslips"]
  node_employees["Employee records"]
end

subgraph group_platform["Platform services"]
  node_proxy["Request proxy<br/>[proxy.ts]"]
  node_dal["Data access &amp; auth<br/>[dal.ts]"]
  node_session["Session tokens<br/>[session.ts]"]
  node_prisma["Prisma client<br/>[prisma.ts]"]
  node_database[("PostgreSQL")]
  node_rate["Rate limiting<br/>[rate-limit.ts]"]
  node_apihelpers["API helpers<br/>[api.ts]"]
  node_dates["Date utilities<br/>[dates.ts]"]
  node_money["Money utilities<br/>[money.ts]"]
  node_tax["GST calculations<br/>[tax.ts]"]
end

subgraph group_outputs["Reports and files"]
  node_exports["PDF / Excel exports<br/>[list-export.ts]"]
  node_reports["Reports data<br/>[reports.ts]"]
  node_excel["Workbook builder<br/>[excel.ts]"]
  node_pdf["Document PDFs<br/>[document-pdf.tsx]"]
  node_storage["File storage<br/>[storage.ts]"]
  node_mail["Email service<br/>[mail.ts]"]
end

node_browser(("Employee / admin"))

node_browser -->|"requests"| node_proxy
node_proxy -->|"routes to"| node_pages
node_proxy -->|"routes to"| node_actions
node_proxy -->|"routes to"| node_api
node_pages -->|"loads data"| node_dal
node_actions -->|"accesses data"| node_dal
node_api -->|"accesses data"| node_dal
node_dal -->|"reads cookie"| node_session
node_dal -->|"checks user"| node_prisma
node_prisma -->|"queries"| node_database
node_api -->|"uses helpers"| node_apihelpers
node_apihelpers -->|"limits requests"| node_rate
node_customers -->|"manages records"| node_actions
node_salesdocs -->|"creates documents"| node_actions
node_payments -->|"records receipts"| node_actions
node_purchasing -->|"manages orders"| node_actions
node_documents -->|"files documents"| node_actions
node_tasks -->|"assigns work"| node_actions
node_attendance -->|"records attendance"| node_actions
node_worklogs -->|"submits work"| node_actions
node_expenses -->|"submits claims"| node_actions
node_payroll -->|"runs payroll"| node_actions
node_employees -->|"manages profiles"| node_actions
node_api -->|"builds exports"| node_exports
node_api -->|"loads report data"| node_reports
node_exports -->|"builds workbook"| node_excel
node_exports -->|"renders PDF"| node_pdf
node_api -->|"uploads files"| node_storage
node_api -->|"serves files"| node_storage
node_actions -->|"sends task email"| node_mail
node_actions -.->|"calculates GST"| node_tax
node_exports -->|"formats dates"| node_dates
node_exports -->|"formats amounts"| node_money

click node_proxy "https://github.com/nishant443/nts-app/blob/main/src/proxy.ts"
click node_pages "https://github.com/nishant443/nts-app/tree/main/src/app/(app)"
click node_actions "https://github.com/nishant443/nts-app/tree/main/src/app/actions"
click node_api "https://github.com/nishant443/nts-app/tree/main/src/app/api"
click node_customers "https://github.com/nishant443/nts-app/tree/main/src/app/(app)/customers"
click node_salesdocs "https://github.com/nishant443/nts-app/tree/main/src/app/(app)/invoices"
click node_payments "https://github.com/nishant443/nts-app/tree/main/src/app/(app)/payments"
click node_purchasing "https://github.com/nishant443/nts-app/tree/main/src/app/(app)/purchase-orders"
click node_documents "https://github.com/nishant443/nts-app/tree/main/src/app/(app)/documents"
click node_tasks "https://github.com/nishant443/nts-app/tree/main/src/app/(app)/tasks"
click node_attendance "https://github.com/nishant443/nts-app/tree/main/src/app/(app)/attendance"
click node_worklogs "https://github.com/nishant443/nts-app/tree/main/src/app/(app)/work-logs"
click node_expenses "https://github.com/nishant443/nts-app/tree/main/src/app/(app)/expenses"
click node_payroll "https://github.com/nishant443/nts-app/tree/main/src/app/(app)/admin/payroll"
click node_employees "https://github.com/nishant443/nts-app/tree/main/src/app/(app)/admin/employees"
click node_dal "https://github.com/nishant443/nts-app/blob/main/src/lib/dal.ts"
click node_session "https://github.com/nishant443/nts-app/blob/main/src/lib/session.ts"
click node_prisma "https://github.com/nishant443/nts-app/blob/main/src/lib/prisma.ts"
click node_rate "https://github.com/nishant443/nts-app/blob/main/src/lib/rate-limit.ts"
click node_apihelpers "https://github.com/nishant443/nts-app/blob/main/src/lib/api.ts"
click node_dates "https://github.com/nishant443/nts-app/blob/main/src/lib/dates.ts"
click node_money "https://github.com/nishant443/nts-app/blob/main/src/lib/money.ts"
click node_tax "https://github.com/nishant443/nts-app/blob/main/src/lib/tax.ts"
click node_exports "https://github.com/nishant443/nts-app/blob/main/src/lib/services/list-export.ts"
click node_reports "https://github.com/nishant443/nts-app/blob/main/src/lib/services/reports.ts"
click node_excel "https://github.com/nishant443/nts-app/blob/main/src/lib/excel.ts"
click node_pdf "https://github.com/nishant443/nts-app/blob/main/src/lib/pdf/document-pdf.tsx"
click node_storage "https://github.com/nishant443/nts-app/blob/main/src/lib/storage.ts"
click node_mail "https://github.com/nishant443/nts-app/blob/main/src/lib/mail.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_pages,node_actions,node_api toneBlue
class node_customers,node_salesdocs,node_payments,node_purchasing,node_documents toneAmber
class node_tasks,node_attendance,node_worklogs,node_expenses,node_payroll,node_employees toneMint
class node_proxy,node_dal,node_session,node_prisma,node_database,node_rate,node_apihelpers,node_dates,node_money,node_tax toneRose
class node_exports,node_reports,node_excel,node_pdf,node_storage,node_mail,node_browser toneIndigo
```

## Components

### Application workflows

- [App pages](https://github.com/nishant443/nts-app/tree/main/src/app/(app)): `src/app/(app)`
- [Server actions](https://github.com/nishant443/nts-app/tree/main/src/app/actions): `src/app/actions`
- [Route handlers](https://github.com/nishant443/nts-app/tree/main/src/app/api): `src/app/api`

### Business records

- [Customers](https://github.com/nishant443/nts-app/tree/main/src/app/(app)/customers): `src/app/(app)/customers`
- [Quotes & invoices](https://github.com/nishant443/nts-app/tree/main/src/app/(app)/invoices): `src/app/(app)/invoices`
- [Payments](https://github.com/nishant443/nts-app/tree/main/src/app/(app)/payments): `src/app/(app)/payments`
- [Purchase orders](https://github.com/nishant443/nts-app/tree/main/src/app/(app)/purchase-orders): `src/app/(app)/purchase-orders`
- [Business documents](https://github.com/nishant443/nts-app/tree/main/src/app/(app)/documents): `src/app/(app)/documents`

### People operations

- [Tasks](https://github.com/nishant443/nts-app/tree/main/src/app/(app)/tasks): `src/app/(app)/tasks`
- [Attendance & leave](https://github.com/nishant443/nts-app/tree/main/src/app/(app)/attendance): `src/app/(app)/attendance`
- [Daily work](https://github.com/nishant443/nts-app/tree/main/src/app/(app)/work-logs): `src/app/(app)/work-logs`
- [Expenses](https://github.com/nishant443/nts-app/tree/main/src/app/(app)/expenses): `src/app/(app)/expenses`
- [Payroll & payslips](https://github.com/nishant443/nts-app/tree/main/src/app/(app)/admin/payroll): `src/app/(app)/admin/payroll`
- [Employee records](https://github.com/nishant443/nts-app/tree/main/src/app/(app)/admin/employees): `src/app/(app)/admin/employees`

### Platform services

- [Request proxy](https://github.com/nishant443/nts-app/blob/main/src/proxy.ts): `src/proxy.ts`
- [Data access & auth](https://github.com/nishant443/nts-app/blob/main/src/lib/dal.ts): `src/lib/dal.ts`
- [Session tokens](https://github.com/nishant443/nts-app/blob/main/src/lib/session.ts): `src/lib/session.ts`
- [Prisma client](https://github.com/nishant443/nts-app/blob/main/src/lib/prisma.ts): `src/lib/prisma.ts`
- **PostgreSQL**
- [Rate limiting](https://github.com/nishant443/nts-app/blob/main/src/lib/rate-limit.ts): `src/lib/rate-limit.ts`
- [API helpers](https://github.com/nishant443/nts-app/blob/main/src/lib/api.ts): `src/lib/api.ts`
- [Date utilities](https://github.com/nishant443/nts-app/blob/main/src/lib/dates.ts): `src/lib/dates.ts`
- [Money utilities](https://github.com/nishant443/nts-app/blob/main/src/lib/money.ts): `src/lib/money.ts`
- [GST calculations](https://github.com/nishant443/nts-app/blob/main/src/lib/tax.ts): `src/lib/tax.ts`

### Reports and files

- [PDF / Excel exports](https://github.com/nishant443/nts-app/blob/main/src/lib/services/list-export.ts): `src/lib/services/list-export.ts`
- [Reports data](https://github.com/nishant443/nts-app/blob/main/src/lib/services/reports.ts): `src/lib/services/reports.ts`
- [Workbook builder](https://github.com/nishant443/nts-app/blob/main/src/lib/excel.ts): `src/lib/excel.ts`
- [Document PDFs](https://github.com/nishant443/nts-app/blob/main/src/lib/pdf/document-pdf.tsx): `src/lib/pdf/document-pdf.tsx`
- [File storage](https://github.com/nishant443/nts-app/blob/main/src/lib/storage.ts): `src/lib/storage.ts`
- [Email service](https://github.com/nishant443/nts-app/blob/main/src/lib/mail.ts): `src/lib/mail.ts`

### Other components

- **Employee / admin**

## Connections

- Employee / admin → Request proxy: requests
- Request proxy → App pages: routes to
- Request proxy → Server actions: routes to
- Request proxy → Route handlers: routes to
- App pages → Data access & auth: loads data
- Server actions → Data access & auth: accesses data
- Route handlers → Data access & auth: accesses data (evidence: `src/app/api/export/invoices/route.ts`)
- Data access & auth → Session tokens: reads cookie (evidence: `src/lib/dal.ts`)
- Data access & auth → Prisma client: checks user (evidence: `src/lib/dal.ts`)
- Prisma client → PostgreSQL: queries
- Route handlers → API helpers: uses helpers (evidence: `src/app/api/export/invoices/route.ts`)
- API helpers → Rate limiting: limits requests (evidence: `src/lib/api.ts`)
- Customers → Server actions: manages records
- Quotes & invoices → Server actions: creates documents
- Payments → Server actions: records receipts
- Purchase orders → Server actions: manages orders
- Business documents → Server actions: files documents
- Tasks → Server actions: assigns work
- Attendance & leave → Server actions: records attendance
- Daily work → Server actions: submits work
- Expenses → Server actions: submits claims
- Payroll & payslips → Server actions: runs payroll
- Employee records → Server actions: manages profiles
- Route handlers → PDF / Excel exports: builds exports (evidence: `src/app/api/export/invoices/route.ts`)
- Route handlers → Reports data: loads report data (evidence: `src/app/api/export/sales/route.ts`)
- PDF / Excel exports → Workbook builder: builds workbook (evidence: `src/lib/services/list-export.ts`)
- PDF / Excel exports → Document PDFs: renders PDF (evidence: `src/lib/services/list-export.ts`)
- Route handlers → File storage: uploads files (evidence: `src/app/api/upload/route.ts`)
- Route handlers → File storage: serves files (evidence: `src/app/api/files/[...path]/route.ts`)
- Server actions → Email service: sends task email
- Server actions → GST calculations: calculates GST
- PDF / Excel exports → Date utilities: formats dates (evidence: `src/lib/services/list-export.ts`)
- PDF / Excel exports → Money utilities: formats amounts (evidence: `src/lib/services/list-export.ts`)
