HR & Attendance Build

4 Stages · Complete · Flask + SQLite + JavaScript

Home › Apps › HR & Attendance
4 stages · ~12–14 hours · Complete

Build an HR & attendance app.
Shell, client, server, advanced.

A complete HR & attendance app in four stages. Start with a static two-view shell — a manager dashboard and an employee clock-in page. Add a live clock, idempotent clock-in/out, derived KPIs, and localStorage. Move to Flask + SQLite with an event-log attendance model and a derived shifts table. Then grow: timesheets with overtime, manual corrections, a roster, manager approval, and reports. The same four-stage arc as the CRM, Inventory, and POS builds — shell, client logic, backend, advanced data layer. Each stage adds exactly one layer and stops.

~12–14 hours Intermediate HTML · CSS · JavaScript · Python · Flask · SQLite 4 stages · complete

What you end up with: a working HR & attendance app — employees, an append-only event log of clock-ins, outs, and breaks, a derived shifts table that pairs events into shifts, and a manager dashboard that shows who's working, who's late, and how many hours have accumulated. A timesheet view with overtime. Manual corrections that never edit history. A roster that compares "should have worked" against "did work." A manager approval workflow that locks a week's timesheet. Runs on your laptop with three commands.

What it is not: authentication, payroll export, timezone/DST handling, hardware integration. Those are separate concept courses, not Stage 05.

The four stages

Each stage added exactly one layer. Stage 04 was the last one.

👥
Stage 01
Interface
Done

The static shell. A two-view app: a manager dashboard with four KPI cards, an employee list with current status, and today's attendance timeline; and an employee clock-in view with a single big button, current time, and today's hours. A tab at the top switches between them. No data, no logic, no timers.

2 hours · HTML · CSS
⚡
Stage 02
Interactions
Done

Make it work. Live clock ticking once per second. Idempotent clock-in (double-click doesn't create two events). Clock-out closes the shift, computes hours worked, adds to today's total. The KPIs recompute from the event list on every change. Everything persists in localStorage. The employee view's button changes state — CLOCK IN, CLOCK OUT, END BREAK.

3–4 hours · JavaScript · DOM · localStorage
🐍
Stage 03
Backend
Done

Give it a server. Flask + SQLite. Three tables — employees, attendance_events (append-only), shifts (derived cache) — with two foreign keys. The core lesson: pairing events into shifts. Clock-in is idempotent (server rejects a second in without an intervening out). Overnight shifts handled. Break pairing handled. RESTRICT on events — an employee with attendance can be archived, not deleted.

3–4 hours · Python · Flask · SQLite · event derivation
📊
Stage 04 · FINAL
Advanced
Done

Make it a real HR system. Timesheets: hours per employee per week, with overtime flagged at 40h. Manual corrections as new manual_in/manual_out events with notes — never edits. A roster table for "should have worked" vs "did work." A manager approval workflow — approve a week, corrections lock. An attendance report with filters. This was the final stage.

3–4 hours · SQL · Flask · reports · workflow

The data model

Four tables, two foreign keys, one event log.

employees
├── id
├── name
├── email UNIQUE
├── role 'employee' | 'manager'
├── hourly_rate
├── hired_at
└── archived_at NULL = active, set = former employee

attendance_events append-only. Never edited.
├── id
├── employee_id FK to employees ON DELETE RESTRICT
├── type 'in' | 'out' | 'break_start' | 'break_end'
│ | 'manual_in' | 'manual_out'
├── occurred_at ISO timestamp (UTC)
├── note reason for manual events
└── created_at when the row was written

shifts derived cache, one row per (employee, date)
├── id
├── employee_id FK to employees ON DELETE RESTRICT
├── date 'YYYY-MM-DD' (start date, even for overnight)
├── clock_in_at
├── clock_out_at nullable while open
├── break_minutes
├── minutes_worked
└── status 'open' | 'closed' | 'approved'

scheduled_shifts the roster plan
├── id
├── employee_id FK to employees ON DELETE RESTRICT
├── date
├── start_at
├── end_at
└── note

Why event log, not mutable shifts

Events are facts. Facts don't get edited. A missed clock-out is fixed by adding a manual_out event with a note, not by updating a row. The audit trail survives. Same principle as POS refunds.

Why shifts exists at all

It's a cache. The derivation is correct but slow to run on every page load. Cache the result, recompute on every event. Same trade-off as products.quantity in Inventory.

Why RESTRICT on events

An employee who has clocked in cannot be deleted. Their attendance is a payroll record. Archive them instead — same pattern as POS products that have been sold.

Why the roster exists

The shifts table says what happened. The scheduled_shifts table says what was planned. Comparing them answers "were they on time?" — a question the worked-only model cannot answer.

What you built, stage by stage

A concrete picture of the app at each point.

After Stage 01
A two-view shell. Manager sees KPIs, a list, and a timeline — all hardcoded. Employee sees a clock card with a big button. Tab toggles between views. Nothing works.
After Stage 02
The shell is alive. Clock in → status flips, KPI updates, timer starts. Clock out → hours computed, added to today. The employee view's button label changes by state. Everything persists in localStorage. Still single-device, still no server.
After Stage 03
The same UI, now talking to Flask. Events persist in SQLite. The shifts table is derived from events server-side. Clock-in is idempotent — the same employee can't have two ins without an out between them. Overnight shifts, break pairing, and edge cases handled.
After Stage 04 — complete
The full app. Timesheet view — a week grid with hours and overtime. Manual corrections as new events, with a note and a timestamp. A roster comparing scheduled vs worked. Manager approval — approve a week, timesheets lock, corrections require a re-open. An attendance report. The build is finished.

Downloads

Working demos and the full backend source. Complete.

What you'll learn

The concepts, grouped by stage.

Stage 01 — Layout

Two independent layouts sharing one design system. The manager dashboard and the employee clock-in view have nothing structurally in common. Same CSS tokens, different grids. The token set is the brand.

Stage 02 — State

One state object. One render(). deriveShift() walks events in order and produces the shift summary. Idempotency by three guards. A live clock that updates two text nodes only. localStorage persistence on every mutation.

Stage 03 — Event log + derivation

Append-only events as source of truth. A derived shifts table as a cached summary. Server-side derivation. Idempotent API (409 on duplicate). Overnight shifts, break pairing, RESTRICT on employee deletion.

Stage 04 — Workflow & reports

Manual corrections as new events, never edits. Overtime in config, not code. Roster as plan, shifts as reality, LEFT JOIN as the comparison. Approval as a state machine with a bulk update. Reports as SQL aggregates.

Related tracks — not part of this build

Where to go after Stage 04.

The HR build is four stages and it's complete. Authentication, deployment, payroll integration, and timezone/DST handling are separate concept courses — they apply to any HR app, not just this one.

Build something new

The four-stage arc is a template. Shell, client logic, backend, advanced data layer works for any app that tracks periodic state about people:

HR & attendance
this build
Fitness tracker
members, workouts, sessions (event log)
Field service
technicians, jobs, time entries (event log)
Project tracker
members, tasks, time logs (event log)

Same four stages. Same event-log discipline. Same derivation pattern. Same approval workflow. The pattern is the reusable thing.

← Back to Apps
HR & Attendance Build · 4 Stages · Complete