Business Operations System

HRM Platform

A production HR platform engineered to handle real-world employment workflows—connecting biometric attendance devices, leave management, complex payroll calculations, and Capacitor Android packaging into a unified system.

HRM Platform project
01 — Overview

Project details

Human resource management software is often mistakenly treated as a collection of simple CRUD forms for employee contact records. In day-to-day operations, an active company relies on an interconnected rules engine where punch-clock timestamps, approved leave balances, gazetted holidays, and payroll math directly govern one another.

As a Full-Stack Engineer on this project, I worked across the stack from Prisma database modeling and Next.js route handlers to biometric device synchronization boundaries, payroll calculation pipelines, and administrative dashboards. My priority was making business logic explicit, keeping calculation flows deterministic, and protecting historical records from accidental modification.

The platform supports daily operational routines including employee status tracking, biometric clock-in and clock-out processing with anomaly flags, shift assignments, leave approvals with quota validation, and monthly payroll generation with statutory tax and deduction withholding.

Year2026
RoleFull-Stack Engineer
TypeBusiness Operations System
AccessInternal Production System
02 — The problem

The challenge

In many companies, HR workflows are fragmented across separate tools: attendance logs sit trapped inside standalone biometric wall clocks, leave requests flow through informal chat messages, and month-end payroll is manually calculated on spreadsheets. This fragmentation creates reconciliation bottlenecks, calculation discrepancies, and tedious manual adjustments every month.

Bringing these workflows into a unified system introduced concrete engineering challenges. Biometric clocks from vendors like ZKTeco, devices using BS-SDK protocols, and Hikvision hardware communicate over erratic local office networks, frequently buffering offline punches and dumping out-of-order batches. A naive database design that updates employee compensation in place damages historical payroll audits. Moreover, payroll calculation is not basic multiplication: it must accurately account for mid-month joining dates, assigned rest days, statutory public holidays, paid versus unpaid leave (Loss of Pay), and Nepal regulatory contributions including Provident Fund and Social Security Fund (SSF).

03 — The approach

How I approached it

I structured the system by defining clear domain boundaries and enforcing all business rules on the server rather than trusting client state. The database schema separates current operational profiles from historical transaction records, ensuring that modifying an employee's salary today never distorts payroll slips generated in previous fiscal periods.

To handle physical attendance clocks safely, I isolated device communication behind a dedicated Node.js ingestion service. Instead of permitting hardware to write straight into core tables, punch events are verified, debounced, mapped from biometric device IDs to internal employee records, and aggregated into normalized daily summaries.

HRM Platform system preview and architecture overview
04 — Engineering

Engineering breakdown

The important parts of the project were not just the interface, but the systems and decisions behind it.

01

Biometric hardware integration and attendance processing boundaries

Physical attendance clocks installed across office facilities communicate over unpredictable local networks. Devices frequently buffer punches during connectivity interruptions and subsequently transmit large batches upon reconnection, producing duplicate timestamps and out-of-order records.

I worked with device integration protocols across ZKTeco, BS-SDK, and Hikvision hardware. To protect core application data, I established a dedicated integration boundary where external hardware forwards raw events—containing device user IDs, timestamps, and punch direction—to a specialized ingestion endpoint.

Incoming punches are debounced within a configurable time window to filter out accidental double-taps by employees. The server resolves punches against an explicit (employeeId, workDate) compound key, treating the earliest valid punch as clock-in and the latest valid punch as clock-out.

When an employee punches in but forgets to punch out, the system avoids leaving the day in an undefined state. Instead, it flags the record with a missing clock-out anomaly status, alerting managers during weekly regularization so approved adjustments can be entered with a clear operational reason.

02

Connecting daily attendance and leave quotas to the payroll calculation engine

Payroll computation is one of the most critical parts of business software: a calculation mistake of even a fraction of a day creates immediate operational friction and compliance problems.

The calculation engine avoids arbitrary 30-day divisions. It evaluates the exact calendar days of the target month, verifies mid-month joining or exit dates, accounts for designated weekly rest days, and checks approved leave balances.

Leave requests move through an explicit approval workflow. When approved, the system evaluates whether the employee has remaining paid leave quotas or if the absence must be categorized as unpaid leave (Loss of Pay / LOP).

During payroll processing, the pipeline aggregates verified attendance days, applies approved paid leave credits, deducts unpaid absences, includes approved overtime hours, and computes statutory deductions including income tax withholding, Provident Fund, and Social Security Fund (SSF) rules.

Crucially, the finalized calculation produces an immutable PayrollSlip record with granular line items. Storing finalized slips as historical snapshots ensures that pay slips remain verifiable even when base salaries change in subsequent months.

