Skip to content

Work

Biometric Attendance Backend

Hardware is unreliable and HR data is evidence. Every step is replayable, auditable and safe to retry.

Role
Designed the architecture and backend
Status
In production.
Device
ZKTeco SenseFace 2A
Metric
Direct device integration, no vendor middleware
Stack
  • FastAPI
  • PostgreSQL
  • Alembic
  • Nginx
  • AWS EC2

Problems and answers

  • Device re-sends the same upload

    exact replays deduplicated; device gets OK only after the batch commits.

  • Accidental double scan

    kept as evidence; counts as checkout only after the shift's minimum gap.

  • Terminal offline, uploads hours later

    late punches recalculate the finalized day.

  • HR already corrected a day

    the override stays; the day is flagged "Review required".

  • Shift rules change

    immutable, effective-dated shift revisions; past days keep their rules.

  • Employee leaves

    identity disabled or deleted on terminals via a command queue.

  • Privacy

    no face or fingerprint templates or photos stored in the ERP.

The design

terminal → PUSH receiver → immutable raw event + work item (one transaction) → single advisory-locked worker → daily result → 7 reports. Bounded retry, crash recovery, heartbeat.

A terminal pushes to the PUSH receiver. One transaction stores an immutable raw event and a work item. A single advisory-locked worker turns it into a daily result, which feeds 7 reports. Bounded retry, crash recovery and a heartbeat protect the worker. The calendar shows a placeholder month.
  1. 01

    terminal → PUSH receiver → immutable raw event + work item (one transaction)

  2. 02

    Device re-sends the same upload → exact replays deduplicated; device gets OK only after the batch commits.

  3. 03

    single advisory-locked worker → daily result → 7 reports

  4. 04

    Terminal offline, uploads hours later → late punches recalculate the finalized day.

Key decisions

  • One locked worker instead of many: correctness first; multi-worker scaling waits until it can be proven safe.

  • Raw evidence is immutable; everything else is derived and can be recalculated.

  • Verify, don't trust: an AI-suggested device-authentication flow was checked against the device documentation and dropped before implementation because the hardware doesn't support it.

Next case study

"For You" Recommendation Engine