One IoT backend for the device, dashboard and mobile app
How we structure one IoT backend in Nest.js so the firmware, dashboard and mobile app teams share a contract and stop blocking each other.

Most connected products end up with three clients talking to the cloud: the device, a web dashboard and a mobile app. If each one grows its own backend, or its own corner of a shared one, the firmware team waits on the app team, the app team waits on hardware, and every payload change turns into a week of messages. A single, well-structured IoT backend fixes most of that, and it does not need a large platform to do it.
This post is for founders and product leads planning the software side of a device, and for engineers who have already felt the friction. It describes how we structure a Nest.js API so that firmware, web and mobile work can move in parallel.
Why three clients drift into three backends
The drift is rarely a decision. Firmware needs somewhere to send readings early, so someone stands up a quick endpoint. The dashboard arrives later and adds its own tables. The mobile app needs pairing and push notifications, so it gets a third service or a separate set of routes with slightly different names for the same things.
A few months in, “device”, “unit” and “node” mean the same object in three places, and nobody is sure which field is authoritative. The cost shows up as coordination: every change needs three people in the same conversation.
The underlying problem is that the three clients have very different constraints, and nobody wrote them down:
- The device is constrained, often intermittently connected, and slow to update. Firmware in the field may stay on an old version for months.
- The dashboard wants rich queries over history, many devices at once and role-based access for operators.
- The mobile app wants a small, fast view of one user’s devices, pairing flows and notifications, and it also ships on a release cycle you do not fully control because of store review.
Draw the boundaries in the IoT backend first
We start with one Nest.js application split into modules by domain, not by client. Typical modules are devices (identity, provisioning, ownership), telemetry (ingest and query of readings), commands (configuration and actions sent to devices), users and notifications. Each module owns its tables and exposes services that other modules call; nothing reaches into another module’s tables directly.
The clients then sit on top as thin adapters. Device-facing routes or message handlers, dashboard controllers and mobile controllers all call the same domain services. If the mobile app needs a slimmer response, that shape lives in its controller, not in a duplicate copy of the business logic.
This keeps one source of truth per concept. When a device is reassigned to a new owner, it happens in one place, and the dashboard, the app and the device all see the same result.
Contract first: one schema the firmware and the app both trust
The single most useful habit is to agree the contract before anyone writes a handler. For HTTP endpoints we keep an OpenAPI document generated from Nest.js DTOs, and the web and mobile clients generate their types from it. For device messages we keep versioned JSON Schema definitions (or Protocol Buffers when payload size matters) in the same repository.
That gives each team something concrete to build against:
- The firmware engineer knows exactly which fields the backend expects, their units and their limits.
- The app engineers get typed clients and compile-time errors when a field changes.
- Code review on a schema change pulls in all three disciplines automatically, because the file is shared.
Be explicit about units and time. We write units into field names (temp_c, battery_mv) and insist on UTC timestamps, with the device time and the server receive time stored separately. Device clocks drift and occasionally reset, and you will want both values when debugging.
Separate device ingestion from the request API
Device traffic and human traffic behave differently. A few hundred devices reporting every minute is steady, small and bursty after an outage, when everything reconnects at once. Dashboard and app traffic is spiky around office hours and expects low latency.
So we keep ingestion on its own path. Devices usually connect over MQTT to a managed broker (AWS IoT Core is a common choice and supports per-device X.509 certificates), or post to a small HTTPS endpoint when the radio and power budget make MQTT awkward. Messages land in a queue and a worker in the telemetry module validates them against the schema, then writes to Postgres. For time-series data, a Postgres extension such as TimescaleDB or careful partitioning by time usually covers small and mid-sized fleets without introducing another database.
The request API reads from the same store, but a burst of reconnecting devices never sits in front of a user waiting for a page to load. It is also the cleanest place to apply rate limits and reject malformed payloads without affecting anything else.
| Path | Typical transport | Main concern |
|---|---|---|
| Device ingestion | MQTT or HTTPS, via a queue | Throughput, validation, reconnect bursts |
| Dashboard API | HTTPS (REST), WebSocket for live views | Query performance, roles and permissions |
| Mobile API | HTTPS (REST), push notifications | Small payloads, pairing, offline tolerance |
Simulators so nobody waits for hardware
Hardware is almost always the last thing to be ready. Boards come back from assembly with a rework or two, and the first firmware is busy with drivers and power, not cloud features. If the app team waits for real devices, they lose weeks.
We write a small device simulator early: a script that authenticates like a device, publishes messages that match the schema and responds to commands. It can run one device or a few hundred, and it can be told to misbehave, sending late, duplicated or out-of-order readings, dropping off for an hour, or reporting a low battery. The dashboard and app are built against it, and we keep using it later for load tests and for reproducing field problems.
It works in the other direction too. The firmware engineer can point a development board at a local backend in a container and see their messages accepted or rejected with a clear validation error, rather than guessing why nothing appears on a screen.
Versioning for devices you cannot force to update
Apps can be nudged to upgrade. Devices often cannot, at least not quickly: an OTA rollout is usually staged, some units are offline, and a few may never update at all. The backend has to accept every payload version still in the field.
- Every device message carries a schema version and the firmware version.
- Changes are additive by default: new optional fields, never renamed or repurposed ones.
- When a breaking change is unavoidable, the ingestion worker translates old versions into the current internal shape, so the rest of the backend only sees one model.
- Commands sent to devices are checked against what that firmware version supports before they leave the queue.
Storing the firmware version per device also pays off on the dashboard. Being able to filter a fleet by firmware version is one of the first things operators ask for, which we touched on in the five numbers a fleet dashboard should show first.
What we would do on day one
If you are about to start the software side of a connected product, this is the short list we work through before building features:
- Write down the core domain objects and agree one name for each across firmware, web and mobile.
- Create the shared contract: OpenAPI for HTTP, versioned schemas for device messages, with units and UTC timestamps.
- Set up one Nest.js application with domain modules and thin per-client controllers.
- Separate device ingestion behind a queue from the request API.
- Build a device simulator in the first sprint, before the boards arrive.
- Put schema and firmware version on every device message from the very first prototype.
None of this is expensive, and all of it is far cheaper on day one than after three teams have shipped against three different ideas of what a device is. It is also why we prefer one team to own everything from firmware to cloud; you can see how that fits together on our product engineering services page.