Command Palette

Search for a command to run...

0

Command Palette

Search for a command to run...

Projects
ProjectHR / Workforce2023

Attendance Management System

Full-featured employee attendance management system built as part of a multi-tenant property management backend. Handles the complete attendance lifecycle — check-in/out, late detection, GPS validation, shift configuration, and multi-day leave approval workflows — with timezone-aware business logic.

Tech Stack

  • Go
  • Gin
  • MongoDB
  • JWT

Key Features

  • Timezone-aware check-in/out using IANA timezone middleware — all day-boundary logic runs in the employee's local timezone
  • Automatic late arrival and early checkout detection with configurable per-shift tolerance windows
  • Multi-day leave approval workflow with auto-generated daily attendance records for each working day
  • GPS coordinate validation rejecting physical attendance submissions with zero-value coordinates
  • Duplicate check-in prevention and bulk off-day management for entire workspaces
  • Work hours auto-calculation on checkout based on check-in/out timestamps

Architecture

3-layer clean architecture with MongoDB view

  • 1.Controller layer: route binding, auth context, HTTP response
  • 2.Service layer: business logic, rule enforcement, data orchestration
  • 3.MongoDB layer: generic CRUD abstraction + pre-aggregated v_attendance view
  • 4.Read operations query v_attendance view (enriched with employee detail via $lookup)

Data / Processing Flow

  1. 01Request arrives with IANA timezone header parsed by TimezoneMiddleware
  2. 02Service resolves shift schedule for the employee's current day-of-week
  3. 03Shift reference time projected onto today's date in the employee's timezone
  4. 04Late/early detection compares current time against projected deadline + tolerance
  5. 05GPS validation runs before any database write for physical attendance
  6. 06Result persisted and linked to parent leave record if applicable

Use Cases

  • Employee daily attendance tracking with timezone support
  • HR reporting for late arrivals and early checkouts
  • Leave request management with multi-step approval
  • Shift schedule compliance verification
  • Bulk holiday management across workspace employees

My Contributions

  • Built TimezoneMiddleware for IANA-based per-request timezone resolution.
  • Implemented late/early detection by projecting shift reference hh:mm:ss onto today's date.
  • Designed leave state machine (pending → approved/rejected → cancel) with auto-generated daily records.
  • Built GPS validation, duplicate check-in guard, and bulk off-day endpoint.
  • Designed MongoDB v_attendance view to avoid repeated aggregation on read paths.

Technical Highlights

  • TimezoneMiddleware projects shift hh:mm:ss onto today's date — eliminates epoch-based date comparison bugs
  • Leave state machine generates individual daily records for each working day (Sunday skipped)
  • MongoDB v_attendance view pre-joins employee detail, keeping write paths clean
  • All day-boundary calculations (StartOfDay, EndOfDay) run in employee timezone, not server timezone

Challenges Solved

  • !Shift reference times were stored as epoch ms from 2024 — fixed by projecting only hh:mm:ss onto today's date in the correct timezone
  • !Check-in date off-by-one for UTC+9 users — resolved by using request timezone for all boundary calculations
  • !Leave record orphaning on cancellation — fixed with atomic parent revert + bulk child delete by parentId
  • !Duplicate check-ins on network retry — fixed with pre-flight status query before any insert
Buka tautan projectKembali ke daftar

http://localhost:3000/projects/attendance-system