Implementation

Application Foundation

I implemented the project as a TypeScript workspace with separate `client`, `server`, and `database` areas. The browser application uses Next.js and React. The API uses Express, and PostgreSQL is accessed through Prisma. Docker Compose provides a repeatable local PostgreSQL service.

The development seed creates thirty employees across administrator, manager, registered nurse, and care aide positions. It also creates certifications, day/evening/night shift types, schedule periods, assignments, and attendance records. This makes the main screens and reports usable immediately after setup.

Authentication and Employees

The completed authentication flow uses email and password sign-in, Argon2 password hashes, server-side sessions, HTTP-only cookies, and active-account checks. Routes use authentication and role middleware, so hiding a manager button in the client is never treated as the security control.

Managers can search and filter employees, open employee details, create and update records, and deactivate an employee without deleting history. Certification records include type, credential information, issue and expiry dates, and status. The schedule validator can therefore check whether a certification is valid on the date of a shift.

Scheduling

Managers can create a schedule period and add day, evening, or night shifts. Each shift stores its own time, minimum staffing value, and status. Employees can be assigned from the schedule editor.

The main implementation work was the reusable assignment validator. It checks:

– active employment;
– overlapping assignments;
– ten hours of rest;
– approved time off;
– weekly and temporary availability;
– expected weekly hours; and
– required certification coverage.

Schedule validation also calculates minimum staffing and qualification gaps. Blocking conflicts must be corrected before publication. A general staff shortage can be published only after the manager records an explanation. Publication uses a serializable database transaction so that validation, status changes, audit data, and notifications succeed or fail together.

Requests and Schedule Changes

Employees can save a regular availability pattern, add temporary unavailable periods, and submit future time-off requests. Managers can approve or reject requests and include a response note.

A manager can post a future published shift as open. Employees see whether the scheduling rules make them eligible and can submit a response. Eligibility is checked again when a manager approves the response because the schedule may have changed.

Shift swaps use three stages: the assigned employee creates the request, the proposed employee accepts or declines, and the manager makes the final decision. The published assignment remains unchanged until final approval.

Attendance and Reporting

Employees can clock in from thirty minutes before a shift until its scheduled end and then clock out. Actual times are stored separately from scheduled times. Managers can correct both times by entering a reason. Worked time is rounded to the nearest fifteen minutes and grouped into Monday-based weeks. Hours above forty are reported as overtime.

The manager dashboard shows current staffing, upcoming warnings, pending requests, and expiring certifications. Reports provide date-filtered staffing coverage, qualification results, regular hours, overtime, and totals. The report page also includes a print layout.

Implementation Challenges

The most important challenge was keeping assignment decisions consistent across direct scheduling, open shifts, and swaps. Reusing the same validation service solved this problem. Another challenge was separating warnings from blocking errors so that a manager can acknowledge general understaffing but cannot bypass overlap, rest, leave, or qualification requirements.

The application now supports the complete planned workflow. External email delivery is not enabled; the system creates notification and email-channel records so a future approved provider can process them without being part of the main business transaction.

 

Leave a Reply

Your email address will not be published. Required fields are marked *