# iqbalussain/payrollsheet architecture

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

- Interactive diagram: https://gitdiagram.com/iqbalussain/payrollsheet
- Repository: https://github.com/iqbalussain/payrollsheet

## Overview

Payroll Companion is a role-gated workforce payroll application. Admin and HR users sign in, then work with employee records, daily timesheets, payroll batches and lines, advances, history, salary slips, cost allocation, attendance reports, and audit history. Payroll calculations and carry-forward logic sit in a shared domain layer; React Query data hooks connect the interface to Supabase. The route imports and renders the principal screens, while the shared data module accesses the database. Some subsystem implementation details are unsampled, so those relationships are omitted or marked unverified.

Main entry points: [`src/routes/index.tsx`](https://github.com/iqbalussain/payrollsheet/blob/main/src/routes/index.tsx) (Payroll Portal), [`src/lib/payroll-data.ts`](https://github.com/iqbalussain/payrollsheet/blob/main/src/lib/payroll-data.ts) (Payroll Data Hooks), [`src/components/payroll/PayrollTab.tsx`](https://github.com/iqbalussain/payrollsheet/blob/main/src/components/payroll/PayrollTab.tsx) (Payroll Batches), [`src/integrations/supabase/external-client.ts`](https://github.com/iqbalussain/payrollsheet/blob/main/src/integrations/supabase/external-client.ts) (Supabase Client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["Application Shell"]
  node_portal["Payroll Portal<br/>[index.tsx]"]
  node_login["Sign-in<br/>[LoginPage.tsx]"]
end

subgraph group_workforce["Workforce &amp; Attendance"]
  node_employees["Employee Records<br/>[EmployeesTab.tsx]"]
  node_employee_details["Employee Details<br/>[EmployeeModal.tsx]"]
  node_timesheets["Daily Timesheets<br/>[TimesheetsTab.tsx]"]
  node_attendance["Attendance Reports"]
end

subgraph group_payroll["Payroll Operations"]
  node_payroll_tab["Payroll Batches<br/>[PayrollTab.tsx]"]
  node_advances["Advance Management<br/>[AdvancesTab.tsx]"]
  node_domain["Payroll Calculations<br/>[payroll.ts]"]
end

subgraph group_insights["History &amp; Reporting"]
  node_history["Employee History<br/>[HistoryTab.tsx]"]
  node_slips["Salary Slips<br/>[SlipsTab.tsx]"]
  node_slip_pdf["PDF Generation<br/>[slip-pdf.ts]"]
  node_cost["Cost Allocation<br/>[CostTab.tsx]"]
  node_cost_details["Cost Details"]
  node_audit["Audit History"]
end

subgraph group_platform["Data &amp; Services"]
  node_data["Payroll Data Hooks<br/>[payroll-data.ts]"]
  node_supabase_client["Supabase Client<br/>[external-client.ts]"]
end

node_user(("Admin / HR"))
node_supabase[("Supabase")]

node_user -->|"opens"| node_portal
node_portal -->|"prompts sign-in"| node_login
node_portal -->|"renders"| node_employees
node_portal -->|"renders"| node_payroll_tab
node_portal -->|"renders"| node_history
node_portal -->|"renders"| node_slips
node_portal -->|"renders"| node_cost
node_portal -->|"renders"| node_advances
node_portal -->|"renders"| node_audit
node_portal -->|"renders"| node_timesheets
node_portal -->|"renders"| node_attendance
node_portal -->|"loads data"| node_data
node_employees -.->|"opens details"| node_employee_details
node_payroll_tab -.->|"generates draft"| node_timesheets
node_employees -.->|"reads and saves"| node_data
node_payroll_tab -->|"saves batches"| node_data
node_advances -.->|"manages advances"| node_data
node_data -->|"queries"| node_supabase_client
node_supabase_client -.->|"connects"| node_supabase
node_login -.->|"authenticates"| node_supabase_client
node_payroll_tab -->|"uses calculations"| node_domain
node_history -->|"uses calculations"| node_domain
node_slips -->|"generates PDFs"| node_slip_pdf
node_slip_pdf -->|"formats payroll values"| node_domain
node_cost -->|"opens details"| node_cost_details
node_attendance -->|"reads attendance data"| node_data
node_timesheets -.->|"reads and saves"| node_data
node_history -.->|"reads records"| node_data
node_audit -->|"reads audit records"| node_supabase_client

click node_portal "https://github.com/iqbalussain/payrollsheet/blob/main/src/routes/index.tsx"
click node_login "https://github.com/iqbalussain/payrollsheet/blob/main/src/components/payroll/LoginPage.tsx"
click node_employees "https://github.com/iqbalussain/payrollsheet/blob/main/src/components/payroll/EmployeesTab.tsx"
click node_employee_details "https://github.com/iqbalussain/payrollsheet/blob/main/src/components/payroll/EmployeeModal.tsx"
click node_timesheets "https://github.com/iqbalussain/payrollsheet/blob/main/src/components/payroll/TimesheetsTab.tsx"
click node_attendance "https://github.com/iqbalussain/payrollsheet/blob/main/src/components/payroll/AttendanceReportTab.tsx"
click node_payroll_tab "https://github.com/iqbalussain/payrollsheet/blob/main/src/components/payroll/PayrollTab.tsx"
click node_advances "https://github.com/iqbalussain/payrollsheet/blob/main/src/components/payroll/AdvancesTab.tsx"
click node_domain "https://github.com/iqbalussain/payrollsheet/blob/main/src/lib/payroll.ts"
click node_history "https://github.com/iqbalussain/payrollsheet/blob/main/src/components/payroll/HistoryTab.tsx"
click node_slips "https://github.com/iqbalussain/payrollsheet/blob/main/src/components/payroll/SlipsTab.tsx"
click node_slip_pdf "https://github.com/iqbalussain/payrollsheet/blob/main/src/lib/slip-pdf.ts"
click node_cost "https://github.com/iqbalussain/payrollsheet/blob/main/src/components/payroll/CostTab.tsx"
click node_cost_details "https://github.com/iqbalussain/payrollsheet/blob/main/src/components/payroll/CostDetailsModal.tsx"
click node_audit "https://github.com/iqbalussain/payrollsheet/blob/main/src/components/payroll/AuditHistoryTab.tsx"
click node_data "https://github.com/iqbalussain/payrollsheet/blob/main/src/lib/payroll-data.ts"
click node_supabase_client "https://github.com/iqbalussain/payrollsheet/blob/main/src/integrations/supabase/external-client.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_portal,node_login toneBlue
class node_employees,node_employee_details,node_timesheets,node_attendance,node_supabase toneAmber
class node_payroll_tab,node_advances,node_domain toneMint
class node_history,node_slips,node_slip_pdf,node_cost,node_cost_details,node_audit toneRose
class node_data,node_supabase_client,node_user toneIndigo
```

## Components

### Application Shell

- [Payroll Portal](https://github.com/iqbalussain/payrollsheet/blob/main/src/routes/index.tsx): `src/routes/index.tsx`
- [Sign-in](https://github.com/iqbalussain/payrollsheet/blob/main/src/components/payroll/LoginPage.tsx): `src/components/payroll/LoginPage.tsx`

### Workforce & Attendance

- [Employee Records](https://github.com/iqbalussain/payrollsheet/blob/main/src/components/payroll/EmployeesTab.tsx): `src/components/payroll/EmployeesTab.tsx`
- [Employee Details](https://github.com/iqbalussain/payrollsheet/blob/main/src/components/payroll/EmployeeModal.tsx): `src/components/payroll/EmployeeModal.tsx`
- [Daily Timesheets](https://github.com/iqbalussain/payrollsheet/blob/main/src/components/payroll/TimesheetsTab.tsx): `src/components/payroll/TimesheetsTab.tsx`
- [Attendance Reports](https://github.com/iqbalussain/payrollsheet/blob/main/src/components/payroll/AttendanceReportTab.tsx): `src/components/payroll/AttendanceReportTab.tsx`

### Payroll Operations

- [Payroll Batches](https://github.com/iqbalussain/payrollsheet/blob/main/src/components/payroll/PayrollTab.tsx): `src/components/payroll/PayrollTab.tsx`
- [Advance Management](https://github.com/iqbalussain/payrollsheet/blob/main/src/components/payroll/AdvancesTab.tsx): `src/components/payroll/AdvancesTab.tsx`
- [Payroll Calculations](https://github.com/iqbalussain/payrollsheet/blob/main/src/lib/payroll.ts): `src/lib/payroll.ts`

### History & Reporting

- [Employee History](https://github.com/iqbalussain/payrollsheet/blob/main/src/components/payroll/HistoryTab.tsx): `src/components/payroll/HistoryTab.tsx`
- [Salary Slips](https://github.com/iqbalussain/payrollsheet/blob/main/src/components/payroll/SlipsTab.tsx): `src/components/payroll/SlipsTab.tsx`
- [PDF Generation](https://github.com/iqbalussain/payrollsheet/blob/main/src/lib/slip-pdf.ts): `src/lib/slip-pdf.ts`
- [Cost Allocation](https://github.com/iqbalussain/payrollsheet/blob/main/src/components/payroll/CostTab.tsx): `src/components/payroll/CostTab.tsx`
- [Cost Details](https://github.com/iqbalussain/payrollsheet/blob/main/src/components/payroll/CostDetailsModal.tsx): `src/components/payroll/CostDetailsModal.tsx`
- [Audit History](https://github.com/iqbalussain/payrollsheet/blob/main/src/components/payroll/AuditHistoryTab.tsx): `src/components/payroll/AuditHistoryTab.tsx`

### Data & Services

- [Payroll Data Hooks](https://github.com/iqbalussain/payrollsheet/blob/main/src/lib/payroll-data.ts): `src/lib/payroll-data.ts`
- [Supabase Client](https://github.com/iqbalussain/payrollsheet/blob/main/src/integrations/supabase/external-client.ts): `src/integrations/supabase/external-client.ts`

### Other components

- **Admin / HR**
- **Supabase**

## Connections

- Admin / HR → Payroll Portal: opens (evidence: `src/routes/index.tsx`)
- Payroll Portal → Sign-in: prompts sign-in (evidence: `src/routes/index.tsx`)
- Payroll Portal → Employee Records: renders (evidence: `src/routes/index.tsx`)
- Payroll Portal → Payroll Batches: renders (evidence: `src/routes/index.tsx`)
- Payroll Portal → Employee History: renders (evidence: `src/routes/index.tsx`)
- Payroll Portal → Salary Slips: renders (evidence: `src/routes/index.tsx`)
- Payroll Portal → Cost Allocation: renders (evidence: `src/routes/index.tsx`)
- Payroll Portal → Advance Management: renders (evidence: `src/routes/index.tsx`)
- Payroll Portal → Audit History: renders (evidence: `src/routes/index.tsx`)
- Payroll Portal → Daily Timesheets: renders (evidence: `src/routes/index.tsx`)
- Payroll Portal → Attendance Reports: renders (evidence: `src/routes/index.tsx`)
- Payroll Portal → Payroll Data Hooks: loads data (evidence: `src/routes/index.tsx`)
- Employee Records → Employee Details: opens details
- Payroll Batches → Daily Timesheets: generates draft (evidence: `README.md`)
- Employee Records → Payroll Data Hooks: reads and saves
- Payroll Batches → Payroll Data Hooks: saves batches (evidence: `src/components/payroll/PayrollTab.tsx`)
- Advance Management → Payroll Data Hooks: manages advances
- Payroll Data Hooks → Supabase Client: queries (evidence: `src/lib/payroll-data.ts`)
- Supabase Client → Supabase: connects
- Sign-in → Supabase Client: authenticates (evidence: `src/components/payroll/LoginPage.tsx`)
- Payroll Batches → Payroll Calculations: uses calculations (evidence: `src/components/payroll/PayrollTab.tsx`)
- Employee History → Payroll Calculations: uses calculations (evidence: `src/components/payroll/HistoryTab.tsx`)
- Salary Slips → PDF Generation: generates PDFs (evidence: `src/components/payroll/SlipsTab.tsx`)
- PDF Generation → Payroll Calculations: formats payroll values (evidence: `src/lib/slip-pdf.ts`)
- Cost Allocation → Cost Details: opens details (evidence: `src/components/payroll/CostTab.tsx`)
- Attendance Reports → Payroll Data Hooks: reads attendance data (evidence: `src/components/payroll/AttendanceReportTab.tsx`)
- Daily Timesheets → Payroll Data Hooks: reads and saves (evidence: `src/components/payroll/TimesheetsTab.tsx`)
- Employee History → Payroll Data Hooks: reads records
- Audit History → Supabase Client: reads audit records (evidence: `src/components/payroll/AuditHistoryTab.tsx`)
