Skip to content

Latest commit

Β 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🏒 HR Management System

A full-stack Human Resources management solution designed to streamline employee administration, organizational department hierarchy, lookup classifications, vacation requests, and secure role-based authentication.


πŸ“‘ Table of Contents


🌟 Overview

The HR Management System provides organizations with a centralized platform to manage personnel records and organizational workflows. Key capabilities include:

  • πŸ” Authentication & RBAC: JWT Bearer authentication with role claims (Admin, HR, Manager, Developer) and BCrypt password encryption.
  • πŸ‘₯ Employee Management: Comprehensive employee profiles (position, department, manager hierarchy, start/end dates, active status) with automated user account generation.
  • 🏒 Department Tracking: Manage organizational departments, floor assignments, and department type classifications.
  • πŸ–οΈ Vacation & Leave Tracking: Vacation request lifecycle, date range tracking, leave categorization, notes, and aggregated leave analytics per employee.
  • 🏷️ Centralized Lookup System: Major/Minor code lookup dictionary for positions, department types, and leave types.

πŸ› System Architecture

graph TD
    Client["Angular 20 SPA (Client Browser)"]
    API["ASP.NET Core 8 Web API"]
    Auth["JWT Authentication & BCrypt Service"]
    EF["Entity Framework Core 9"]
    DB[("Microsoft SQL Server (Hr_System)")]

    Client -->|HTTP / REST API Requests| API
    Client -->|Bearer Token Header| Auth
    API -->|Validate Token / Issue JWT| Auth
    API -->|Queries & Commands| EF
    EF -->|SQL Queries & Migrations| DB
Loading

πŸ’» Tech Stack

Backend

  • Framework: .NET 8 (ASP.NET Core Web API)
  • ORM: Entity Framework Core 9 (Code-First)
  • Database: Microsoft SQL Server
  • Authentication: JWT Bearer Tokens (Microsoft.AspNetCore.Authentication.JwtBearer)
  • Password Security: BCrypt.Net-Next
  • API Documentation: Swagger / OpenAPI (Swashbuckle.AspNetCore)

Frontend


πŸ—„ Database Schema & Seed Data

Entity Relationship Model

