# dwisusanto29/payslip_system architecture

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

- Interactive diagram: https://gitdiagram.com/dwisusanto29/payslip_system
- Repository: https://github.com/dwisusanto29/payslip_system

## Overview

Payslip System is an Express API for employee payroll. Employees register or log in, submit attendance, overtime and reimbursement data, then retrieve generated payslips; administrators define attendance periods, run payroll and view period summaries. Routes apply authentication and admin authorization before invoking controllers, which query PostgreSQL through the shared connection pool. The sampled controllers show payroll calculations and payslip reads. The README documents the API capabilities; implementation details are based on the sampled source files.

Main entry points: [`src/index.js`](https://github.com/dwisusanto29/payslip_system/blob/main/src/index.js) (Express server), [`src/routes/userRoutes.js`](https://github.com/dwisusanto29/payslip_system/blob/main/src/routes/userRoutes.js) (User routes), [`src/routes/adminRoutes.js`](https://github.com/dwisusanto29/payslip_system/blob/main/src/routes/adminRoutes.js) (Admin routes), [`src/config/database.js`](https://github.com/dwisusanto29/payslip_system/blob/main/src/config/database.js) (PostgreSQL connection pool)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API entry"]
  node_server["Express server<br/>[index.js]"]
  node_user_routes["User routes<br/>[userRoutes.js]"]
  node_admin_routes["Admin routes<br/>[adminRoutes.js]"]
end

subgraph group_access["Identity and access"]
  node_auth["JWT access checks<br/>[authMiddleware.js]"]
end

subgraph group_workforce["Workforce inputs"]
  node_user_controller["User operations<br/>[userController.js]"]
end

subgraph group_payroll["Payroll and reporting"]
  node_admin_controller["Payroll operations<br/>[adminController.js]"]
end

subgraph group_storage["Persistence"]
  node_db_pool["PostgreSQL connection pool<br/>[database.js]"]
  node_postgres[("PostgreSQL data<br/>[schema.sql]")]
end

node_employee(("Employee"))
node_administrator(("Administrator"))

node_employee -->|"sends API requests"| node_server
node_administrator -->|"sends API requests"| node_server
node_server -->|"mounts user routes"| node_user_routes
node_server -->|"mounts admin routes"| node_admin_routes
node_user_routes -->|"dispatches user actions"| node_user_controller
node_user_routes -->|"checks protected requests"| node_auth
node_admin_routes -->|"checks admin access"| node_auth
node_admin_routes -->|"dispatches admin actions"| node_admin_controller
node_user_controller -->|"queries user data"| node_db_pool
node_admin_controller -->|"queries payroll data"| node_db_pool
node_db_pool -->|"reads and writes"| node_postgres

click node_server "https://github.com/dwisusanto29/payslip_system/blob/main/src/index.js"
click node_user_routes "https://github.com/dwisusanto29/payslip_system/blob/main/src/routes/userRoutes.js"
click node_admin_routes "https://github.com/dwisusanto29/payslip_system/blob/main/src/routes/adminRoutes.js"
click node_auth "https://github.com/dwisusanto29/payslip_system/blob/main/src/middleware/authMiddleware.js"
click node_user_controller "https://github.com/dwisusanto29/payslip_system/blob/main/src/controllers/userController.js"
click node_admin_controller "https://github.com/dwisusanto29/payslip_system/blob/main/src/controllers/adminController.js"
click node_db_pool "https://github.com/dwisusanto29/payslip_system/blob/main/src/config/database.js"
click node_postgres "https://github.com/dwisusanto29/payslip_system/blob/main/src/models/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_server,node_user_routes,node_admin_routes toneBlue
class node_auth toneAmber
class node_user_controller toneMint
class node_admin_controller toneRose
class node_db_pool,node_postgres,node_employee,node_administrator toneIndigo
```

## Components

### API entry

- [Express server](https://github.com/dwisusanto29/payslip_system/blob/main/src/index.js): `src/index.js`
- [User routes](https://github.com/dwisusanto29/payslip_system/blob/main/src/routes/userRoutes.js): `src/routes/userRoutes.js`
- [Admin routes](https://github.com/dwisusanto29/payslip_system/blob/main/src/routes/adminRoutes.js): `src/routes/adminRoutes.js`

### Identity and access

- [JWT access checks](https://github.com/dwisusanto29/payslip_system/blob/main/src/middleware/authMiddleware.js): `src/middleware/authMiddleware.js`

### Workforce inputs

- [User operations](https://github.com/dwisusanto29/payslip_system/blob/main/src/controllers/userController.js): `src/controllers/userController.js`

### Payroll and reporting

- [Payroll operations](https://github.com/dwisusanto29/payslip_system/blob/main/src/controllers/adminController.js): `src/controllers/adminController.js`

### Persistence

- [PostgreSQL connection pool](https://github.com/dwisusanto29/payslip_system/blob/main/src/config/database.js): `src/config/database.js`
- [PostgreSQL data](https://github.com/dwisusanto29/payslip_system/blob/main/src/models/schema.sql): `src/models/schema.sql`

### Other components

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

## Connections

- Employee → Express server: sends API requests
- Administrator → Express server: sends API requests
- Express server → User routes: mounts user routes
- Express server → Admin routes: mounts admin routes
- User routes → User operations: dispatches user actions
- User routes → JWT access checks: checks protected requests
- Admin routes → JWT access checks: checks admin access
- Admin routes → Payroll operations: dispatches admin actions
- User operations → PostgreSQL connection pool: queries user data
- Payroll operations → PostgreSQL connection pool: queries payroll data
- PostgreSQL connection pool → PostgreSQL data: reads and writes
