# mrkaran007/hrms-enterprise architecture

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

- Interactive diagram: https://gitdiagram.com/mrkaran007/hrms-enterprise
- Repository: https://github.com/mrkaran007/hrms-enterprise

## Overview

HRMS Enterprise is an ASP.NET Core API for employee and department administration, transfers, and JWT-based access control. Its principal workflow is an HTTP request through a controller to a business service, then repositories and a unit of work for persistence; employee transfers additionally record history within a transaction. Authentication and resource authorization form a distinct access-control branch. The README documents capabilities beyond the sampled code; those branches are included, while edges not visible in excerpts or explicit documentation are omitted.

Main entry points: [`HRMS.API/Data/HRMSDbContext.cs`](https://github.com/mrkaran007/hrms-enterprise/blob/master/HRMS.API/Data/HRMSDbContext.cs) (EF data context), [`HRMS.API/Services/Employee/EmployeeService.cs`](https://github.com/mrkaran007/hrms-enterprise/blob/master/HRMS.API/Services/Employee/EmployeeService.cs) (Employee rules), [`HRMS.API/Services/Auth/AuthService.cs`](https://github.com/mrkaran007/hrms-enterprise/blob/master/HRMS.API/Services/Auth/AuthService.cs) (Authentication rules), [`HRMS.API/Controllers/EmployeeController.cs`](https://github.com/mrkaran007/hrms-enterprise/blob/master/HRMS.API/Controllers/EmployeeController.cs) (Employee endpoints)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["HTTP API"]
  node_employee_api["Employee endpoints"]
  node_department_api["Department endpoints"]
  node_auth_api["Authentication endpoints<br/>[AuthController.cs]"]
  node_errors["Error handling"]
end

subgraph group_domain["HR Operations"]
  node_employee_service["Employee rules<br/>[EmployeeService.cs]"]
  node_department_service["Department rules"]
  node_transfer_history["Transfer history"]
  node_employee_dtos["Employee DTOs<br/>[Employee]"]
  node_department_dtos["Department DTOs<br/>[Department]"]
end

subgraph group_security["Identity &amp; Access"]
  node_auth_service["Authentication rules<br/>[AuthService.cs]"]
  node_jwt["JWT issuance<br/>[JwtService.cs]"]
  node_resource_access["Employee access policy"]
end

subgraph group_persistence["Persistence"]
  node_employee_repo["Employee repository"]
  node_department_repo["Department repository"]
  node_user_repo["User repository<br/>[UserRepository.cs]"]
  node_unit_of_work["Unit of work<br/>[UnitOfWork.cs]"]
  node_context["EF data context<br/>[HRMSDbContext.cs]"]
  node_entities["HR entities<br/>[Employee.cs]"]
end

node_client(("API caller"))
node_sql[("SQL Server")]

node_client -->|"sends requests"| node_employee_api
node_client -->|"sends requests"| node_department_api
node_client -->|"sends requests"| node_auth_api
node_employee_api -->|"calls"| node_employee_service
node_department_api -->|"calls"| node_department_service
node_auth_api -->|"calls"| node_auth_service
node_employee_service -->|"queries and updates"| node_employee_repo
node_employee_service -->|"checks departments"| node_department_repo
node_employee_service -->|"records and reads"| node_transfer_history
node_employee_service -->|"saves transaction"| node_unit_of_work
node_department_service -->|"manages departments"| node_department_repo
node_department_service -->|"checks assignments"| node_employee_repo
node_department_service -->|"saves changes"| node_unit_of_work
node_auth_service -->|"checks and stores users"| node_user_repo
node_auth_service -->|"validates employee link"| node_employee_repo
node_auth_service -->|"saves account"| node_unit_of_work
node_auth_service -->|"requests token"| node_jwt
node_employee_repo -->|"queries data"| node_context
node_department_repo -->|"queries data"| node_context
node_user_repo -->|"queries data"| node_context
node_transfer_history -->|"queries data"| node_context
node_unit_of_work -->|"saves changes"| node_context
node_context -->|"persists entities"| node_sql
node_context -->|"maps relationships"| node_entities
node_employee_api -->|"uses resource policy"| node_resource_access
node_errors -->|"returns JSON errors"| node_client
node_employee_api -->|"accepts and returns"| node_employee_dtos
node_department_api -->|"accepts requests"| node_department_dtos

click node_employee_api "https://github.com/mrkaran007/hrms-enterprise/blob/master/HRMS.API/Controllers/EmployeeController.cs"
click node_department_api "https://github.com/mrkaran007/hrms-enterprise/blob/master/HRMS.API/Controllers/DepartmentController.cs"
click node_auth_api "https://github.com/mrkaran007/hrms-enterprise/blob/master/HRMS.API/Controllers/AuthController.cs"
click node_errors "https://github.com/mrkaran007/hrms-enterprise/blob/master/HRMS.API/Middleware/ExceptionHandlingMiddleware.cs"
click node_employee_service "https://github.com/mrkaran007/hrms-enterprise/blob/master/HRMS.API/Services/Employee/EmployeeService.cs"
click node_department_service "https://github.com/mrkaran007/hrms-enterprise/blob/master/HRMS.API/Services/Department/DepartmentService.cs"
click node_transfer_history "https://github.com/mrkaran007/hrms-enterprise/blob/master/HRMS.API/Repositories/TransferHistory/TransferHistoryRepository.cs"
click node_employee_dtos "https://github.com/mrkaran007/hrms-enterprise/tree/master/HRMS.API/DTOs/Employee"
click node_department_dtos "https://github.com/mrkaran007/hrms-enterprise/tree/master/HRMS.API/DTOs/Department"
click node_auth_service "https://github.com/mrkaran007/hrms-enterprise/blob/master/HRMS.API/Services/Auth/AuthService.cs"
click node_jwt "https://github.com/mrkaran007/hrms-enterprise/blob/master/HRMS.API/Services/Auth/JwtService.cs"
click node_resource_access "https://github.com/mrkaran007/hrms-enterprise/blob/master/HRMS.API/Authorization/EmployeeAccessHandler.cs"
click node_employee_repo "https://github.com/mrkaran007/hrms-enterprise/blob/master/HRMS.API/Repositories/Employee/EmployeeRepository.cs"
click node_department_repo "https://github.com/mrkaran007/hrms-enterprise/blob/master/HRMS.API/Repositories/Department/DepartmentRepository.cs"
click node_user_repo "https://github.com/mrkaran007/hrms-enterprise/blob/master/HRMS.API/Repositories/User/UserRepository.cs"
click node_unit_of_work "https://github.com/mrkaran007/hrms-enterprise/blob/master/HRMS.API/Repositories/UnitOfWork.cs"
click node_context "https://github.com/mrkaran007/hrms-enterprise/blob/master/HRMS.API/Data/HRMSDbContext.cs"
click node_entities "https://github.com/mrkaran007/hrms-enterprise/blob/master/HRMS.API/Models/Employee.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_employee_api,node_department_api,node_auth_api,node_errors toneBlue
class node_employee_service,node_department_service,node_transfer_history,node_employee_dtos,node_department_dtos,node_sql toneAmber
class node_auth_service,node_jwt,node_resource_access,node_client toneMint
class node_employee_repo,node_department_repo,node_user_repo,node_unit_of_work,node_context,node_entities toneRose
```

## Components

### HTTP API

- [Employee endpoints](https://github.com/mrkaran007/hrms-enterprise/blob/master/HRMS.API/Controllers/EmployeeController.cs): `HRMS.API/Controllers/EmployeeController.cs`
- [Department endpoints](https://github.com/mrkaran007/hrms-enterprise/blob/master/HRMS.API/Controllers/DepartmentController.cs): `HRMS.API/Controllers/DepartmentController.cs`
- [Authentication endpoints](https://github.com/mrkaran007/hrms-enterprise/blob/master/HRMS.API/Controllers/AuthController.cs): `HRMS.API/Controllers/AuthController.cs`
- [Error handling](https://github.com/mrkaran007/hrms-enterprise/blob/master/HRMS.API/Middleware/ExceptionHandlingMiddleware.cs): `HRMS.API/Middleware/ExceptionHandlingMiddleware.cs`

### HR Operations

- [Employee rules](https://github.com/mrkaran007/hrms-enterprise/blob/master/HRMS.API/Services/Employee/EmployeeService.cs): `HRMS.API/Services/Employee/EmployeeService.cs`
- [Department rules](https://github.com/mrkaran007/hrms-enterprise/blob/master/HRMS.API/Services/Department/DepartmentService.cs): `HRMS.API/Services/Department/DepartmentService.cs`
- [Transfer history](https://github.com/mrkaran007/hrms-enterprise/blob/master/HRMS.API/Repositories/TransferHistory/TransferHistoryRepository.cs): `HRMS.API/Repositories/TransferHistory/TransferHistoryRepository.cs`
- [Employee DTOs](https://github.com/mrkaran007/hrms-enterprise/tree/master/HRMS.API/DTOs/Employee): `HRMS.API/DTOs/Employee`
- [Department DTOs](https://github.com/mrkaran007/hrms-enterprise/tree/master/HRMS.API/DTOs/Department): `HRMS.API/DTOs/Department`

### Identity & Access

- [Authentication rules](https://github.com/mrkaran007/hrms-enterprise/blob/master/HRMS.API/Services/Auth/AuthService.cs): `HRMS.API/Services/Auth/AuthService.cs`
- [JWT issuance](https://github.com/mrkaran007/hrms-enterprise/blob/master/HRMS.API/Services/Auth/JwtService.cs): `HRMS.API/Services/Auth/JwtService.cs`
- [Employee access policy](https://github.com/mrkaran007/hrms-enterprise/blob/master/HRMS.API/Authorization/EmployeeAccessHandler.cs): `HRMS.API/Authorization/EmployeeAccessHandler.cs`

### Persistence

- [Employee repository](https://github.com/mrkaran007/hrms-enterprise/blob/master/HRMS.API/Repositories/Employee/EmployeeRepository.cs): `HRMS.API/Repositories/Employee/EmployeeRepository.cs`
- [Department repository](https://github.com/mrkaran007/hrms-enterprise/blob/master/HRMS.API/Repositories/Department/DepartmentRepository.cs): `HRMS.API/Repositories/Department/DepartmentRepository.cs`
- [User repository](https://github.com/mrkaran007/hrms-enterprise/blob/master/HRMS.API/Repositories/User/UserRepository.cs): `HRMS.API/Repositories/User/UserRepository.cs`
- [Unit of work](https://github.com/mrkaran007/hrms-enterprise/blob/master/HRMS.API/Repositories/UnitOfWork.cs): `HRMS.API/Repositories/UnitOfWork.cs`
- [EF data context](https://github.com/mrkaran007/hrms-enterprise/blob/master/HRMS.API/Data/HRMSDbContext.cs): `HRMS.API/Data/HRMSDbContext.cs`
- [HR entities](https://github.com/mrkaran007/hrms-enterprise/blob/master/HRMS.API/Models/Employee.cs): `HRMS.API/Models/Employee.cs`

### Other components

- **API caller**
- **SQL Server**

## Connections

- API caller → Employee endpoints: sends requests (evidence: `README.md`)
- API caller → Department endpoints: sends requests (evidence: `README.md`)
- API caller → Authentication endpoints: sends requests (evidence: `README.md`)
- Employee endpoints → Employee rules: calls (evidence: `HRMS.API/Controllers/EmployeeController.cs`)
- Department endpoints → Department rules: calls (evidence: `HRMS.API/Controllers/DepartmentController.cs`)
- Authentication endpoints → Authentication rules: calls (evidence: `HRMS.API/Controllers/AuthController.cs`)
- Employee rules → Employee repository: queries and updates (evidence: `HRMS.API/Services/Employee/EmployeeService.cs`)
- Employee rules → Department repository: checks departments (evidence: `HRMS.API/Services/Employee/EmployeeService.cs`)
- Employee rules → Transfer history: records and reads (evidence: `HRMS.API/Services/Employee/EmployeeService.cs`)
- Employee rules → Unit of work: saves transaction (evidence: `HRMS.API/Services/Employee/EmployeeService.cs`)
- Department rules → Department repository: manages departments (evidence: `HRMS.API/Services/Department/DepartmentService.cs`)
- Department rules → Employee repository: checks assignments (evidence: `HRMS.API/Services/Department/DepartmentService.cs`)
- Department rules → Unit of work: saves changes (evidence: `HRMS.API/Services/Department/DepartmentService.cs`)
- Authentication rules → User repository: checks and stores users (evidence: `HRMS.API/Services/Auth/AuthService.cs`)
- Authentication rules → Employee repository: validates employee link (evidence: `HRMS.API/Services/Auth/AuthService.cs`)
- Authentication rules → Unit of work: saves account (evidence: `HRMS.API/Services/Auth/AuthService.cs`)
- Authentication rules → JWT issuance: requests token (evidence: `HRMS.API/Services/Auth/AuthService.cs`)
- Employee repository → EF data context: queries data (evidence: `HRMS.API/Repositories/Employee/EmployeeRepository.cs`)
- Department repository → EF data context: queries data (evidence: `HRMS.API/Repositories/Department/DepartmentRepository.cs`)
- User repository → EF data context: queries data (evidence: `HRMS.API/Repositories/User/UserRepository.cs`)
- Transfer history → EF data context: queries data (evidence: `HRMS.API/Repositories/TransferHistory/TransferHistoryRepository.cs`)
- Unit of work → EF data context: saves changes (evidence: `HRMS.API/Repositories/UnitOfWork.cs`)
- EF data context → SQL Server: persists entities (evidence: `README.md`)
- EF data context → HR entities: maps relationships (evidence: `HRMS.API/Data/HRMSDbContext.cs`)
- Employee endpoints → Employee access policy: uses resource policy (evidence: `README.md`)
- Error handling → API caller: returns JSON errors (evidence: `README.md`)
- Employee endpoints → Employee DTOs: accepts and returns (evidence: `HRMS.API/Controllers/EmployeeController.cs`)
- Department endpoints → Department DTOs: accepts requests (evidence: `HRMS.API/Controllers/DepartmentController.cs`)
