Employee Management (HRM)
Relevant source files
The following files were used as context for generating this wiki page:
- packages/core/src/lib/employee/employee.entity.ts
- apps/gauzy/src/app/pages/employees/employees.component.ts
- packages/core/src/lib/organization-department/organization-department.entity.ts
- packages/core/src/lib/organization-team/organization-team.entity.ts
- apps/gauzy/src/app/pages/employees/employees.module.ts
- packages/mcp-server/src/lib/tools/employees.ts
- apps/gauzy-e2e/src/integration/ManageEmployeesTest.ts
- apps/gauzy-e2e/src/integration/EditEmployeeTest.ts
- packages/mcp-server/src/lib/schema.ts
- apps/gauzy/src/app/pages/users/users.component.ts
- README.md
The Employee Management (HRM) module is a core feature of the Gauzy platform, designed for comprehensive human resource management. It facilitates the entire employee lifecycle, from onboarding and data management to their integration within the organizational structure. This module allows for the creation, editing, and management of employee profiles, including personal details, employment status, rates, and associations with projects, teams, and departments. It also supports inviting new employees and converting existing platform users into employees.
Sources: README.md, apps/gauzy/src/app/pages/employees/employees.component.ts, packages/core/src/lib/employee/employee.entity.ts
Data Model: The Employee Entity
The central data structure for the HRM module is the Employee entity. It encapsulates all information related to an employee, linking them to a User account and a Contact profile, and embedding them within the organizational hierarchy.
Sources: packages/core/src/lib/employee/employee.entity.ts
Entity Relationships
The Employee entity is interconnected with several other key entities within the platform, forming the backbone of the HRM data model.
The diagram below illustrates the main relationships of the Employee entity.
Key Employee Entity Fields
The Employee entity contains a wide range of fields to store detailed information. Below are some of the most significant ones.
| Field | Type | Description |
|---|---|---|
userId | ID | Foreign key linking to the User entity. Each employee must have a user account. |
contactId | ID | Foreign key linking to the Contact entity for personal contact details. |
organizationId | ID | Foreign key linking to the Organization the employee belongs to. |
organizationPositionId | ID | Foreign key for the employee's role or position within the organization. |
startedWorkOn | Date | The date when the employee started working. |
endWork | Date | The date when the employee's work ended. |
payPeriod | PayPeriodEnum | The payment frequency (e.g., WEEKLY, MONTHLY). |
billRateValue | number | The employee's billing rate, typically per hour. |
isTrackingEnabled | boolean | A flag to enable or disable time tracking for the employee. |
allowScreenshotCapture | boolean | A flag to enable or disable screen capture for the employee. |
customFields | EmployeeEntityCustomFields | Embedded object for storing custom data fields. |
Sources: packages/core/src/lib/employee/employee.entity.ts:40-249, packages/mcp-server/src/lib/schema.ts:221-337
Core Functionality
The HRM module provides a user interface and API for managing employees throughout their lifecycle.
Employee Creation and Onboarding
There are two primary ways to add an employee to the system: inviting them via email or creating a new employee record directly.
The following flowchart illustrates the process of adding a new employee.
- Invite Employee: An administrator can send an invitation to one or more email addresses. The invite includes an optional start date and project assignment. The recipient then completes their registration.
- Add Employee: A multi-step form allows for the creation of a complete employee profile, including user credentials, personal information, employment details (start date, tags), and financial rates.
Editing Employee Information
Existing employee profiles can be extensively modified through a tabbed interface.
The following components are part of the employee editing interface:
- Account: Basic user information like username, email, and name.
- Networks: Social and professional network links (e.g., LinkedIn, GitHub).
- Employment: Job-related information like description and employment type.
- Hiring: Dates related to the hiring process (offer, acceptance).
- Location: Physical address details.
- Rates: Billing rates and weekly work limits.
- Projects: Association with organizational projects.
- Contacts: Association with organizational contacts.
Sources: apps/gauzy-e2e/src/integration/EditEmployeeTest.ts:100-165, apps/gauzy/src/app/pages/employees/employees.module.ts:90-107
Employee Status Management
- End Work: An employee's contract can be terminated by setting an
endWorkdate. This action marks the employee as inactive. - Delete Employee: This action performs a soft delete, marking the employee record as deleted but retaining it in the database for historical purposes.
- Convert User to Employee: A standard platform user can be converted into an employee. This is useful for internal staff who were initially registered as regular users. The
convertUserToEmployeefunction inusers.component.tshandles this by creating a newEmployeerecord linked to the existingUserID.
Sources: apps/gauzy-e2e/src/integration/ManageEmployeesTest.ts:128-143, apps/gauzy/src/app/pages/users/users.component.ts:479-503
Frontend Architecture
The employee management feature is encapsulated within the EmployeesModule. This module imports and declares all necessary components, services, and shared modules for handling employee data.
Component Structure
The diagram below shows the key components of the EmployeesModule and their relationships.
Key Frontend Components
| Component | File | Description |
|---|---|---|
EmployeesComponent | employees.component.ts | The main component for listing, viewing, and managing employees. It handles data loading for the smart table and user interactions like adding, editing, and deleting. |
EditEmployeeComponent | edit-employee/edit-employee.component.ts | The container component for the employee editing form. |
EditEmployeeProfileComponent | edit-employee/edit-employee-profile/edit-employee-profile.component.ts | Manages the tabbed layout for editing different sections of an employee's profile. |
EditEmployeeMainComponent | edit-employee/edit-employee-profile/edit-employee-main/edit-employee-main.component.ts | Form for editing the main account details of an employee. |
ManageEmployeeInviteComponent | manage-employee-invite/manage-employee-invite.component.ts | Component for managing pending employee invitations. |
EmployeeWorkStatusComponent | table-components/employee-work-status/employee-work-status.component.ts | A custom table cell component to display the employee's work status (Active, Ended). |
Sources: apps/gauzy/src/app/pages/employees/employees.module.ts:80-107, apps/gauzy/src/app/pages/employees/employees.component.ts
API and Tooling
The backend provides a set of tools for interacting with employee data, exposed via an API. These tools are defined in packages/mcp-server/src/lib/tools/employees.ts and use zod for schema validation.
API Call Sequence Example
This sequence diagram shows a typical flow for fetching a list of employees from the frontend.
Employee API Tools
The employees.ts file registers several tools for employee management.
| Tool Name | Description | Key Parameters |
|---|---|---|
get_employees | Get a paginated list of employees for an organization. | page, limit, search, relations, where |
get_employee_count | Get the total count of employees in an organization. | where |
get_employee | Get a specific employee by their ID. | id, relations |
create_employee | Create a new employee in the organization. | employee_data (based on EmployeeSchema) |
update_employee | Update an existing employee. | id, employee_data |
soft_delete_employee | Soft delete (archive) an employee. | id |
restore_employee | Restore a soft-deleted employee. | id |
bulk_create_employees | Create multiple employees in a single request. | employees (array of employee data) |
Sources: packages/mcp-server/src/lib/tools/employees.ts
Conclusion
The Employee Management (HRM) module is a foundational part of the Gauzy platform, providing robust tools for managing an organization's workforce. Through a well-defined data model centered on the Employee entity, a comprehensive set of API endpoints, and a feature-rich user interface, it supports the full employee lifecycle. The system is designed for flexibility, allowing employees to be structured within departments and teams, and enabling detailed tracking of their work, performance, and financial information.