In March 2023, two of us started CtrlHQ from an empty repository. I was the lead engineer, owning the architecture, backend and infrastructure, and I worked with one front-end engineer. Thirteen months later, it was a multi-tenant SaaS platform that enterprise customers used to configure, monitor and remotely deploy the control systems in their meeting rooms and buildings.
Enterprise B2B changes what "minimum" means in an MVP. The buyer has an IT department, a security review, staff who each need different access, and hardware behind a firewall nobody is going to open for a startup. You can't skip tenancy, permissions, audit logs or a safe way to reach on-site equipment. They're the price of entry.
With two engineers, we couldn't build all of that the brute-force way. Every architecture call had to do the work of an extra person: remove a whole category of future work, or let one engineer safely do what would usually take a team. For each one, I'll cover the problem, what we chose, and why it was right for the product.
Boring Tools, Same Shape Everywhere
I chose a deliberately conventional stack:
- Node with Fastify on the backend.
- Prisma over MySQL for data.
- Vue 3 and Vite on the front end.
- Redis for real-time messaging.
- One monorepo, run locally with Docker Compose.
None of it was exciting. All of it was mature, well documented and fast to work in, so our time went into the product and not the tooling.
The real leverage was structure. Every backend module, from buildings to touchpanels to deploys, has the same shape: routes, controllers and services, with data access through one shared repository base class. Fastify's autoloading registers a module as soon as its folder exists. Adding a domain area is mostly writing business logic, and either of us could open any part of the codebase and know where everything lived.
The Prisma schema is the single source of truth for the data model. It generates the database client and drives migrations, and it's readable enough that the front-end engineer could check a relationship without asking me.
The pipeline followed the same idea. Each app builds only when its own files change, migrations run only when the schema changes, and releases are versioned from merge request labels. We had no ops team, so the pipeline had to be safe by default.
For a team of two, consistency beats cleverness. When every part of the codebase looks the same, two people can move a lot faster than two people should.
The Organization Is the Root
The first model I wrote was the company, not the user. In B2B, your customer is the organization, so I made it the literal root of the schema. Users, regions, buildings, rooms, edge servers, integrations, metrics and audit logs all hang off an organization, and deleting one cascades cleanly through everything it owns.
The organization ID also lives inside every access token. Each request arrives already knowing which tenant it belongs to, and queries are scoped by default, not by remembering to add a filter. Retrofitting tenant isolation onto a product that started single-tenant is one of the most expensive migrations a SaaS company can face. We never had to do it, because there was never a version of CtrlHQ without tenants.
Roles got the same treatment. Early on, we moved them from a hard-coded list to a database table with seed data. Enterprise customers don't have "admin" and "user". They have integrators, facilities staff, IT and help desk, and each one needs a different slice of the product. Because roles are data, a new customer's org chart is configuration, not a code change, and the front end can gate everything down to the help content a person sees.
Auth That Passes a Security Review
Enterprise deals stall in security review, not in demos. So I designed authentication as if the first customer's IT team would read the code, because eventually someone like them would.
- No open sign-up. You register with a token issued to your organization, so nobody can create an account in a tenant they don't belong to.
- Two factors by default. A correct password isn't enough. It triggers a one-time code by email that expires after five minutes, and old codes are cleared on every login.
- Short-lived access, revocable sessions. Access tokens last an hour. Refresh tokens last five days, live in an HTTP-only cookie that JavaScript can't read, and are stored on the server, so an admin can revoke every session for a user at once. Each access token is bound to the refresh token that issued it, so a token from one session can't be used to extend another.
- Auth is its own app. Login and registration are a separate front end from the dashboard, served under their own path. The code that handles credentials is small and isolated, and the dashboard never touches a password.
None of this is unusual on its own. What mattered was building it into the foundation, so security was never a project we had to schedule against features.
Audit Logging Is Infrastructure
Sooner or later, every enterprise customer asks who changed a room's configuration, and when. The usual answer is to add logging to each endpoint as it's written. That works until someone forgets one, and with two people shipping fast, someone eventually would.
So audit logging doesn't live in the endpoints at all. It's a single server hook that runs after every response. Every create, update and delete, on any route, is recorded automatically with:
- The user and the organization.
- The IP address.
- The resource and the action.
- The result status.
Auth routes are excluded on purpose, so credentials never end up in a log.
Full coverage is the default. A new module is audited the moment it ships, with nothing extra to write and nothing to remember, and customers had an audit log page before most of the product existed. When an enterprise asked us to prove who did what, the answer was always yes.
Model the Customer's World, Not Your Screens
CtrlHQ manages physical things. Buildings hold rooms, and rooms hold control processors, touchpanels, devices, ports, sources and destinations. We modeled that world directly, and two choices kept the model holding up as the product grew.
Definitions are separate from instances. A processor definition or device definition describes a kind of hardware: its model, its ports and what it can connect to. A processor or device is one real unit in one real room, owned by one tenant. Definitions are reference data shared across every customer. Supporting a new piece of hardware means adding a row, not shipping code, and every customer's rooms describe the same equipment the same way.
Telemetry speaks the language of control systems. Room control hardware deals in three signal types: analog levels, digital on/off states and serial strings. We store every metric in exactly that shape, one record with an analog, boolean or serial value, tagged by room or device and metric type. Any signal from any device, including hardware we hadn't seen yet, fits the same table without a migration. To the platform, occupancy, power, online status and source selection are all the same kind of data.
We also put business rules where the data lives. For example, a room can be assigned to only one processor slot, and the schema enforces it. A model the customer's own engineers would recognize is one that survives the business changing around it.
Configuration Is Data
In an enterprise product, the workflow that decides whether customers succeed often isn't the dashboard. It's setup. In CtrlHQ, setting up a room means choosing a processor, defining touchpanels, wiring sources and destinations and applying security settings. And it has to be right before people walk in on Monday morning.
We built setup as a guided, multi-step wizard, and every part of it is data, not code:
- Forms come from schemas. The front end renders each step from a schema definition. With one front-end engineer, that was the difference between maintaining one form engine and maintaining a hand-built form for every device type.
- Every configuration is validated against a schema before it's accepted, so bad data stops at the door and never reaches a room.
- Customer-specific fields are flexible attributes. One customer's unusual requirement is a value, not a migration that affects everyone.
- Rooms start as drafts and go live only when the wizard is done, because real setups take days and pass between people.
- Snapshots capture a room's full configuration as a versioned record that can be exported, so there's always a known-good state to go back to.
Every enterprise customer is a little different, and those differences are where B2B products drown in special cases. Schema-driven configuration let one product, and one front-end engineer, serve all of them.
Let the Edge Dial Out
The biggest technical constraint was that the things we managed weren't in our cloud. Room processors sit on customer networks, and no enterprise IT team is going to open an inbound port to let a vendor in. Any design that needed one would have died in the first security review.
So I flipped the connection around. Each customer site runs a small edge server that opens an outbound WebSocket to our cloud. That's the same kind of connection a browser makes, so corporate networks already allow it. Each edge server has its own key and belongs to one organization, and it's authenticated during the handshake, before a socket even exists.
The protocol has one rule that made the whole system resilient: the first message on every connection is the site's full configuration. An edge server that reboots or drops off the network comes back in a known state, with no reconciliation logic. Heartbeats every 30 seconds drive the online status customers see, and live status recovers on its own after a reconnect.
Inside the cloud, Redis sits between the edge and everything else. Live state is published to per-room and per-device channels. A browser subscribes only to what it's showing, and it gets the last known value as soon as it subscribes, so a page never loads blank. Metrics go onto a queue that a worker writes to the database in order, so a burst of activity from one building never slows the connection.
Nothing in the cloud ever connects into a customer's network. The edge server opens the only connection, and Redis keeps live status apart from database writes.
The WebSocket gateway also got its own server and port, outside the API framework. Real-time connections and request/response traffic behave differently. One is long-lived sockets that stay open for days, and the other is short bursts. Running both through one framework meant fighting the reverse proxy and the framework's request lifecycle. A small dedicated socket server let us own the handshake, authentication and heartbeats directly, and route each kind of traffic through the proxy the way it needs.
Remote Deploy as a State Machine
Remote deploy was the feature that tied the platform together: push a new version of a room's control program from the dashboard, with nobody on site. Two decisions shaped it.
Source control is the source of truth for versions. Each control program already lived in its own Git repository, so we didn't build a separate artifact store or version registry. CtrlHQ reads a program's release tags and turns them into its version history: commit, message, date and link. Engineers release the way they already do, by tagging, and the dashboard always matches what's in source control. There's no second system to drift out of sync.
Every deploy is a record, not a request in flight. Choosing a version for a processor slot creates a deploy request in the database with an explicit status: pending, success, error or failed. The cloud sends it to the right edge server, the edge applies it and reports back, and the record moves to its final state. Because the state is durable, a deploy survives a server restart, a dropped connection or a slow site, and the customer can always see where it stands. We later added deploys by type, so configuration and program code ship separately.
A deploy crosses five boundaries: our database, the Git host, a WebSocket, a customer's network and the processor itself. Designing it as a state machine with durable states, and not a chain of calls that all have to succeed in one go, is what made it dependable across every one of them.
Integrations Run Off the Request Path
Enterprises don't adopt tools on their own. They want yours to work with the ones they already pay for, and for our customers that meant Microsoft 365. We picked a first integration that turned CtrlHQ's data into something a facilities director could take into a budget meeting: ending ghost meetings.
Rooms get booked and nobody shows up. With the organization's consent, CtrlHQ reads room calendars through Microsoft Graph and checks each room's occupancy sensor. When a meeting has started and the room is still empty, it can release the booking and email the organizer. Whether that happens automatically is a per-organization setting, because enterprises want that kind of control. Every release is recorded, so customers can see how much room time they got back.
Three decisions kept it solid:
- Integrations are per tenant. The available integrations are modeled separately from each organization's connection and credentials, so one customer turning on Microsoft 365 changes nothing for another.
- Respect the other system's data model. A calendar event has a different ID in each attendee's copy of the same meeting, so we match on the meeting's universal calendar ID and act on each copy correctly.
- Background work runs outside the API. Calendar checks run every two minutes as scheduled jobs in their own process, on worker threads, so a slow third-party API never slows down the dashboard.
This is where the platform's value clicked for buyers. Live room data is interesting. Rooms that free themselves up are a business case.
Decisions That Compound
In thirteen months, two engineers shipped:
- Multi-tenant SaaS with enterprise-grade auth.
- A complete audit trail.
- A hardware-aware data model and schema-driven configuration.
- A cloud-and-edge architecture that passes a firewall review.
- Remote deploys to on-site equipment.
- A Microsoft 365 integration with a result customers could measure.
That didn't happen because we worked twice as hard. It happened because each decision removed a category of future work.
The Principles
- Put tenancy at the root on day one, so you never have to retrofit isolation.
- Make cross-cutting concerns hooks, not habits. Audit logging that runs on every response can't fall behind.
- Model the customer's world. With definitions and signal types, new hardware is data, not code.
- Drive configuration from schemas, so one engineer can support every device and every customer.
- Let the edge dial out. If you never need an inbound port, the firewall conversation is short.
- Give risky operations durable states. The riskiest feature became one of the most visible and dependable.
The job on an enterprise MVP isn't picking the newest tools. It's making the handful of structural calls that let a small team build something an enterprise can trust, and keep building on it long after the MVP.