03

Employee status transitions and preserving historical compensation records

Employees progress through different phases: probation, active tenure, leave of absence, resignation, and occasional rejoining. In a basic CRUD system, updating an employee record is treated as a simple in-place SQL update.

In an operating HR platform, in-place updates destroy history. If an employee receives a salary adjustment in June, re-generating a March report must reflect their March compensation, not their June compensation. Similarly, if an employee resigns and rejoins months later, their past attendance and tax history must remain intact.

I modeled employment lifecycle events with explicit status transitions and historical salary records. Calculations for attendance, leave quotas, and payroll runs evaluate the specific compensation values that were effective during that target payroll cycle.

This architectural discipline required careful database planning, but it protected historical records from unintentional corruption as the company grew.

04

Multi-tenant architecture and data isolation boundaries (current phase)

The platform originally supported a single organization and is actively evolving toward multi-tenant capability to support multiple business entities and branch subsidiaries on shared infrastructure.

To build data isolation safely, I introduced organization scoping at the schema and query layers. Core operational models—including employees, attendance records, leave balances, and payroll runs—incorporate explicit organization identifiers with compound indices such as [organizationId, employeeCode].

Prisma queries are structured with organization scoping to ensure that data access is restricted to the authenticated user's organization context before business operations run.

To be transparent about the project's current state: schema isolation and query-level organization scoping are implemented in the database layer. Automated self-onboarding and cross-organization billing remain an ongoing engineering phase.

05

Packaging the web application for Android with Capacitor

To provide staff with mobile access without maintaining two independent codebases, I contributed to packaging the Next.js web application for Android using Capacitor.

This work involved setting up Capacitor configuration within the project, configuring the Android Studio workspace, managing Gradle dependencies, and tuning production WebView settings.

I configured application icons, splash assets, and orientation preferences, generated signed test APKs, and validated the build across emulators and physical Android devices.

To be clear about the mobile architecture: this is a responsive web application running inside an optimized Capacitor WebView container rather than a separate native Kotlin app. This choice allowed us to share authentication cookies and server-rendered workflows across mobile and desktop.

05

Key engineering work

  • Biometric hardware integration supporting ZKTeco, BS-SDK, and Hikvision device streams
  • Deterministic payroll pipeline calculating prorated workdays, leaves, and statutory deductions (PF/SSF)
  • Daily attendance normalization with missing clock-out anomaly detection
  • Employment status tracking maintaining historical compensation and audit records
  • Formal leave management workflow integrating paid quotas and Loss of Pay (LOP) deductions
  • Organization-scoped data models and query-level multi-tenant boundary preparation
  • Server-side JWT authentication with secure HttpOnly cookies and role-based route guards
  • Android APK packaging using Capacitor WebView integration and Gradle builds
06

Key decisions

  • Isolated biometric device traffic behind a dedicated ingestion service rather than allowing direct database writes.
  • Calculated payroll from verified attendance and approved leave snapshots rather than mutable client-calculated values.
  • Protected historical salary calculations by storing line-item snapshots on finalized pay slips.
  • Enforced organization-scoped query filtering at the database access layer to prevent cross-tenant data exposure.
  • Used Capacitor to deliver an Android mobile APK from the existing Next.js application without maintaining separate codebases.
07

Results

  • Unified attendance timestamps, leave requests, and payroll calculations into a single relational database schema.
  • Reduced manual month-end punch reconciliations by automating daily biometric clock aggregation.
  • Ensured auditability for payroll runs, linking every pay item directly to verified attendance and approved leave records.
  • Delivered both desktop browser and mobile Android access for employees and administrators from a unified codebase.
  • Established organization boundaries ready for ongoing multi-tenant expansion.
08

What I learned

  • Business software complexity is rarely in the number of dashboard screens; it lives in the interactions between business rules across domains.
  • Choosing between an in-place column update and an immutable snapshot determines whether historical audits can be trusted.
  • Hardware integrations require strict validation boundaries: external devices should never write directly to core operational models.
09 — Stack

Technologies

Next.js App RouterTypeScriptReactPrisma ORMMySQL / MariaDBNode.js & ExpressTailwind CSSJWT & HttpOnly CookiesbcryptZod ValidationCapacitorAndroid StudioDocker
10 — Visuals

Interface & Architecture

Visual highlights and system architecture from the HRM Platform project.

HRM Platform interface overview
HRM Platform Interface Overview
Next project

Have a problem
worth solving?

Whether you're building something new or improving an existing system, let's talk about the problem and what it would take to build it well.

Start a conversation