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.
- 01
terminal → PUSH receiver → immutable raw event + work item (one transaction)
- 02
Device re-sends the same upload → exact replays deduplicated; device gets OK only after the batch commits.
- 03
single advisory-locked worker → daily result → 7 reports
- 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.