# gabvx-cmd/hrms architecture

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

- Interactive diagram: https://gitdiagram.com/gabvx-cmd/hrms
- Repository: https://github.com/gabvx-cmd/hrms

## Overview

This is a PHP HR management system for employee records, accounts, attendance, and leave requests. The clearest evidenced workflow is HR staff adding or editing an employee: the page validates submitted data, calls the Employee model, and the model persists it; the dashboard reads employee records for summary views. The shared bootstrap establishes the session and PDO connection and instantiates the models. Several feature pages and models are present in the tree but were not sampled, so their internal wiring is not asserted here.

Main entry points: [`includes/db_connect.php`](https://github.com/gabvx-cmd/hrms/blob/main/includes/db_connect.php) (Shared bootstrap), [`includes/auth_guard.php`](https://github.com/gabvx-cmd/hrms/blob/main/includes/auth_guard.php) (Role guard), [`employee_form.php`](https://github.com/gabvx-cmd/hrms/blob/main/employee_form.php) (Employee form), [`classes/employee.php`](https://github.com/gabvx-cmd/hrms/blob/main/classes/employee.php) (Employee model)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_access["Access and Bootstrap"]
  node_bootstrap["Shared bootstrap<br/>[db_connect.php]"]
  node_guard["Role guard<br/>[auth_guard.php]"]
  node_login["Login and logout<br/>[login.php]"]
  node_account["Account creation<br/>[create_account.php]"]
  node_user_model["User model<br/>[user.php]"]
  node_db_config["PDO configuration<br/>[db.php]"]
end

subgraph group_people["Employee Records"]
  node_employee_pages["Employee list and delete<br/>[employees.php]"]
  node_employee_form["Employee form<br/>[employee_form.php]"]
  node_dashboard["HR dashboard<br/>[index.php]"]
  node_employee_model["Employee model<br/>[employee.php]"]
  node_employee_home["Employee dashboard"]
end

subgraph group_timeoff["Attendance and Leave"]
  node_attendance_pages["Attendance pages"]
  node_attendance_home["Employee attendance"]
  node_attendance_model["Attendance model<br/>[attendance.php]"]
  node_leave_pages["Leave request pages<br/>[leave_admin.php]"]
  node_leave_home["Employee leave<br/>[leave_employee.php]"]
  node_leave_model["Leave request model<br/>[leave_request.php]"]
end

node_hr(("HR staff"))
node_employee(("Employee"))
node_database[("HRMS database<br/>[schema.sql]")]

node_hr -->|"submits details"| node_employee_form
node_employee_form -->|"loads setup"| node_bootstrap
node_employee_form -->|"checks role"| node_guard
node_employee_form -->|"creates or updates"| node_employee_model
node_employee_form -->|"checks duplicate email"| node_database
node_employee_pages -->|"loads setup"| node_bootstrap
node_employee_pages -->|"checks role"| node_guard
node_employee_pages -->|"manages records"| node_employee_model
node_dashboard -->|"loads setup"| node_bootstrap
node_dashboard -->|"checks role"| node_guard
node_dashboard -->|"fetches employees"| node_employee_model
node_employee_model -->|"reads and writes"| node_database
node_bootstrap -->|"opens connection"| node_db_config
node_bootstrap -->|"instantiates"| node_user_model
node_bootstrap -->|"instantiates"| node_employee_model
node_bootstrap -->|"instantiates"| node_attendance_model
node_bootstrap -->|"instantiates"| node_leave_model
node_login -->|"loads setup"| node_bootstrap
node_login -->|"authenticates"| node_user_model
node_account -->|"loads setup"| node_bootstrap
node_account -->|"checks role"| node_guard
node_account -->|"creates account"| node_user_model
node_user_model -->|"reads and writes"| node_database
node_attendance_pages -->|"loads setup"| node_bootstrap
node_attendance_pages -->|"checks role"| node_guard
node_attendance_home -->|"loads setup"| node_bootstrap
node_attendance_model -->|"reads and writes"| node_database
node_leave_pages -->|"loads setup"| node_bootstrap
node_leave_pages -->|"checks role"| node_guard
node_leave_home -->|"loads setup"| node_bootstrap
node_leave_model -->|"reads and writes"| node_database
node_employee -->|"views own dashboard"| node_employee_home

click node_bootstrap "https://github.com/gabvx-cmd/hrms/blob/main/includes/db_connect.php"
click node_guard "https://github.com/gabvx-cmd/hrms/blob/main/includes/auth_guard.php"
click node_login "https://github.com/gabvx-cmd/hrms/blob/main/login.php"
click node_account "https://github.com/gabvx-cmd/hrms/blob/main/create_account.php"
click node_user_model "https://github.com/gabvx-cmd/hrms/blob/main/classes/user.php"
click node_employee_pages "https://github.com/gabvx-cmd/hrms/blob/main/employees.php"
click node_employee_form "https://github.com/gabvx-cmd/hrms/blob/main/employee_form.php"
click node_dashboard "https://github.com/gabvx-cmd/hrms/blob/main/index.php"
click node_employee_model "https://github.com/gabvx-cmd/hrms/blob/main/classes/employee.php"
click node_employee_home "https://github.com/gabvx-cmd/hrms/blob/main/employee_dashboard.php"
click node_attendance_pages "https://github.com/gabvx-cmd/hrms/blob/main/attendance_admin.php"
click node_attendance_home "https://github.com/gabvx-cmd/hrms/blob/main/attendance_employee.php"
click node_attendance_model "https://github.com/gabvx-cmd/hrms/blob/main/classes/attendance.php"
click node_leave_pages "https://github.com/gabvx-cmd/hrms/blob/main/leave_admin.php"
click node_leave_home "https://github.com/gabvx-cmd/hrms/blob/main/leave_employee.php"
click node_leave_model "https://github.com/gabvx-cmd/hrms/blob/main/classes/leave_request.php"
click node_db_config "https://github.com/gabvx-cmd/hrms/blob/main/config/db.php"
click node_database "https://github.com/gabvx-cmd/hrms/blob/main/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_bootstrap,node_guard,node_login,node_account,node_user_model,node_db_config toneBlue
class node_employee_pages,node_employee_form,node_dashboard,node_employee_model,node_employee_home,node_database toneAmber
class node_attendance_pages,node_attendance_home,node_attendance_model,node_leave_pages,node_leave_home,node_leave_model toneMint
class node_hr,node_employee toneIndigo
```

## Components

### Access and Bootstrap

- [Shared bootstrap](https://github.com/gabvx-cmd/hrms/blob/main/includes/db_connect.php): `includes/db_connect.php`
- [Role guard](https://github.com/gabvx-cmd/hrms/blob/main/includes/auth_guard.php): `includes/auth_guard.php`
- [Login and logout](https://github.com/gabvx-cmd/hrms/blob/main/login.php): `login.php`
- [Account creation](https://github.com/gabvx-cmd/hrms/blob/main/create_account.php): `create_account.php`
- [User model](https://github.com/gabvx-cmd/hrms/blob/main/classes/user.php): `classes/user.php`
- [PDO configuration](https://github.com/gabvx-cmd/hrms/blob/main/config/db.php): `config/db.php`

### Employee Records

- [Employee list and delete](https://github.com/gabvx-cmd/hrms/blob/main/employees.php): `employees.php`
- [Employee form](https://github.com/gabvx-cmd/hrms/blob/main/employee_form.php): `employee_form.php`
- [HR dashboard](https://github.com/gabvx-cmd/hrms/blob/main/index.php): `index.php`
- [Employee model](https://github.com/gabvx-cmd/hrms/blob/main/classes/employee.php): `classes/employee.php`
- [Employee dashboard](https://github.com/gabvx-cmd/hrms/blob/main/employee_dashboard.php): `employee_dashboard.php`

### Attendance and Leave

- [Attendance pages](https://github.com/gabvx-cmd/hrms/blob/main/attendance_admin.php): `attendance_admin.php`
- [Employee attendance](https://github.com/gabvx-cmd/hrms/blob/main/attendance_employee.php): `attendance_employee.php`
- [Attendance model](https://github.com/gabvx-cmd/hrms/blob/main/classes/attendance.php): `classes/attendance.php`
- [Leave request pages](https://github.com/gabvx-cmd/hrms/blob/main/leave_admin.php): `leave_admin.php`
- [Employee leave](https://github.com/gabvx-cmd/hrms/blob/main/leave_employee.php): `leave_employee.php`
- [Leave request model](https://github.com/gabvx-cmd/hrms/blob/main/classes/leave_request.php): `classes/leave_request.php`

### Other components

- **HR staff**
- **Employee**
- [HRMS database](https://github.com/gabvx-cmd/hrms/blob/main/schema.sql): `schema.sql`

## Connections

- HR staff → Employee form: submits details
- Employee form → Shared bootstrap: loads setup
- Employee form → Role guard: checks role
- Employee form → Employee model: creates or updates
- Employee form → HRMS database: checks duplicate email
- Employee list and delete → Shared bootstrap: loads setup
- Employee list and delete → Role guard: checks role
- Employee list and delete → Employee model: manages records
- HR dashboard → Shared bootstrap: loads setup
- HR dashboard → Role guard: checks role
- HR dashboard → Employee model: fetches employees
- Employee model → HRMS database: reads and writes
- Shared bootstrap → PDO configuration: opens connection
- Shared bootstrap → User model: instantiates
- Shared bootstrap → Employee model: instantiates
- Shared bootstrap → Attendance model: instantiates
- Shared bootstrap → Leave request model: instantiates
- Login and logout → Shared bootstrap: loads setup
- Login and logout → User model: authenticates
- Account creation → Shared bootstrap: loads setup
- Account creation → Role guard: checks role
- Account creation → User model: creates account
- User model → HRMS database: reads and writes
- Attendance pages → Shared bootstrap: loads setup
- Attendance pages → Role guard: checks role
- Employee attendance → Shared bootstrap: loads setup
- Attendance model → HRMS database: reads and writes
- Leave request pages → Shared bootstrap: loads setup
- Leave request pages → Role guard: checks role
- Employee leave → Shared bootstrap: loads setup
- Leave request model → HRMS database: reads and writes
- Employee → Employee dashboard: views own dashboard
