Business Systems——4 min read

What It Takes to Build an HR Management System

From attendance and leave to payroll, device integrations, fiscal years, and permissions: the engineering challenges behind building a production HR platform.

Professional team collaborating around a table in a modern office

Human resource management software is often viewed from the outside as an administrative directory: a database of employee names, job titles, phone numbers, and emergency contacts. In an active company, however, an operating HR platform is a rules engine where physical attendance hardware, approved leave requests, fiscal holiday calendars, and monthly compensation math continuously govern one another.

Over the past year building our internal HRM Platform, I worked across the full lifecycle of workforce software. What makes business software difficult is rarely the number of visual dashboard screens; it is the friction of translating ambiguous, real-world workplace rules into deterministic, auditable software logic.

The challenge of physical attendance hardware

In standard web applications, users interact with software through clean browser inputs. In an HR system, daily attendance is generated by physical biometric wall clocks—devices manufactured by vendors like ZKTeco, hardware running BS-SDK protocols, or Hikvision face-recognition terminals.

These devices introduce distinct integration problems. They communicate over unpredictable local office networks, buffer punches during internet outages, and dump thousands of out-of-order timestamps when reconnected. Furthermore, hardware registers users by an internal device ID (such as device_user_id: 104), which must be accurately mapped to system employee records without collision across multiple office branches.

typescript
// Normalizing raw biometric punch events into daily attendance
export async function processBiometricPunch(rawPunch: RawDevicePunch) {
  const { deviceUserId, timestamp, deviceId } = rawPunch;

  // 1. Resolve employee mapping from biometric hardware ID
  const mapping = await prisma.biometricMapping.findUnique({
    where: { deviceId_deviceUserId: { deviceId, deviceUserId } }
  });
  if (!mapping) {
    return recordUnmappedPunch(rawPunch);
  }

  const workDate = getLocalDateString(timestamp);

  // 2. Upsert daily attendance record with earliest clock-in and latest clock-out
  return await prisma.attendance.upsert({
    where: {
      employeeId_workDate: { employeeId: mapping.employeeId, workDate }
    },
    create: {
      employeeId: mapping.employeeId,
      workDate,
      clockIn: timestamp,
      status: "PRESENT"
    },
    update: {
      clockOut: timestamp // Updates latest punch timestamp
    }
  });
}

Debouncing punches and detecting anomaly states

Employees frequently double-tap fingerprint sensors or punch in twice within two minutes to make sure the clock registered. An attendance ingestion service must debounce events within a configurable window (e.g. 5 minutes) to avoid registering the same touch as both clock-in and clock-out.

When an employee punches in at 9:00 AM but rushes home without punching out, the system cannot leave the record in an open state indefinitely. Our ingestion pipeline flags the record with a MISSING_CLOCKOUT anomaly status. During weekly attendance regularization, supervisors can review flagged anomalies and record approved manual adjustments accompanied by an audit reason.

The deterministic payroll calculation pipeline

Payroll is the most unforgiving component of business software. An arithmetic discrepancy of even a fraction of a day damages employee trust and creates regulatory compliance liabilities. Naive calculations that divide monthly salary by 30 days immediately break during February or months with 31 days.

Our payroll pipeline evaluates the exact calendar structure of the pay cycle:

• **Prorated employment days:** Verifying exact hire dates for employees who joined mid-month so compensation reflects actual days worked.

• **Leave reconciliation:** Joining against the leave approval engine. If an employee took approved leave, the pipeline checks whether remaining paid quotas cover the absence or if it must be deducted as unpaid Loss of Pay (LOP).

• **Statutory withholdings:** Computing regulatory deductions including income tax brackets, Provident Fund (PF), and Social Security Fund (SSF) rules according to Nepal labour regulations.

Crucial architectural decision: Finalized payroll slips are stored as immutable line-item snapshots in a PayrollSlip table. They are never computed on the fly from current employee profile records, ensuring that historical tax records remain completely verifiable years later.

Preserving historical records across employee lifecycle events

Employees move through distinct career phases: probation, active service, title promotions, salary adjustments, resignations, and occasional rejoining. In a simple CRUD database, an update is treated as an in-place UPDATE employees SET salary = ... statement.

In an enterprise HR platform, in-place updates destroy historical audit trails. If an employee receives a salary adjustment in July, re-printing a tax certificate for February must reflect their February compensation, not their July compensation. We resolved this by decoupling current employment profiles from historical compensation and attendance snapshots.

Conclusion and key lessons

Building an HR management system taught me that database schema design is business logic. The decisions you make regarding relational constraints, immutable historical snapshots, and integration boundaries determine whether an operational platform remains reliable as workforce complexity scales.

Dipesh Thapa

Dipesh Thapa

Full-Stack Engineer based in Nepal, specializing in Next.js, TypeScript, Prisma, and high-performance server architectures.

Related posts

Browse all articles

Get engineering
notes

Technical case studies, engineering lessons, and notes from building real-world digital products and systems.

Logo icon

Occasional deep-dives into software architecture, database performance, payment integration, and engineering practices.

No spam · Unsubscribe anytime