erDiagram
    LOOKUP {
        bigint Id PK
        int MajorCode
        int MinorCode
        string Name
    }

    USER {
        bigint Id PK
        string UserName UK
        string HashedPassword
        bit IsAdmin
    }

    DEPARTMENT {
        bigint Id PK
        string Name
        string Description
        int FloorNumber
        bigint TypeId FK
    }

    EMPLOYEE {
        bigint Id PK
        string Name
        datetime BirthDate
        string Phone
        bit IsActive
        datetime StartDate
        datetime EndDate
        bigint DepartmentId FK
        bigint ManagerId FK
        bigint PositionId FK
        bigint UserId FK,UK
    }

    VACATION {
        bigint Id PK
        bigint EmployeeId FK
        datetime CreationDate
        datetime StartDate
        datetime EndDate
        bigint TypeId FK
        string Notes
    }

    LOOKUP ||--o{ DEPARTMENT : "categorizes (TypeId)"
    LOOKUP ||--o{ EMPLOYEE : "defines position (PositionId)"
    LOOKUP ||--o{ VACATION : "defines leave type (TypeId)"
    DEPARTMENT ||--o{ EMPLOYEE : "employs (DepartmentId)"
    EMPLOYEE ||--o{ EMPLOYEE : "manages (ManagerId)"
    USER ||--|| EMPLOYEE : "authenticates (UserId)"
    EMPLOYEE ||--o{ VACATION : "requests (EmployeeId)"
Loading

Pre-Seeded Lookup Data

Major Code Category Minor Code Name
0 Employee Positions 0 Header (Employee Positions)
0 Employee Positions 1 HR
0 Employee Positions 2 Manager
0 Employee Positions 3 Developer
1 Department Types 0 Header (Department Types)
1 Department Types 1 Finance
1 Department Types 2 Adminstrative
1 Department Types 3 Technical
2 Vacation Types 0 Header (Vacation Types)
2 Vacation Types 1 Annual Vacation
2 Vacation Types 2 Sick Vacation
2 Vacation Types 3 Unpaid Vacation

πŸ“‘ API Documentation & Endpoints

Swagger UI is available during development at: http://localhost:5160/swagger or https://localhost:7168/swagger

1. Authentication (/api/Auth)

Method Endpoint Description Auth Required
POST /api/Auth/Login Validates credentials and generates a signed JWT token with user claims & role ❌ No

Login Request Body:

{
  "userName": "Admin",
  "password": "Admin@123"
}

2. Employees (/api/Employees)

Method Endpoint Description Auth Required
GET /api/Employees/GetAll Retrieves filtered employee records πŸ”’ Yes (HR, Admin)
GET /api/Employees/GetById?Id={id} Retrieves a single employee by ID ❌ No
POST /api/Employees/Add Creates employee & automatically provisions user account ({Name}_HR) ❌ No
PUT /api/Employees/Update Updates employee details ❌ No
DELETE /api/Employees/Delete?id={id} Deletes an employee record ❌ No

Query Parameters for GetAll:

  • PositionId (long, optional)
  • EmployeeName (string, optional)
  • IsActive (bool, optional)

Create Employee Request Body:

{
  "name": "Jane Doe",
  "birthDate": "1995-04-12T00:00:00Z",
  "phone": "+962791234567",
  "isActive": true,
  "startDate": "2025-01-01T00:00:00Z",
  "endDate": null,
  "departmentId": 1,
  "managerId": null,
  "positionId": 2
}

Note: Creating an employee automatically generates a linked user account with username <Name>_HR and default password <Name>@123.


3. Departments (/api/Departments)

Method Endpoint Description Auth Required
GET /api/Departments/GetAll Retrieves departments with optional filters ❌ No
GET /api/Departments/GetById?Id={id} Retrieves single department details with lookup info ❌ No
POST /api/Departments/Add Creates a new department ❌ No
PUT /api/Departments/Update Modifies existing department info ❌ No
DELETE /api/Departments/Delete?Id={id} Deletes a department ❌ No

Create Department Request Body:

{
  "name": "Information Technology",
  "description": "Software development and infrastructure",
  "floorNumber": 3,
  "typeId": 8
}

4. Vacations (/api/Vacations)

Method Endpoint Description Auth Required
GET /api/Vacations/GetAll Retrieves vacation requests (filterable by EmployeeId & VacationTypeId) ❌ No
GET /api/Vacations/GetById?Id={id} Retrieves a vacation record by ID ❌ No
POST /api/Vacations/Add Submits a new vacation request ❌ No
PUT /api/Vacations/Update Updates vacation dates or details ❌ No
DELETE /api/Vacations/Delete?Id={id} Deletes a vacation request ❌ No
GET /api/Vacations/EmployeesVacationsCount Returns total vacation request counts grouped by employee ❌ No

Create Vacation Request Body:

{
  "employeeId": 1,
  "startDate": "2025-08-01T00:00:00Z",
  "endDate": "2025-08-07T00:00:00Z",
  "typeId": 10,
  "notes": "Annual family leave"
}

🎨 Frontend Overview

The client-side application is built with Angular 20 Standalone Components and Bootstrap 5:

  • Navigation Bar: Responsive navbar for navigating between Employees, Departments, and Vacations sections.
  • Employee Management Screen (EmployeesComponent):
    • Search & filter bar (by employee name, position, status).
    • Data table displaying employee name, phone, formatted dates, position, department, manager, and active/inactive badges.
    • Interactive Bootstrap modal for adding or editing employee records.
    • Reactive form validation (employeeForm).
  • Custom Utilities:
    • RandomColorDirective ([appRandomColor]): Assigns random vibrant background colors to elements.
    • ReversePipe (reverse): Pipe for reversing text strings.

πŸ“‚ Project Directory Structure

HR/
β”œβ”€β”€ HR.sln                             # Root Visual Studio Solution
β”œβ”€β”€ global.json                        # .NET SDK version configuration (8.0.413)
β”œβ”€β”€ README.md                          # Project documentation
β”‚
β”œβ”€β”€ HR/                                # Backend Web API (.NET 8)
β”‚   β”œβ”€β”€ Controllers/                   # API Controller Endpoints
β”‚   β”‚   β”œβ”€β”€ AuthController.cs          # Login & JWT token generator
β”‚   β”‚   β”œβ”€β”€ DepartmentsController.cs   # Department CRUD operations
β”‚   β”‚   β”œβ”€β”€ EmployeesController.cs     # Employee CRUD & User sync
β”‚   β”‚   └── VacationsController.cs     # Vacation CRUD & Analytics
β”‚   β”œβ”€β”€ DTOs/                          # Data Transfer Objects
β”‚   β”‚   β”œβ”€β”€ Auth/                      # Login DTOs
β”‚   β”‚   β”œβ”€β”€ Departments/               # Department Filter & Save DTOs
β”‚   β”‚   β”œβ”€β”€ Employees/                 # Employee Filter & Save DTOs
β”‚   β”‚   └── Vacations/                 # Vacation Filter, Save & Count DTOs
β”‚   β”œβ”€β”€ Migrations/                    # EF Core Database Migrations
β”‚   β”œβ”€β”€ Model/                         # Domain Entities
β”‚   β”‚   β”œβ”€β”€ Department.cs
β”‚   β”‚   β”œβ”€β”€ Employee.cs
β”‚   β”‚   β”œβ”€β”€ Lookup.cs
β”‚   β”‚   β”œβ”€β”€ User.cs
β”‚   β”‚   └── Vacation.cs
β”‚   β”œβ”€β”€ Properties/
β”‚   β”‚   └── launchSettings.json        # Port configurations (5160 / 7168)
β”‚   β”œβ”€β”€ HrDbContext.cs                 # EF Core DbContext with Seed Data
β”‚   β”œβ”€β”€ HR.csproj                      # Backend Project dependencies
β”‚   β”œβ”€β”€ Program.cs                     # API Middleware, JWT & DI Setup
β”‚   └── appsettings.json               # Database Connection String & Logging
β”‚
└── Frontend/                          # Frontend SPA
    └── HR/                            # Angular 20 Application
        β”œβ”€β”€ src/
        β”‚   β”œβ”€β”€ app/
        β”‚   β”‚   β”œβ”€β”€ components/
        β”‚   β”‚   β”‚   └── employees/     # Employees management component
        β”‚   β”‚   β”‚       β”œβ”€β”€ employees.ts
        β”‚   β”‚   β”‚       β”œβ”€β”€ employees.html
        β”‚   β”‚   β”‚       └── employees.css
        β”‚   β”‚   β”œβ”€β”€ directives/        # Custom Angular directives
        β”‚   β”‚   β”‚   └── random-color.ts
        β”‚   β”‚   β”œβ”€β”€ pipes/             # Custom Angular pipes
        β”‚   β”‚   β”‚   └── reverse-pipe.ts
        β”‚   β”‚   β”œβ”€β”€ app.ts             # Main root standalone component
        β”‚   β”‚   β”œβ”€β”€ app.html           # Main navigation layout
        β”‚   β”‚   β”œβ”€β”€ app.css
        β”‚   β”‚   └── app.config.ts      # Application config & providers
        β”‚   β”œβ”€β”€ index.html
        β”‚   β”œβ”€β”€ main.ts
        β”‚   └── styles.css
        β”œβ”€β”€ angular.json               # Angular CLI configuration
        β”œβ”€β”€ package.json               # Frontend dependencies & scripts
        └── tsconfig.json              # TypeScript compiler configuration

πŸš€ Getting Started & Local Setup

Prerequisites

Make sure you have the following installed on your machine:


Backend Setup (.NET 8)

  1. Navigate to the Backend directory:

    cd HR
  2. Configure Database Connection String: Open appsettings.json and adjust the HrContext connection string to match your SQL Server instance:

    {
      "ConnectionStrings": {
        "HrContext": "Server=localhost;Database=Hr_System;Trusted_Connection=True;MultipleActiveResultSets=true;TrustServerCertificate=True;"
      }
    }
  3. Apply Database Migrations & Seed Data: Ensure EF Core tools are installed, then apply the migrations:

    dotnet tool install --global dotnet-ef   # If not installed
    dotnet ef database update
  4. Run the Backend API:

    dotnet run

    The backend will start and listen at:

    • HTTP: http://localhost:5160
    • HTTPS: https://localhost:7168
    • Swagger Documentation: http://localhost:5160/swagger

Frontend Setup (Angular 20)

  1. Navigate to the Frontend project directory:

    cd Frontend/HR
  2. Install Dependencies:

    npm install
  3. Start the Development Server:

    npm start
    # or: ng serve
  4. Access the Application: Open your browser and navigate to:

    http://localhost:4200/
    

πŸ”‘ Default Credentials

The database migration pre-seeds a default administrator account:

Username Password Role Description
Admin Admin@123 Admin Full administrative privileges

⚠️ When new employees are added through /api/Employees/Add, corresponding user accounts are automatically created with:

  • Username: <EmployeeName>_HR (e.g. John_HR)
  • Password: <EmployeeName>@123 (e.g. John@123)

πŸ“„ License

This project is developed for internal Human Resources and personnel management operations.

About

Full-stack Human Resources management system built with ASP.NET Core 8 Web API, Entity Framework Core, SQL Server, and Angular 20 with JWT role-based authentication.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages