# kahoccode/hrmanagementsystem architecture

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

- Interactive diagram: https://gitdiagram.com/kahoccode/hrmanagementsystem
- Repository: https://github.com/kahoccode/hrmanagementsystem

## Overview

This is an ASP.NET Core HR application whose main workflow is role-authorized employee and manager operations: maintain employee records, record and review attendance or leave, calculate and approve payroll, then report or notify on outcomes. Its distinct domain stages include annual-leave policy and balance processing, attendance adjustments, multi-level payroll review, and employee hierarchy management. MVC and API controllers expose these capabilities over a shared EF Core data layer. The README documents broad feature coverage; sampled source confirms selected payroll, attendance, leave, authorization, and annual-leave behavior, so unsampled subsystem wiring is shown only at directory level.

Main entry points: [`HRManagementSystem/Data/HrDbContext.cs`](https://github.com/kahoccode/hrmanagementsystem/blob/master/HRManagementSystem/Data/HrDbContext.cs) (HR data context), [`HRManagementSystem/ApiControllers`](https://github.com/kahoccode/hrmanagementsystem/tree/master/HRManagementSystem/ApiControllers) (REST endpoints), [`HRManagementSystem/Program.cs`](https://github.com/kahoccode/hrmanagementsystem/blob/master/HRManagementSystem/Program.cs) (Application setup), [`HRManagementSystem/Controllers`](https://github.com/kahoccode/hrmanagementsystem/tree/master/HRManagementSystem/Controllers) (MVC pages)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_access["Access and employees"]
  node_mvc["MVC pages"]
  node_api["REST endpoints"]
  node_account["Account access"]
  node_employees["Employee records"]
  node_authorization["Permission policies"]
end

subgraph group_workforce["Workforce operations"]
  node_attendance["Attendance workflow"]
  node_attendance_review["Attendance review"]
  node_attendance_reports["Attendance reports"]
  node_leave["Leave requests"]
  node_leave_review["Leave approvals"]
  node_leave_policy["Leave policies"]
  node_leave_config["Leave configuration"]
  node_leave_service["Leave balance service<br/>[PhepNamService.cs]"]
end

subgraph group_payroll["Payroll and reporting"]
  node_payroll["Payroll processing"]
  node_payroll_review["Payroll approvals"]
  node_payroll_calc["Payroll calculator"]
  node_reports["Payroll reports"]
end

subgraph group_platform["Application platform"]
  node_email["Email delivery<br/>[EmailService.cs]"]
  node_scheduled["Annual leave tasks"]
  node_context["HR data context<br/>[HrDbContext.cs]"]
  node_sql[("SQL Server")]
  node_program["Application setup<br/>[Program.cs]"]
end

node_employee(("Employee"))
node_manager(("HR manager"))

node_employee -->|"uses pages"| node_mvc
node_manager -->|"uses pages"| node_mvc
node_employee -->|"sends requests"| node_api
node_manager -->|"sends requests"| node_api
node_mvc -->|"routes requests"| node_account
node_mvc -->|"routes requests"| node_employees
node_api -->|"routes requests"| node_attendance
node_api -->|"routes requests"| node_leave
node_api -->|"routes requests"| node_payroll
node_account -->|"checks access"| node_authorization
node_employees -->|"checks permissions"| node_authorization
node_attendance_review -->|"reads and updates"| node_context
node_attendance_reports -->|"reads records"| node_context
node_leave_review -->|"reads and updates"| node_context
node_leave_config -->|"reads and updates"| node_context
node_leave_policy -->|"reads and updates"| node_context
node_leave_service -->|"reads and updates"| node_context
node_leave_review -->|"sends notices"| node_email
node_payroll_review -->|"reads and updates"| node_context
node_payroll -->|"calculates pay"| node_payroll_calc
node_payroll -->|"reads and writes"| node_context
node_payroll -->|"generates reports"| node_reports
node_scheduled -->|"processes balances"| node_leave_service
node_context -->|"persists data"| node_sql
node_program -->|"configures database"| node_context
node_program -->|"registers policies"| node_authorization
node_program -->|"hosts tasks"| node_scheduled
node_program -->|"registers service"| node_email

click node_mvc "https://github.com/kahoccode/hrmanagementsystem/tree/master/HRManagementSystem/Controllers"
click node_api "https://github.com/kahoccode/hrmanagementsystem/tree/master/HRManagementSystem/ApiControllers"
click node_account "https://github.com/kahoccode/hrmanagementsystem/blob/master/HRManagementSystem/Controllers/AccountController.cs"
click node_employees "https://github.com/kahoccode/hrmanagementsystem/blob/master/HRManagementSystem/Controllers/EmployeesController.cs"
click node_authorization "https://github.com/kahoccode/hrmanagementsystem/tree/master/HRManagementSystem/Authorization"
click node_attendance "https://github.com/kahoccode/hrmanagementsystem/tree/master/HRManagementSystem/ApiControllers"
click node_attendance_review "https://github.com/kahoccode/hrmanagementsystem/blob/master/HRManagementSystem/ApiControllers/AttendanceManagerApiController.cs"
click node_attendance_reports "https://github.com/kahoccode/hrmanagementsystem/blob/master/HRManagementSystem/ApiControllers/AttendanceReportApiController.cs"
click node_leave "https://github.com/kahoccode/hrmanagementsystem/tree/master/HRManagementSystem/ApiControllers"
click node_leave_review "https://github.com/kahoccode/hrmanagementsystem/blob/master/HRManagementSystem/ApiControllers/LeaveManagerApiController.cs"
click node_leave_policy "https://github.com/kahoccode/hrmanagementsystem/blob/master/HRManagementSystem/Controllers/ChinhSachPhepNamController.cs"
click node_leave_config "https://github.com/kahoccode/hrmanagementsystem/blob/master/HRManagementSystem/Controllers/CauHinhPhepNamController.cs"
click node_leave_service "https://github.com/kahoccode/hrmanagementsystem/blob/master/HRManagementSystem/Services/PhepNamService.cs"
click node_payroll "https://github.com/kahoccode/hrmanagementsystem/tree/master/HRManagementSystem/ApiControllers"
click node_payroll_review "https://github.com/kahoccode/hrmanagementsystem/blob/master/HRManagementSystem/ApiControllers/PayrollManagerApiController.cs"
click node_payroll_calc "https://github.com/kahoccode/hrmanagementsystem/blob/master/HRManagementSystem/Services/PayrollCalculator.cs"
click node_reports "https://github.com/kahoccode/hrmanagementsystem/blob/master/HRManagementSystem/Services/PayrollReportService.cs"
click node_email "https://github.com/kahoccode/hrmanagementsystem/blob/master/HRManagementSystem/Services/EmailService.cs"
click node_scheduled "https://github.com/kahoccode/hrmanagementsystem/blob/master/HRManagementSystem/Services/BackgroundService.cs"
click node_context "https://github.com/kahoccode/hrmanagementsystem/blob/master/HRManagementSystem/Data/HrDbContext.cs"
click node_program "https://github.com/kahoccode/hrmanagementsystem/blob/master/HRManagementSystem/Program.cs"

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_mvc,node_api,node_account,node_employees,node_authorization toneBlue
class node_attendance,node_attendance_review,node_attendance_reports,node_leave,node_leave_review,node_leave_policy,node_leave_config,node_leave_service toneAmber
class node_payroll,node_payroll_review,node_payroll_calc,node_reports toneMint
class node_email,node_scheduled,node_context,node_sql,node_program toneRose
class node_employee,node_manager toneIndigo
```

## Components

### Access and employees

- [MVC pages](https://github.com/kahoccode/hrmanagementsystem/tree/master/HRManagementSystem/Controllers): `HRManagementSystem/Controllers`
- [REST endpoints](https://github.com/kahoccode/hrmanagementsystem/tree/master/HRManagementSystem/ApiControllers): `HRManagementSystem/ApiControllers`
- [Account access](https://github.com/kahoccode/hrmanagementsystem/blob/master/HRManagementSystem/Controllers/AccountController.cs): `HRManagementSystem/Controllers/AccountController.cs`
- [Employee records](https://github.com/kahoccode/hrmanagementsystem/blob/master/HRManagementSystem/Controllers/EmployeesController.cs): `HRManagementSystem/Controllers/EmployeesController.cs`
- [Permission policies](https://github.com/kahoccode/hrmanagementsystem/tree/master/HRManagementSystem/Authorization): `HRManagementSystem/Authorization`

### Workforce operations

- [Attendance workflow](https://github.com/kahoccode/hrmanagementsystem/tree/master/HRManagementSystem/ApiControllers): `HRManagementSystem/ApiControllers`
- [Attendance review](https://github.com/kahoccode/hrmanagementsystem/blob/master/HRManagementSystem/ApiControllers/AttendanceManagerApiController.cs): `HRManagementSystem/ApiControllers/AttendanceManagerApiController.cs`
- [Attendance reports](https://github.com/kahoccode/hrmanagementsystem/blob/master/HRManagementSystem/ApiControllers/AttendanceReportApiController.cs): `HRManagementSystem/ApiControllers/AttendanceReportApiController.cs`
- [Leave requests](https://github.com/kahoccode/hrmanagementsystem/tree/master/HRManagementSystem/ApiControllers): `HRManagementSystem/ApiControllers`
- [Leave approvals](https://github.com/kahoccode/hrmanagementsystem/blob/master/HRManagementSystem/ApiControllers/LeaveManagerApiController.cs): `HRManagementSystem/ApiControllers/LeaveManagerApiController.cs`
- [Leave policies](https://github.com/kahoccode/hrmanagementsystem/blob/master/HRManagementSystem/Controllers/ChinhSachPhepNamController.cs): `HRManagementSystem/Controllers/ChinhSachPhepNamController.cs`
- [Leave configuration](https://github.com/kahoccode/hrmanagementsystem/blob/master/HRManagementSystem/Controllers/CauHinhPhepNamController.cs): `HRManagementSystem/Controllers/CauHinhPhepNamController.cs`
- [Leave balance service](https://github.com/kahoccode/hrmanagementsystem/blob/master/HRManagementSystem/Services/PhepNamService.cs): `HRManagementSystem/Services/PhepNamService.cs`

### Payroll and reporting

- [Payroll processing](https://github.com/kahoccode/hrmanagementsystem/tree/master/HRManagementSystem/ApiControllers): `HRManagementSystem/ApiControllers`
- [Payroll approvals](https://github.com/kahoccode/hrmanagementsystem/blob/master/HRManagementSystem/ApiControllers/PayrollManagerApiController.cs): `HRManagementSystem/ApiControllers/PayrollManagerApiController.cs`
- [Payroll calculator](https://github.com/kahoccode/hrmanagementsystem/blob/master/HRManagementSystem/Services/PayrollCalculator.cs): `HRManagementSystem/Services/PayrollCalculator.cs`
- [Payroll reports](https://github.com/kahoccode/hrmanagementsystem/blob/master/HRManagementSystem/Services/PayrollReportService.cs): `HRManagementSystem/Services/PayrollReportService.cs`

### Application platform

- [Email delivery](https://github.com/kahoccode/hrmanagementsystem/blob/master/HRManagementSystem/Services/EmailService.cs): `HRManagementSystem/Services/EmailService.cs`
- [Annual leave tasks](https://github.com/kahoccode/hrmanagementsystem/blob/master/HRManagementSystem/Services/BackgroundService.cs): `HRManagementSystem/Services/BackgroundService.cs`
- [HR data context](https://github.com/kahoccode/hrmanagementsystem/blob/master/HRManagementSystem/Data/HrDbContext.cs): `HRManagementSystem/Data/HrDbContext.cs`
- **SQL Server**
- [Application setup](https://github.com/kahoccode/hrmanagementsystem/blob/master/HRManagementSystem/Program.cs): `HRManagementSystem/Program.cs`

### Other components

- **Employee**
- **HR manager**

## Connections

- Employee → MVC pages: uses pages
- HR manager → MVC pages: uses pages
- Employee → REST endpoints: sends requests
- HR manager → REST endpoints: sends requests
- MVC pages → Account access: routes requests
- MVC pages → Employee records: routes requests
- REST endpoints → Attendance workflow: routes requests
- REST endpoints → Leave requests: routes requests
- REST endpoints → Payroll processing: routes requests
- Account access → Permission policies: checks access
- Employee records → Permission policies: checks permissions
- Attendance review → HR data context: reads and updates
- Attendance reports → HR data context: reads records
- Leave approvals → HR data context: reads and updates
- Leave configuration → HR data context: reads and updates
- Leave policies → HR data context: reads and updates
- Leave balance service → HR data context: reads and updates
- Leave approvals → Email delivery: sends notices
- Payroll approvals → HR data context: reads and updates
- Payroll processing → Payroll calculator: calculates pay
- Payroll processing → HR data context: reads and writes
- Payroll processing → Payroll reports: generates reports
- Annual leave tasks → Leave balance service: processes balances
- HR data context → SQL Server: persists data
- Application setup → HR data context: configures database
- Application setup → Permission policies: registers policies
- Application setup → Annual leave tasks: hosts tasks
- Application setup → Email delivery: registers service
