
Staff portal
In at 6:30 PM,out at 3:30 AM,one shift.
The private back office of The Best Estimator: one login where fifteen staff run projects, customers and their own attendance.
The team works US hours from Islamabad, so every shift crosses midnight. Most of the engineering went into making time and payroll right.
- Year
- 2026
- Role
- Design, build, deploy
- Stack
- Flask · PostgreSQL · plain JS
- Access
- Internal, staff only

One login, four roles.
Every person is one row in one staff table. Each module adds its own rules on top, and the server checks them on every request, so a hidden button is never the only lock.
- Full
Dashboard
/dashboard - Every project
Projects
/projects - Full
Customers
/customers - Own
My attendance
/attendance - Full + corrections
Attendance review
/attendance/admin - Full
Staff
/staff - Full
Share a project
/projects/<id>/generate-link - No login
Client view
/p/<token>
Admin · every project, every person, every correctionLocked routes answer 403 or 404, not a hidden link
The shift that crosses midnight.
- A normal night
In at 6:30 PM, out at 3:30 AM.
The office keeps US working hours. Every shift starts on one date and ends on the next, so it is the normal case, not an edge case.
- The bug
Midnight changed the date.
Check-out looked for today's row. After midnight, today was the 25th; the shift was saved on the 24th. Nobody could check out, and the shift stayed open forever.
- The fix
Ask for the open shift, not the date.
Check-out now closes whichever shift is still open, whatever the calendar says. The database backs it up: one person can never have two open shifts.
CREATE UNIQUE INDEX uq_one_open_shift ON attendance (staff_user_id) WHERE check_out_at IS NULL AND NOT missed_checkout;
- Windows
Buttons that only work on time.
Check-in opens at your own shift start for seven hours; check-out takes over the same minute, so a slip of the thumb can't end a shift early. 1:30 AM on a Saturday is still Friday's shift.
- Forgot to check out
Nobody guesses the hours.
When the window closes, the shift is flagged, counts as zero hours and shows up for an admin. No check-out time is ever invented, and it never blocks the next night.


Every correction leaves a trail.
Attendance feeds salaries, so only an admin can change a past entry, a reason is required, and the old value is kept. The employee sees the note on their own history.
- check_out_at
none→ 3:31 AM“Forgot to check out, confirmed on call”AdminSep 25 · 10:12 AM - check_in_at
7:58 PM→ 6:31 PM“Power cut at home, checked in late”AdminSep 26 · 9:40 AM - created
absent→ 6:30 PM – 3:30 AM“On a site visit, logged by phone”AdminOct 02 · 11:05 AM - left_early
yes→ noCleared when check-out moved to shift endSystemOct 06 · 4:18 AM
Every bug, written down.
- #21 · Time zones
The server lived in UTC.
Near midnight in Islamabad, a check-in could land on the wrong day. Times are stored in UTC and shown in the company's own zone.
- #30 · Dates
A 12:30 AM check-in was saved on the wrong day.
It now takes the date the shift started, and a dry-run command repairs the rows the old bug had already mis-dated.
- #32 · Privacy
Estimators could find client names through search.
Their search now only matches project names and addresses.
- #33 · Access
A deactivated person kept their session.
Access now ends on their very next click.
- #34 · Payroll
The month counted future days as absent.
Days not yet worked are “Upcoming”, and a shift still running after midnight isn't judged until it ends.
Built with Flask and PostgreSQL, hand-written CSS and plain JavaScript, no build step. Rate-limited login, CSRF on every form, hashed passwords, deployed on Railway.


