The Brief
A multi-territory estate where one operations team manages a stately home, a safari park, workshops, and heritage attractions — each with its own statutory regime, its own contractors, its own escalation paths. Compliance Hub solved the core problem. FM Control Hub is the tailored fork: same engine, plus a Contractor Portal so external supply-chain partners (lift engineers, water hygienists, electricians) work inside the audit trail rather than emailing certificates that never get filed.
What's Different From Compliance Hub
1. Contractor Portal — role-gated dashboard showing only inspections and actions assigned to the contractor's company. Company KPIs, work-order queue, document upload with expiry enforcement.
2. Contractor Onboarding — automated invitation flow. Manager adds a contractor; the system provisions the user, scopes them to the assigned site only, sends a magic-link invite. No shared logins, no certificate-by-email.
3. /inspections/new — full Zod-validated server-action form for creating new inspections (Compliance Hub originally relied on SQL seeding for inspection creation).
4. Premium glassmorphism UI overhaul — heavier brand investment than the generic Compliance Hub tier, because the buyer profile is enterprise estate ops, not "FM SaaS at £99/mo".
5. Longleat-class sample data — sites, assets, inspections and findings seeded against a realistic multi-territory estate so the platform sells itself in the demo.
The Contractor Portal
RLS does the heavy lifting. A contractor's site_memberships record gives them role = 'contractor' on exactly one or more sites. Three policy rules cover the whole thing:
· can SELECT only inspections / actions where assigned_to_user_id = auth.uid() OR delegated_to_user_id = auth.uid()
· can UPDATE acceptance_status, accepted_at, declined_at, decline_reason, clock-on/off, completion fields
· can UPLOAD documents to /<org>/<site>/contractor-docs/<own>/ only — storage path RLS enforces it
The portal UI is a thin layer on top — it doesn't add security, just hides what the contractor was never going to be able to see anyway. That's how RLS-first works: the security model is the data model.
Auto-Recurring Inspections
Migration 0008 adds a trigger: when an inspection is signed off (pass / advisory / fail), if its compliance register has a cadence_months value, the system inserts the next occurrence at performed_at + cadence_months, copies the asset and dutyholder references, and stamps the source_inspection_id so the audit chain is preserved. A weekly L8 sentinel-point check spawns 52 occurrences a year automatically — no human ever forgets to schedule the next one.
Combined with the calendar's cadence projections (which forecast up to 24 occurrences forward visually), the FM team sees both what's actually scheduled and what's coming based on the cadence rules.
Deployment Topology
Dual-deploy: production on Vercel at fm-control-hub.jonnyai.co.uk for fast edge routing, mirror on a GCP VM (PM2 + nginx + Let's Encrypt) at fm-control-hub.vercel.app for fallback. DNS in Cloudflare. Vercel env audit runbook + scripts live in ops/vercel-audit/ — runs after any Supabase key rotation. CI is strict: tsc --noEmit, next lint, next build, all hard gates on every push to main.
The Outcome
Live at fm-control-hub.jonnyai.co.uk. Demo: demo@jonnyai.co.uk / FMHub-Demo-2026! All 11 statutory frameworks covered. Contractor portal active. Auto-recurring inspections firing. Realtime widgets debounced and scopable by site. Email out on notifications via Resend. PDF export of inspection records for HSE handover. PWA install. Dark mode. Premium UI tier suitable for enterprise estate ops.
Sold as a tier above Compliance Hub: £299/mo Pro entry, £999/mo + £1,500 setup white-label for estates that need their own brand on their own domain.