Dev.to WebDev πŸ›  Dev πŸ‘ 0 πŸ“– 6 min read

Building Geofenced, Liveness-Aware Face Attendance Without Turning It Into Spyware

Attendance apps look simple from the outside: a worker taps Check in, a photo is taken, a pin appears on a map, and HR sees a green row. The hard part is everything that happens between that tap and a payroll-safe event.

Attendance apps look simple from the outside: a worker taps Check in, a photo is taken, a pin appears on a map, and HR sees a green row. The hard part is everything that happens between that tap and a payroll-safe event. A still photo can be pointed at another phone. Consumer GPS can jump tens of metres beside a tall building. And a system that records a face plus a coordinate is processing personal data, which in Indonesia is regulated under the Personal Data Protection Law (UU PDP).

This article walks through a practical architecture for a clock-in service that combines a geofence with face verification and a simple liveness prompt. It is written for engineers and technical founders. I will use AbsenKuy, an Indonesian HRIS, as a real-world reference for product choices such as a 50Γ’β‚¬β€œ1,000 metre geofence radius and a head-movement challenge rather than a still selfie. The same design can be implemented in your own stack; this is not a vendor tutorial.

What you should record, and what you should not

A defensible attendance event is a point-in-time record, not a continuous track:

  • employee identifier and device or session identifier;
  • event type (clock in, clock out, break);
  • server-received timestamp, plus the client timestamp if you want to detect clock skew;
  • a location sample (coordinates, accuracy radius, source);
  • a face-verification result (match / no match / inconclusive) and a liveness result;
  • the policy decision (accepted, rejected, or held for review).

You generally do not need a breadcrumb trail of the worker moving through the city, nor a raw video archive that lives forever. Continuous tracking drains batteries, explodes storage, and is harder to justify as purpose-limited processing. Prefer a single sample at the moment of the tap, and a short-lived image used for matching, then store a template or a verification score according to a written retention policy.

Geofence checks belong on the server

Do the authoritative geofence test on the server, even if the app already disables the button when the OS says the user is outside the circle. Client-side checks are a courtesy to the worker; they are not a control. A request should carry the location sample and accuracy, and the server should:

  1. load the siteÒ€ℒs centre point and radius (per branch, warehouse, or project site);
  2. compute the distance, and also consider the reported accuracy (a 30-metre accuracy claim next to a 50-metre radius is not the same as a tight fix);
  3. apply the site policy: reject, accept with a warning, or queue for a supervisor.

A single global radius is a product smell. A shop doorway and a factory gate are not the same place. AbsenKuyÒ€ℒs 50Γ’β‚¬β€œ1,000 metre range is a useful illustration: start looser in the first two weeks, then tighten after you have seen the real cluster of points. Night-shift sites, basement loading docks, and dense urban canyons will otherwise generate a queue of Ò€œfalse outsideÒ€ events that HR learns to rubber-stamp, which defeats the control.

Face match is not liveness

A 1:1 match against an enrolled template answers Ò€œdoes this look like the enrolled worker?Ò€. It does not answer Ò€œis a live person in front of the camera?Ò€. A printed photo or a video on a second screen can still fool a naive matcher.

A practical liveness step for attendance is a short challenge-response: look straight, turn left or right, or lift the chin, then accept the event only if both the motion and the match succeed. That is more usable in a shop doorway than a long video selfie, and harder to spoof than a single frame. Keep the challenge unpredictable enough that a pre-recorded clip is awkward to reuse.

Enrollment must be a deliberate act, with the workerÒ€ℒs informed consent, a reasonable photo (lighting, unobstructed face), and a way to re-enrol after a haircut, glasses, or a failed streak. Run a trial mode for the first days so legitimate workers are not locked out while templates settle.

Build an anomaly queue, not a silent auto-reject

Auto-reject feels strict and fails in production. GPS jumps, a wet camera lens, or a new helmet can block an honest clock-in two minutes before a shift. Auto-accept with no review is the opposite failure: coordinated fraud becomes invisible.

A small rules engine can flag events rather than decide pay on the spot:

  • location well outside the fence, or accuracy so poor the fence is meaningless;
  • identical coordinates repeated across many days or many people (a classic shared-pin pattern);
  • impossible travel between two sites in a short window;
  • repeated liveness or match failures followed by a sudden success;
  • clock-in from a rooted or mock-location environment, if you can detect it honestly and tell the user why.

Flagged events go to a supervisor queue with the minimum data needed to decide: time, site, distance from the fence, and verification outcome. Do not paste a social-media-style photo feed to the whole company.

Privacy and security constraints that change the design

Treat face templates and location history as sensitive. In an Indonesian context, spell out the purpose (attendance and wage calculation), the operators who can view it, the retention period, and the deletion path when someone resigns. Encrypt templates at rest, restrict admin roles, and keep an audit log of manual overrides. If the app only works online, because the server must see the face and the point, say so in the worker guide and offer a Ò€œretry sendÒ€ path when the signal returns, rather than punishing the first outage.

Also separate the mobile client from payroll. The attendance service should emit immutable events. Payslips should consume approved hours, not re-implement geofence math. That boundary makes audits possible.

A minimal service shape

A boring, workable shape is:

  • a worker web or mobile client (some products, including AbsenKuy, run in the phone browser and avoid an app-store client);
  • an attendance API that writes events, runs fence and verification, and returns accept / reject / pending;
  • an enrollment service with consent records;
  • a review console for HR;
  • an export or payroll consumer for approved time.

You can buy this as a product or build it. If you buy, test the path that actually breaks systems: a night shift that crosses midnight, a worker assigned to two sites in one week, a mid-shift signal drop, and a rejected face that needs a human correction. AbsenKuyÒ€ℒs public pricing is unusual in a market where many incumbents quote on request; early-customer rates start at Rp 4,900 per active employee per month for attendance, with a Rp 200,000 monthly minimum, excluding VAT, and a 14-day trial. Use that as a comparison point, not as a reason to skip the test scenarios.

Ship the policy first

The technology only enforces a written rule: where a person is expected to be, what proof is required, who may override a failed check, and how long biometric data lives. If you cannot explain those four points to a new hire in two minutes, the model is not ready, no matter how accurate the matcher is.

Build the event, the fence, the challenge, and the queue. Leave continuous tracking out unless you have a purpose that can survive a privacy review. Attendance should make honest hours easy to record and dishonest hours harder to fake, without turning the workplace into a surveillance product.

πŸ“° Read the original article on Dev.to WebDev

Originally published by Dev.to WebDev. Aggregated on AIWithGhost for educational purposes β€” full credit and traffic to the original publisher.