# puttirakesh/payroll_management_system architecture

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

- Interactive diagram: https://gitdiagram.com/puttirakesh/payroll_management_system
- Repository: https://github.com/puttirakesh/payroll_management_system

## Overview

This PERN payroll system serves administrators and employees through role-protected web pages backed by an Express API and PostgreSQL. The main workflow is sign-in, role-based access, and use of employee, attendance, leave, payroll, or payslip features; administrators manage records and generate payslips, while employees view their own records and download payslips. The graph preserves these distinct product areas. Some page-to-API and route-to-storage links are supported by the source index; unsampled wiring is not treated as inspected.

Main entry points: [`client/src/App.jsx`](https://github.com/puttirakesh/payroll_management_system/blob/main/client/src/App.jsx) (Route application), [`client/src/api.js`](https://github.com/puttirakesh/payroll_management_system/blob/main/client/src/api.js) (API client), [`server/src/app.js`](https://github.com/puttirakesh/payroll_management_system/blob/main/server/src/app.js) (HTTP API), [`server/src/config/db.js`](https://github.com/puttirakesh/payroll_management_system/blob/main/server/src/config/db.js) (PostgreSQL connection)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web application"]
  node_app["Route application<br/>[App.jsx]"]
  node_login["Sign-in page<br/>[Login.jsx]"]
  node_authstate["Authentication state<br/>[AuthContext.jsx]"]
  node_layout["Role-based layout<br/>[Layout.jsx]"]
  node_clientapi["API client<br/>[api.js]"]
end

subgraph group_people["People operations"]
  node_adminhome["Admin dashboard<br/>[Dashboard.jsx]"]
  node_employees["Employee management<br/>[Employees.jsx]"]
  node_employeehome["Employee dashboard<br/>[Dashboard.jsx]"]
end

subgraph group_time["Time and leave"]
  node_adminattendance["Admin attendance<br/>[Attendance.jsx]"]
  node_employeeattendance["Employee attendance<br/>[Attendance.jsx]"]
  node_adminleaves["Admin leave management<br/>[Leaves.jsx]"]
  node_employeeleaves["Employee leave requests<br/>[Leaves.jsx]"]
end

subgraph group_pay["Payroll and payslips"]
  node_payroll["Payroll management<br/>[Payroll.jsx]"]
  node_payslips["Employee payslips<br/>[Payslips.jsx]"]
end

subgraph group_api["API and persistence"]
  node_server["HTTP API<br/>[app.js]"]
  node_authroute["Authentication route<br/>[auth.js]"]
  node_employeeroute["Employee routes<br/>[employees.js]"]
  node_attendanceroute["Attendance routes<br/>[attendance.js]"]
  node_leaveroute["Leave routes<br/>[leaves.js]"]
  node_paysliproute["Payslip routes<br/>[payslips.js]"]
  node_authmw["Token authorization<br/>[auth.js]"]
  node_pdf["Payslip PDF generation<br/>[payslipPdf.js]"]
  node_dbpool["PostgreSQL connection<br/>[db.js]"]
  node_database[("PostgreSQL database<br/>[schema.sql]")]
end

node_admin(("Administrator"))
node_employee(("Employee"))

node_admin -->|"signs in"| node_login
node_employee -->|"signs in"| node_login
node_login -->|"submits credentials"| node_authstate
node_authstate -->|"requests login"| node_clientapi
node_clientapi -.->|"sends API requests"| node_server
node_server -->|"mounts auth"| node_authroute
node_server -->|"mounts employees"| node_employeeroute
node_server -->|"mounts payslips"| node_paysliproute
node_server -->|"mounts attendance"| node_attendanceroute
node_server -->|"mounts leaves"| node_leaveroute
node_authroute -->|"queries users"| node_dbpool
node_authroute -.->|"issues JWTs"| node_authmw
node_authstate -->|"provides user"| node_app
node_app -->|"routes through"| node_layout
node_app -->|"routes to"| node_login
node_app -->|"routes to"| node_adminhome
node_app -->|"routes to"| node_employees
node_app -->|"routes to"| node_payroll
node_app -->|"routes to"| node_adminattendance
node_app -->|"routes to"| node_adminleaves
node_app -->|"routes to"| node_employeehome
node_app -->|"routes to"| node_payslips
node_app -->|"routes to"| node_employeeattendance
node_app -->|"routes to"| node_employeeleaves
node_adminhome -->|"fetches dashboard"| node_clientapi
node_employees -->|"requests records"| node_clientapi
node_payroll -->|"manages payroll"| node_clientapi
node_adminattendance -->|"requests attendance"| node_clientapi
node_adminleaves -->|"manages leave"| node_clientapi
node_employeehome -->|"fetches dashboard"| node_clientapi
node_payslips -->|"requests payslips"| node_clientapi
node_employeeattendance -->|"requests attendance"| node_clientapi
node_employeeleaves -->|"requests leave"| node_clientapi
node_employeeroute -->|"queries employees"| node_dbpool
node_attendanceroute -->|"queries attendance"| node_dbpool
node_leaveroute -->|"queries leave"| node_dbpool
node_paysliproute -->|"queries payslips"| node_dbpool
node_employeeroute -->|"authenticates requests"| node_authmw
node_attendanceroute -->|"authenticates requests"| node_authmw
node_leaveroute -->|"authenticates requests"| node_authmw
node_paysliproute -->|"authenticates requests"| node_authmw
node_paysliproute -.->|"generates PDF"| node_pdf
node_dbpool -.->|"connects to"| node_database

click node_app "https://github.com/puttirakesh/payroll_management_system/blob/main/client/src/App.jsx"
click node_login "https://github.com/puttirakesh/payroll_management_system/blob/main/client/src/pages/Login.jsx"
click node_authstate "https://github.com/puttirakesh/payroll_management_system/blob/main/client/src/context/AuthContext.jsx"
click node_layout "https://github.com/puttirakesh/payroll_management_system/blob/main/client/src/components/Layout.jsx"
click node_adminhome "https://github.com/puttirakesh/payroll_management_system/blob/main/client/src/pages/admin/Dashboard.jsx"
click node_employees "https://github.com/puttirakesh/payroll_management_system/blob/main/client/src/pages/admin/Employees.jsx"
click node_adminattendance "https://github.com/puttirakesh/payroll_management_system/blob/main/client/src/pages/admin/Attendance.jsx"
click node_employeeattendance "https://github.com/puttirakesh/payroll_management_system/blob/main/client/src/pages/employee/Attendance.jsx"
click node_adminleaves "https://github.com/puttirakesh/payroll_management_system/blob/main/client/src/pages/admin/Leaves.jsx"
click node_employeeleaves "https://github.com/puttirakesh/payroll_management_system/blob/main/client/src/pages/employee/Leaves.jsx"
click node_payroll "https://github.com/puttirakesh/payroll_management_system/blob/main/client/src/pages/admin/Payroll.jsx"
click node_payslips "https://github.com/puttirakesh/payroll_management_system/blob/main/client/src/pages/employee/Payslips.jsx"
click node_employeehome "https://github.com/puttirakesh/payroll_management_system/blob/main/client/src/pages/employee/Dashboard.jsx"
click node_clientapi "https://github.com/puttirakesh/payroll_management_system/blob/main/client/src/api.js"
click node_server "https://github.com/puttirakesh/payroll_management_system/blob/main/server/src/app.js"
click node_authroute "https://github.com/puttirakesh/payroll_management_system/blob/main/server/src/routes/auth.js"
click node_employeeroute "https://github.com/puttirakesh/payroll_management_system/blob/main/server/src/routes/employees.js"
click node_attendanceroute "https://github.com/puttirakesh/payroll_management_system/blob/main/server/src/routes/attendance.js"
click node_leaveroute "https://github.com/puttirakesh/payroll_management_system/blob/main/server/src/routes/leaves.js"
click node_paysliproute "https://github.com/puttirakesh/payroll_management_system/blob/main/server/src/routes/payslips.js"
click node_authmw "https://github.com/puttirakesh/payroll_management_system/blob/main/server/src/middleware/auth.js"
click node_pdf "https://github.com/puttirakesh/payroll_management_system/blob/main/server/src/utils/payslipPdf.js"
click node_dbpool "https://github.com/puttirakesh/payroll_management_system/blob/main/server/src/config/db.js"
click node_database "https://github.com/puttirakesh/payroll_management_system/blob/main/server/src/schema.sql"

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_app,node_login,node_authstate,node_layout,node_clientapi toneBlue
class node_adminhome,node_employees,node_employeehome toneAmber
class node_adminattendance,node_employeeattendance,node_adminleaves,node_employeeleaves toneMint
class node_payroll,node_payslips toneRose
class node_server,node_authroute,node_employeeroute,node_attendanceroute,node_leaveroute,node_paysliproute,node_authmw,node_pdf,node_dbpool,node_database,node_admin,node_employee toneIndigo
```

## Components

### Web application

- [Route application](https://github.com/puttirakesh/payroll_management_system/blob/main/client/src/App.jsx): `client/src/App.jsx`
- [Sign-in page](https://github.com/puttirakesh/payroll_management_system/blob/main/client/src/pages/Login.jsx): `client/src/pages/Login.jsx`
- [Authentication state](https://github.com/puttirakesh/payroll_management_system/blob/main/client/src/context/AuthContext.jsx): `client/src/context/AuthContext.jsx`
- [Role-based layout](https://github.com/puttirakesh/payroll_management_system/blob/main/client/src/components/Layout.jsx): `client/src/components/Layout.jsx`
- [API client](https://github.com/puttirakesh/payroll_management_system/blob/main/client/src/api.js): `client/src/api.js`

### People operations

- [Admin dashboard](https://github.com/puttirakesh/payroll_management_system/blob/main/client/src/pages/admin/Dashboard.jsx): `client/src/pages/admin/Dashboard.jsx`
- [Employee management](https://github.com/puttirakesh/payroll_management_system/blob/main/client/src/pages/admin/Employees.jsx): `client/src/pages/admin/Employees.jsx`
- [Employee dashboard](https://github.com/puttirakesh/payroll_management_system/blob/main/client/src/pages/employee/Dashboard.jsx): `client/src/pages/employee/Dashboard.jsx`

### Time and leave

- [Admin attendance](https://github.com/puttirakesh/payroll_management_system/blob/main/client/src/pages/admin/Attendance.jsx): `client/src/pages/admin/Attendance.jsx`
- [Employee attendance](https://github.com/puttirakesh/payroll_management_system/blob/main/client/src/pages/employee/Attendance.jsx): `client/src/pages/employee/Attendance.jsx`
- [Admin leave management](https://github.com/puttirakesh/payroll_management_system/blob/main/client/src/pages/admin/Leaves.jsx): `client/src/pages/admin/Leaves.jsx`
- [Employee leave requests](https://github.com/puttirakesh/payroll_management_system/blob/main/client/src/pages/employee/Leaves.jsx): `client/src/pages/employee/Leaves.jsx`

### Payroll and payslips

- [Payroll management](https://github.com/puttirakesh/payroll_management_system/blob/main/client/src/pages/admin/Payroll.jsx): `client/src/pages/admin/Payroll.jsx`
- [Employee payslips](https://github.com/puttirakesh/payroll_management_system/blob/main/client/src/pages/employee/Payslips.jsx): `client/src/pages/employee/Payslips.jsx`

### API and persistence

- [HTTP API](https://github.com/puttirakesh/payroll_management_system/blob/main/server/src/app.js): `server/src/app.js`
- [Authentication route](https://github.com/puttirakesh/payroll_management_system/blob/main/server/src/routes/auth.js): `server/src/routes/auth.js`
- [Employee routes](https://github.com/puttirakesh/payroll_management_system/blob/main/server/src/routes/employees.js): `server/src/routes/employees.js`
- [Attendance routes](https://github.com/puttirakesh/payroll_management_system/blob/main/server/src/routes/attendance.js): `server/src/routes/attendance.js`
- [Leave routes](https://github.com/puttirakesh/payroll_management_system/blob/main/server/src/routes/leaves.js): `server/src/routes/leaves.js`
- [Payslip routes](https://github.com/puttirakesh/payroll_management_system/blob/main/server/src/routes/payslips.js): `server/src/routes/payslips.js`
- [Token authorization](https://github.com/puttirakesh/payroll_management_system/blob/main/server/src/middleware/auth.js): `server/src/middleware/auth.js`
- [Payslip PDF generation](https://github.com/puttirakesh/payroll_management_system/blob/main/server/src/utils/payslipPdf.js): `server/src/utils/payslipPdf.js`
- [PostgreSQL connection](https://github.com/puttirakesh/payroll_management_system/blob/main/server/src/config/db.js): `server/src/config/db.js`
- [PostgreSQL database](https://github.com/puttirakesh/payroll_management_system/blob/main/server/src/schema.sql): `server/src/schema.sql`

### Other components

- **Administrator**
- **Employee**

## Connections

- Administrator → Sign-in page: signs in (evidence: `README.md`)
- Employee → Sign-in page: signs in (evidence: `README.md`)
- Sign-in page → Authentication state: submits credentials (evidence: `client/src/context/AuthContext.jsx`)
- Authentication state → API client: requests login (evidence: `client/src/context/AuthContext.jsx`)
- API client → HTTP API: sends API requests
- HTTP API → Authentication route: mounts auth (evidence: `server/src/app.js`)
- HTTP API → Employee routes: mounts employees (evidence: `server/src/app.js`)
- HTTP API → Payslip routes: mounts payslips (evidence: `server/src/app.js`)
- HTTP API → Attendance routes: mounts attendance (evidence: `server/src/app.js`)
- HTTP API → Leave routes: mounts leaves (evidence: `server/src/app.js`)
- Authentication route → PostgreSQL connection: queries users (evidence: `server/src/routes/auth.js`)
- Authentication route → Token authorization: issues JWTs
- Authentication state → Route application: provides user (evidence: `client/src/main.jsx`)
- Route application → Role-based layout: routes through (evidence: `client/src/App.jsx`)
- Route application → Sign-in page: routes to (evidence: `client/src/App.jsx`)
- Route application → Admin dashboard: routes to (evidence: `client/src/App.jsx`)
- Route application → Employee management: routes to (evidence: `client/src/App.jsx`)
- Route application → Payroll management: routes to (evidence: `client/src/App.jsx`)
- Route application → Admin attendance: routes to (evidence: `client/src/App.jsx`)
- Route application → Admin leave management: routes to (evidence: `client/src/App.jsx`)
- Route application → Employee dashboard: routes to (evidence: `client/src/App.jsx`)
- Route application → Employee payslips: routes to (evidence: `client/src/App.jsx`)
- Route application → Employee attendance: routes to (evidence: `client/src/App.jsx`)
- Route application → Employee leave requests: routes to (evidence: `client/src/App.jsx`)
- Admin dashboard → API client: fetches dashboard (evidence: `client/src/pages/admin/Dashboard.jsx`)
- Employee management → API client: requests records (evidence: `client/src/pages/admin/Employees.jsx`)
- Payroll management → API client: manages payroll (evidence: `client/src/pages/admin/Payroll.jsx`)
- Admin attendance → API client: requests attendance (evidence: `client/src/pages/admin/Attendance.jsx`)
- Admin leave management → API client: manages leave (evidence: `client/src/pages/admin/Leaves.jsx`)
- Employee dashboard → API client: fetches dashboard (evidence: `client/src/pages/employee/Dashboard.jsx`)
- Employee payslips → API client: requests payslips (evidence: `client/src/pages/employee/Payslips.jsx`)
- Employee attendance → API client: requests attendance (evidence: `client/src/pages/employee/Attendance.jsx`)
- Employee leave requests → API client: requests leave (evidence: `client/src/pages/employee/Leaves.jsx`)
- Employee routes → PostgreSQL connection: queries employees (evidence: `server/src/routes/employees.js`)
- Attendance routes → PostgreSQL connection: queries attendance (evidence: `server/src/routes/attendance.js`)
- Leave routes → PostgreSQL connection: queries leave (evidence: `server/src/routes/leaves.js`)
- Payslip routes → PostgreSQL connection: queries payslips (evidence: `server/src/routes/payslips.js`)
- Employee routes → Token authorization: authenticates requests (evidence: `server/src/routes/employees.js`)
- Attendance routes → Token authorization: authenticates requests (evidence: `server/src/routes/attendance.js`)
- Leave routes → Token authorization: authenticates requests (evidence: `server/src/routes/leaves.js`)
- Payslip routes → Token authorization: authenticates requests (evidence: `server/src/routes/payslips.js`)
- Payslip routes → Payslip PDF generation: generates PDF (evidence: `server/src/routes/payslips.js`)
- PostgreSQL connection → PostgreSQL database: connects to
