Skip to content
CK/SYSTEMS
Back to Macquarie College
live fullstack

πŸ’» Device Loans

Laptop and device loan management with kiosk, staff, and admin interfaces

Role

Lead Developer

Timeframe

2024 - Present

Stack

Next.js React TypeScript NextAuth Prisma Tailwind CSS

Overview

A three-interface loan management system covering the full device lifecycle β€” from self-service borrowing through staff processing to admin fleet oversight. Each interface is tailored to its audience: a kiosk for borrowers, a queue for ICT staff, and a dashboard for administrators. Authentication is managed via NextAuth with role enforcement from mc-rbac.

Key Features

  • Self-serve kiosk β€” Borrowers use /kiosk to initiate a loan with a confirmation flow, no staff interaction required
  • Staff queue β€” ICT staff manage reservations, handovers, and returns at /staff with a real-time view of pending actions
  • Admin dashboard β€” Administrators manage device pools, view fleet status, and configure loan policies at /admin
  • Real-time staff streaming β€” Server-Sent Events via /api/staff/stream push live updates to the staff queue (new reservations, returns) with keep-alive pings every 15 seconds
  • Smart due-date calculation β€” Domain logic in /src/domain/deviceLoans/dueAt.ts computes return dates based on loan type and school calendar rules

Architecture

Follows domain-driven design with business logic isolated in /src/domain/deviceLoans/ β€” including the loan service, custom error types, and due-date calculation. This keeps framework concerns (Next.js routing, Prisma queries) separate from core business rules.

Testing

  • Vitest unit tests for domain logic
  • Playwright E2E tests for kiosk, staff, and admin flows
  • Stryker mutation testing with 100% score thresholds on critical domain files (dueAt.ts, service.ts)
  • Docker integration tests for full-stack verification

Design Decisions

  • SSE over WebSockets: The staff queue only needs server-to-client updates β€” β€œa new reservation came in,” β€œa device was returned.” There’s no need for bidirectional communication. SSE is simpler: standard HTTP, automatic reconnection on disconnect, no WebSocket server or upgrade handling. Polling would work but adds unnecessary latency and bandwidth waste. SSE hits the sweet spot for a one-way notification stream.
  • 100% Stryker mutation threshold: Due-date calculation involves school calendar rules β€” term dates, weekends, holidays. Getting this wrong has real consequences: a student keeps a loaned laptop over a break, or gets asked to return it during an exam period. It’s the single piece of logic the entire loan workflow depends on. 100% mutation score ensures every conditional branch is genuinely exercised by tests, not just line-covered β€” the kind of logic where a subtle off-by-one silently causes problems for weeks before anyone notices.

Outcomes

  • Streamlined device loan workflow from reservation to return
  • Kiosk mode for self-service borrowing
  • Admin dashboard for fleet oversight

Need a workflow like this shipped properly?

Send the workflow, bottleneck, or delivery problem. I will tell you whether it fits a governed workflow audit, starter build, or implementation sprint.

Request consulting
Newsletter

Short notes on building AI agents in production.

One email when something worth sharing ships. No fluff, no daily cadence, no recycled growth-thread noise.

Primary use: consulting updates, governed AI workflow lessons, and major project writeups.