Arthur Foo

Case study · Attendance & leave

Flutter HRM Daily Tracker

A Flutter app for staff attendance, leave requests and same-day team visibility.

Sole developer 2025 · during a full-stack role Flutter · Laravel 11 · MySQL Local demo & API tests

01 · Summary

One attendance app for three roles

I built the Flutter app and its mobile API in 2025 during a full-stack role. Staff can clock in and out, check attendance and request leave. Managers can see their department’s attendance, and HR admins can review attendance and leave requests across the team.

The API limits each role to the records and actions it is allowed to access.

02 · Problem & constraints

A daily record has to follow the shift

Staff needed to clock in from their phones, review the month and apply for leave. HR needed to see who was in, late or on leave that day.

The app, staff web page and admin dashboard share one database. The server calculates attendance in Malaysia time. Each employee has one record per work date, including overnight shifts that end the following day.

03 · My role

From the Flutter screens to the mobile endpoints

I built the screens, state management, API client and token storage. On the Laravel side, I built the mobile endpoints for sign-in, attendance, calendar, leave, profiles and team views.

04 · Architecture & critical path

How one clock-in becomes a daily record

DR-01 is the 20 November record in the local demo. Flutter sends a clock-in request with a Passport bearer token. Laravel checks the role and applies the attendance rules before writing to MySQL.

DR-01 · Where does a clock-in request go?

Simplified
DR-01 · Where does a clock-in request go? A Flutter request reaches Laravel 11 with a Passport token. An allowed request locks the employee row, checks shift and leave rules, writes the daily record to MySQL and returns the updated day. A manager receives 403 before any write. SEND REQUEST Flutter app Provider · Passport token AUTHORISE & CHECK RULES Laravel 11 API Role · roster · leave · lock STORE THE WORK DATE MySQL attendances · DR-01 REFUSE 403 · Manager role Ends before the transaction Submit clock-in Write daily record Return 403 for manager
Staff clock-in. Laravel locks the employee row in a transaction, resolves the shift, checks approved leave and admin corrections, then writes DR-01 and returns the updated day. 员工打卡。 Laravel 在事务中锁住员工行,核对排班、已批请假和管理员修正,再写入 DR-01 并返回更新后的记录。
Manager refused. The attendance endpoint returns 403 for this role before the transaction opens. 拒绝经理打卡。 考勤接口会在开启事务前拒绝该角色的请求,并返回 403。
  1. The Flutter app sends a request with a Passport token.Flutter 应用携带 Passport 令牌发出请求。
  2. Laravel 11 checks the role. An allowed staff request then locks the employee row and checks shift and leave rules.Laravel 11 先核对角色;允许的员工请求再锁住员工行、检查排班和请假规则。
  3. The daily record is written to MySQL and the updated day is returned.考勤写入 MySQL,并返回更新后的记录。
  4. A manager request receives 403 before any write.经理请求在写入前收到 403。
Fig 04.1 Laravel decides whether DR-01 reaches MySQL, which stores one attendance row per employee and work date.
Work date
An overnight shift keeps both punches on the day the shift started.
Early clock-out
The API requires a reason for an early clock-out and stores it for HR to review.
One row
A unique key on employee and work date backs up the employee row lock.
Clock-in sequence · pseudocode Simplified
if role is Manager: return 403
in a database transaction:
    lock the employee row
    resolve the shift and work date
    check leave and administrator corrections
    write the daily attendance row
return the updated day

05 · Technical choices & trade-offs

Keep attendance rules consistent across clients

  1. Calculate shift rules on the server

    Laravel handles lateness, rest days, leave conflicts and overnight clock-out windows for all clients.

    Trade-off Clocking in requires a connection.

    取舍 打卡需要联网。

  2. Serialize writes for one employee

    A transaction locks the employee row before checking rules and changing attendance.

    Trade-off Simultaneous requests for one employee wait on the database lock.

    取舍 同一员工的同时请求需要等数据库锁。

  3. Enforce team access in the API

    Admins see all staff, managers see their department and staff see their own records.

    Trade-off The app controls which tabs appear, and the API still checks access on each request.

    取舍 应用控制显示哪些标签页,API 仍需逐次检查访问权限。

  4. Discard stale responses after sign-out

    A session counter stops a late response from one account overwriting another account’s screen.

    Trade-off Every new async attendance action needs the same session check.

    取舍 新增考勤异步操作也要检查会话编号。

06 · Interface evidence

Clock-in, leave and team attendance

These phone-width captures show a local Flutter web build connected to Laravel and MySQL, with fictional demo data. The first three follow the same DR-01 record.

Home screen at 08:56 with the Clock In button and recent attendance
Fig 06.1 Demo data Before clock-in, the home screen shows the action available for that work date.
Home screen with the Clock Out button and today’s 08:56 clock-in
Fig 06.2 Demo data After clock-in, today’s row shows an 08:56 start and the next available action is Clock Out.
Today’s attendance row shows 08:56 to 17:20 and is marked Present
Fig 06.3 Demo data After clock-out, the same daily row shows both 08:56 and 17:20.
November calendar with distinct statuses for present, late, absent and on leave
Fig 06.4 Demo data The month view groups daily attendance and leave so staff can review them together.
Annual leave form with start and end dates, a demo reason and optional attachments
Fig 06.5 Demo data The leave form takes a date range, a reason and optional supporting files.
Admin view with attendance totals, status filters and demo staff rows
Fig 06.6 Demo data The admin view shows today’s team totals and lets HR filter staff by status.

07 · Results & verification

What the local checks showed

The local demo verified clock-in, early clock-out with a reason, leave submission and role-based team views. The sample calendar returned 13 working days and a 92.3% attendance rate.

CheckResultSource
Laravel API suite 114 passed · 1,040 assertions Local MySQL with leave types seeded
Flutter account-switch test Passed Local Flutter test run
Default Flutter widget test Failed to compile Template refers to a missing MyApp
Desktop integration test Unrun in this check Login → clock-in → clock-out

08 · Limits & next steps

Local verification and remaining gaps

The app requires a connection for attendance. Leave calculations currently exclude weekends but still count public holidays. In the tested build, two date or time displays on the client were wrong and are not yet fixed; the affected screens are not used here.

The default widget test needs replacing. Production rollout and usage remain unverified.