OmniGuard: one control room, a database per firm
A multi-tenant operating system for private security firms: control room, incidents, SOS, patrol rounds, rosters and invoicing.
- Role
- Full-stack engineer
- Timeline
- Sept 2026 to now
- Status
- In development
- Stack
- NestJS, Postgres, PostGIS, Redis, BullMQ, SSE, Next.js
- Problem
- A security firm's in-house tool had to become a product many firms can lease, with strict isolation and no lost alerts.
- What I did
- Built the API and the control room with a lead engineer, a mobile developer and a designer: a database per firm, an outbox so alerts survive crashes, SSE realtime with replay, and privacy that survives restores.
- Result
- Heading to launch with 340 endpoints, about 9,000 tests and 19 decision records behind it.
The system
The product began as a tool for a single security firm and had to become something many firms could lease. That meant strict isolation between firms, European privacy law, and life-safety workflows where a lost event is not acceptable.
Full-stack engineer on the API and the control room console, in a team with a lead engineer, a mobile developer and a designer. 294 commits across both apps in about six weeks, backed by 19 architecture decision records.
- endpoints
- 340
- entities
- 69
- ADRs
- 19
Every firm gets its own database. Hover or tap a node to follow an incident.
Isolation you can point at
tenant.interceptor.ts (simplified)
const firm = resolveFirm(request.user); // from the tokenconst db = await pool.acquire(firm.id); // lazy, evicted when idlereturn cls.run({ firm, db }, () => db.transaction(() => next.handle()));
A request arrives with a firm A token.
Row-level tenancy works until one missed filter leaks a guard roster to a competitor. Here every firm gets its own Postgres database. Connections are resolved per request from an async context rather than request-scoped providers, kept in a lazy pool map with idle eviction, and wrapped in a transaction by a single interceptor.
Provisioning a firm is an idempotent five step process that verifies PostGIS before the firm goes live, and migrations fan out across every tenant database before each deploy, under an advisory lock.
Events that survive a crash
incidents.service.ts + outbox relay (simplified)
await db.transaction(async (tx) => { await tx.save(incident); await tx.insert(Outbox, { id, type: "sos.raised", payload });});// relay, after restart too:await queue.add(row.type, row.payload, { jobId: row.id });
A guard presses SOS.
An SOS cannot be written to the database and then lost because the process died before the job was queued. Domain events are inserted into an outbox in the same transaction as the change, and a relay moves them to Postgres-backed BullMQ using the outbox row id as the job id, so a replayed relay cannot create duplicates.
Realtime without holding connections
stream.controller.ts (simplified)
// GET /v1/stream Last-Event-ID: 42const missed = await buffer.since(firmId, lastEventId);missed.forEach(send); // replay what was missedsubscribe(firmId, send); // then go livereturn; // no database connection held
The control room opens a stream. The handler registers it and returns.
The control room listens over Server-Sent Events. The handler registers the stream and returns, so no database connection is held while a dispatcher keeps a tab open all night. Reconnects replay missed events from Last-Event-ID, and revoking a token or reaching expiry ends the stream. An integration test asserts the connection is released.
Privacy as engineering, not paperwork
A person asks to be forgotten. They are erased, and the erasure is logged.
The audit log is insert only. Erasures are written to a ledger in the tenant database and copied to the platform database, so restoring a backup replays the erasures instead of resurrecting deleted people. AI assist sends roles instead of names, never logs prompts or responses, pins model versions and treats output as untrusted text.
Decisions worth defending
Database per firm over row-level tenancy
Isolation becomes structural, backups and erasure become per firm, and noisy neighbors stay in their own database.
SSE over WebSockets
Traffic is overwhelmingly server to client, SSE replays cleanly, and it rides plain HTTP through every proxy.
Decision records with revisit thresholds
Each ADR names the load at which it should be reconsidered, sized against a capacity model of 60 firms and 9k users.




