From Excel and localStorage to MySQL: Seven Reworks That Shaped an Esports Venue's Next.js 16 Scheduling and Payroll System
Small-business admin software is a real workload; the hard problems are data ownership, temporal boundaries, and payroll rules, and this build shows how they break a full-stack app. The fixes, especially protecting manual edits from generated writes and making payroll a pure function, transfer directly to any team tool where humans and automation share data.
A Next.js 16 + React 19 + MySQL system replaced Excel scheduling and hand-calculated payroll for a dozen-person esports venue. The first scheduler assigned shifts day by day and produced chaotic early/middle/late rotations, so the final design splits each month into two half-month blocks and gives every employee one fixed shift type per block. New hires and mid-month departures go into a floating pool that only covers absent fixed-role staff, in late > early > middle order, and late-to-day transitions get a bridging rest day in the 14-18 window.
Payroll is the second hard part. Eight components stack together: base, performance, attendance, holiday triple pay, trial-period pay, overnight allowance, recharge commission, overtime, and manual fields. The engine is a pure function that takes employee, month data, settings, and holidays, reads no database, calls no new Date(), and changes no state. That makes rule changes diffable and lets historical months be recomputed as regression checks. Two measurement rules matter: payable attendance excludes trial shifts, and the daily-wage denominator is fixed at days in month minus rest days.
Seven pitfalls cost real rework. DDL ran against a different MySQL instance than the app used; whole-row snapshot writes silently zeroed hand-entered overtime; payroll rules changed five times before settling; React 19 hydration broke on localStorage and new Date(); date-string parsing shifted months in some time zones; the first auto-scheduler overwrote the manager's manual shift edits; and localStorage as the source of truth made data vanish across computers. The fixes: verify schema changes with the app's own connection config, separate engine-derived from manual fields, snapshot and audit every write, gate browser-only rendering behind a hydrated flag, pass YYYY-MM-DD strings and avoid toISOString(), and make auto-generation fill only blank cells. The code is open-sourced under MIT.
A pure-function payroll engine is the load-bearing decision here; after five rule changes in real use, being able to rerun history and diff outputs is what kept the system trustworthy.
The only-fill-blank-cells rule is a general answer to a common failure: when automated logic and human override share the same data, generated writes must treat manual edits as a protected layer, not a conflict to resolve.
Choosing a direct MySQL connection with a thin repository layer over an ORM is a scale-appropriate call for a dozen-person domain, but it only pays off because the model is small enough that SQL stays transparent.
The bugs that cost the most time cluster around data ownership and time boundaries. Framework features are not where the complexity lived.
The build's own conclusion is that small-but-complex business software succeeds or fails on domain rules; once a rule is wrong, clean code does not save it.
That part where auto-scheduling rewrote the entire month made me sweat—the boss thought he'd just misremembered. Brutal lesson.
Good thing I'd snapped a photo back then, otherwise my whole salary wouldn't have been enough to cover it. [crying]