Case study · Attendance & leave
Flutter HRM Daily Tracker
A Flutter app for staff attendance, leave requests and same-day team visibility.
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?
- The Flutter app sends a request with a Passport token.Flutter 应用携带 Passport 令牌发出请求。
- Laravel 11 checks the role. An allowed staff request then locks the employee row and checks shift and leave rules.Laravel 11 先核对角色;允许的员工请求再锁住员工行、检查排班和请假规则。
- The daily record is written to MySQL and the updated day is returned.考勤写入 MySQL,并返回更新后的记录。
- A manager request receives 403 before any write.经理请求在写入前收到 403。
- 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.
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
-
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.
取舍 打卡需要联网。
-
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.
取舍 同一员工的同时请求需要等数据库锁。
-
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 仍需逐次检查访问权限。
-
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.
取舍 新增考勤异步操作也要检查会话编号。
One record on the start day. Both punches fall on the day the shift started.开始日的一条记录。 两次打卡都在班次开始当天。 Still one record on the start day. The clock-out lands after midnight, but an overnight shift keeps both punches on the day the shift started.仍是开始日的一条记录。 下班打卡落在次日,但跨夜班的两次打卡都归到班次开始当天。
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.
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.
| Check | Result | Source |
|---|---|---|
| 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.