Opening case study…
Opening case study…
An internal operations system for a wireline company — incident reporting, crews, equipment, attendance and medical readiness — held together by one permission model and the test suite that guards it.
Covers
Stack
The company ran its operations on paper. Incident and hazard reports on printed forms, field work on a standard operations planning sheet, attendance and equipment utilisation on monthly grids, medical fitness on certificates in a folder.
Each of those has a different audience and a different rule about who may see it. A safety report is not an attendance register is not a medical certificate, and the people allowed near one are frequently not allowed near another. On paper that separation is enforced by which filing cabinet a document sits in.
So the replacement could not be one dashboard over one table. It had to be several workspaces sharing an organization, a permission model and an audit trail, without leaking across the boundaries between them — which is the part that actually determines whether a system like this can be trusted with medical records at all.
The code is sliced by feature rather than by technical layer. Each workspace owns its domain rules, its validation, its permission checks and its components in one place, so a change to how attendance works stays inside attendance instead of rippling through a shared controllers folder.
Underneath, everything leans on one organization module — people, departments, teams — because every other workspace is ultimately about someone or something that belongs to the company. Getting that spine right early is what let the later workspaces be small.
Writes go through a single wrapper that resolves the caller, checks authority, runs the mutation and records the audit event inside one transaction. A state change and the record of that change either both land or neither does. An audit trail that can silently disagree with the data it describes is worse than no audit trail, because it is trusted.
Intake form
Unauthenticated
Staff portal
Signed in
Self-service
Own records only
Route gating
First boundary
Authorization module
Permissions resolved
Feature modules
Sliced by domain
Transactional actions
Write and audit together
PostgreSQL
26 relational tables
Organization module
People, departments, teams
Audit log
Per-record timelines
Private media
Access-checked routes
Nine workspaces are in internal use, each replacing something that used to be printed, photocopied or kept in a spreadsheet on one person's machine.
Two details shaped more of the build than their size suggests. Intake is bilingual, Urdu and English, because the people closest to a hazard are not always the people most comfortable reporting it in English — and a safety system that quietly filters by language is not collecting the reports that matter most.
The second is that spreadsheets had to keep working. Registers import from and export to workbooks, and reports print to a clean A4 page, because the system has to interoperate with the paper process it is replacing rather than demand everyone abandon it on the same day.
Safety & compliance
Operations
Assets
Workforce
Administration
In and out
Every workspace listed here is in internal use. Nothing is named at record, route, client or role level, and no screen is shown.
The attendance and utilisation workspaces are the same shape: one entry per subject per day, folded into a month-wide grid an operations lead can read across in a single pass.
The grid deliberately stops at recording. It says which state an asset or a person was in on each day; it does not compute a utilisation percentage, an efficiency score or a ranking. Those numbers would be easy to add and easy to misread, and nobody has asked for a measure whose definition has not been agreed.
One status entry per subject, per day
Subject × calendar month
A month-wide grid, exportable as a workbook
A register, not a score
The grid records which state something was in on a given day. Turning that into a percentage would mean agreeing what counts as available, what counts as productive and what a good number looks like — decisions that belong to the operations team, not to the schema.
subject × day → stateThere are 33 committed test files, and they sit beside the code they cover rather than in a separate tree — a workspace's domain rules, validation, permissions and workflow tests live in the workspace.
They run on Node's own test runner, so the suite adds no test framework to the dependency list. That was a deliberate constraint on a system one person maintains: every dependency is something that will eventually need upgrading, and a test suite is not worth a second toolchain.
The shapes worth naming are the permission tests on every workspace that has a boundary, the round-trip tests on workbook import and export, and one end-to-end test that walks a record through its whole lifecycle. Coverage is not measured, so no coverage figure appears here.
Known-data KPI test
The chain names the stages one end-to-end test walks, not its assertions, fixtures or data. No coverage percentage is reported here, because none has been measured.
The application sits behind a reverse proxy that terminates TLS, and talks to PostgreSQL through a bounded connection pool. Sessions are database-backed, sign-in is rate-limited and bot-checked, and passwords are stored with a salted key-derivation function rather than a plain hash.
Private media never has a public URL. Field photographs, portraits and medical certificates are held in a private bucket and reached only through in-app routes that re-check the caller's permissions on the way past — a link that leaks is a link that stops working for whoever it leaked to.
Photographs arrive from phones, which means they arrive large and occasionally in formats a browser will not display. They are converted and resized on upload, so the storage cost and the load time are settled once at intake rather than paid on every read.
Client
Reverse proxy
TLS termination
Next.js application
Server Components
Connection pool
Bounded
PostgreSQL
Private object storage
Reached only through the app
The order was driven by which piece of paper was costing the most, not by which module was most interesting to build.
Reporting came first because an incident form that goes missing is the one failure with a genuine safety cost. The organization spine came second, because every workspace after it needed somewhere for a person to belong. The permission model was hardened once there was enough in the system to be worth protecting properly.
Structured incident and hazard reporting, replacing the printed form.
People, departments and teams — something for every later workspace to hang off.
The operations planning sheet digitized, with crews and lifecycle stages.
Equipment, fleet, monthly utilisation and attendance, with workbooks in and out.
Named permissions, baseline profiles and direct grants, resolved server-side.
Domain, validation, permission and workflow tests committed beside the code.
My strongest engineering evidence on this project sits in exactly the places I cannot show: domain rules, permission resolution, transactional behaviour and the relationships between records.
On this page I would rather describe those honestly and abstractly than manufacture a realistic-looking screen full of invented employees. A fake dashboard would show more and prove less, and anyone who has built one of these can tell the difference.
Where the engineering is
What may be published
The previous version of this case study said the repository had no committed tests. That is no longer true — there are 33 files — so the claim has been replaced rather than quietly dropped.
What is genuinely outstanding is narrower and less flattering. Schema reaches the database by push rather than through committed, versioned migrations, which means there is no migration history to review or roll back. The tests run when someone runs them; no continuous integration runs them on a change. Both are known, both are mine, and neither is hard — they are simply not done.
Next proof
The system is deployed internally and in daily use across its nine workspaces, and remains under active development.
The rows below separate what is in place from what is not, on the same terms as the section above: nothing planned is listed as though it were delivered.
Described at concept level only. Permission matrices, role identifiers, route structures and implementation detail are deliberately withheld.
I can show explicit feature boundaries, a permission model of 32 named permissions with baseline profiles and direct grants, server-side authorization carrying its own regression suite, transactional writes paired with per-record audit timelines, private media delivery behind access checks, and 33 committed test files covering domain rules, validation, permissions, workflows and workbook import and export.
This is a live internal system, so no records, routes, screens, client names or role identifiers appear here. I do not claim production scale, quantified business impact, or a security review by anyone other than me. Schema is applied by push rather than by committed migrations, and the tests are not yet run by continuous integration.
The system runs as one Next.js application over PostgreSQL, with private S3-compatible object storage reachable only through in-app routes that re-check permissions per request. Data moves in and out as spreadsheet workbooks, field photographs are normalized on upload, and every write that changes a record's state is transactional and audited.