The problem
HR data is the most sensitive data a company holds. Tenants must never see each other, and leave requests must never overlap.
I built PeopleCore HR as a multi-tenant HR system. It is live, with a public demo linked in the summary above.
The constraint
Many companies share one deployment, so the boundary between them cannot rest on every query remembering a filter. Leave has a second rule that has to hold even when two requests arrive at once.
I chose Supabase on top of Postgres, with Next.js 16. That gave me row-level security and realtime in one platform, and it means I work inside Supabase's rules.
Decisions
Row-level security as the tenant boundary
Tenant isolation is enforced by row-level security in the database. If application code forgets a filter, the policy still applies. In general terms, the cost is that policies are code. Each one needs a test, and each new table needs one.
A GiST exclusion constraint on leave
The overlap rule is a GiST exclusion constraint on leave, so the database refuses an overlapping request whatever the application does. A check in application code can lose a race between two requests. The general trade-off is that a violation arrives as a database error, which has to be turned into a message a person can use.
Realtime
The stack includes Supabase Realtime for live updates. I am keeping this entry short because I will not describe behaviour I have not written down.
Documents behind signed URLs
Documents are served by signed URL, not as open files. A signed link is a temporary grant instead of a permanent address.
An append-only audit log
The audit log is append-only, so history is added to and not edited. The general trade-off is storage, and deciding which events deserve a row.
An owner console
The platform has an owner console for running it. I include it here because it is part of what I built.
Result
PeopleCore HR is live. Leave overlap is blocked by an exclusion constraint. Documents use signed URLs. The audit log is append-only. Tenants are separated by row-level security, and an owner console exists for the platform side.
I have no load figures, user counts or customer numbers to show, so I give none. What I can show is the set of guarantees the database enforces, and each of them is one I can point to in the schema instead of in a promise. That is the standard I held this project to: a rule that matters should be enforced by the database, not by a careful developer.
What I would change
This section is opinion. If I rebuilt it, I would run an automated cross-tenant test on every migration, asserting that one tenant sees zero rows from another. Policies are the control, so the proof should not depend on me remembering.
I would also write the leave-conflict message before the constraint. A database error is written for engineers, and the person reading it is a manager.
I would write down the Realtime and owner console decisions as I made them. Their reasoning is the part a reader cannot recover from the code.
