Skip to main content

From Device to Database, End to End

Putting the patterns together, a full ingestion pipeline has four stages, each one a single LoT entity. This is the canonical recipe for “get data from a real device, normalize it, and store it for analytics.”
Like a kitchen production line. The delivery comes in (sensor), the chef cleans and preps (Action), the dish is plated to the same standard every time (Model), and the waiter takes it to the table (Database).

When to Reach for This

The first time you need persistent, queryable history of your data — usually somewhere between “it works on my laptop” and “we need to show this to the customer.” It’s also the natural foundation for Live KPIs from a Database and any reporting or analytics layer you’ll add later.

The Worked Example

A smart-building HVAC chiller, communicating via Modbus, normalized into a unified schema, and stored in PostgreSQL.

Stage 1 — Industrial Route Ingests from the Device

Pick the route type that matches your protocol: MODBUS for HVAC controllers, OPCUA for PLCs, S7 for Siemens, ALLEN_BRADLEY for Rockwell, BACNET for building automation. Map each register or tag to a UNS topic.

Stage 2 — Action Processes and Normalizes

Type-cast, scale, validate, then call a Model to produce structured output. A wildcard trigger means the same Action handles every chiller in every building.

Stage 3 — Model Standardizes the Schema

One JSON shape for every chiller in every building. Add fields here once, every consumer downstream sees them.

Stage 4 — Database Route Persists

A single insert per published reading. Credentials come from ENV and SECRET so the route is portable between environments.
Four entities, one pipeline. Every chiller in every building flows the same way. Adding a new chiller means adding a Mapping in the gateway route — nothing else changes. Adding a new field to the schema means adding it to ChillerReading and updating the SQL — all the Actions stay untouched. The same four-stage recipe fits any vertical: a solar inverter via Modbus, a traffic light controller via REST, a delivery van via cellular MQTT. Different devices, different protocols, same shape.

Splitting Edge from Cloud with a Bridge

In a typical production setup, the edge broker runs on-site and handles all the high-frequency, device-facing work — every reading, every command, every alarm. The cloud broker sits centrally and only sees what the business needs to see — minute aggregates, alerts, cross-site rollups. An MQTT_BRIDGE route is what selectively forwards data between the two.
Like a local newspaper sending a daily summary to head office. The full story stays in the newsroom; only the headlines and totals make the trip to corporate. Cheaper, safer, faster.

When to Reach for This

This is the right pattern when you have multiple sites, strict bandwidth or cost limits, regulatory or security requirements to keep raw data local, or devices that must keep operating during cloud outages. For a single-site project with a fast and cheap connection, a single broker is simpler.

What’s Where: A Concrete Example

Imagine an edge broker at a solar park with multiple inverters. Each inverter publishes voltage, current, and power readings several times a second. Here’s what each broker actually contains: The cloud sees a clean, aggregated, multi-site view. The edge keeps everything raw, locally and privately.

Step 1: Create the Aggregate at the Edge

An Action on the edge computes a summary every minute, per inverter. This is what gets sent up.
(The cache/ topics get filled by other Actions that consume the raw inverters/ stream — kept internal to the edge using KEEP TOPIC.)

Step 2: Define the Bridge

Three topic mappings. Aggregates and alerts go up; commands come down. Everything else stays local.
The site prefix (lisbon-park) is added on the cloud side, so multiple parks — or buildings, or cities, or fleet regions — can coexist on the same cloud broker without topic collisions.

Complementary Patterns on the Cloud

Once the cloud is receiving aggregates and alerts as MQTT topics, you can compose more patterns on top of it:
  • Cloud database route for central analytics. Add a PostgreSQL or CrateDB route on the cloud broker that subscribes to +/aggregates/# and inserts into a multi-site table. Now you have one historian with data from every site, queryable for trends, capacity planning, and cross-park benchmarks. The exact same EVENT ... QUERY pattern from the Live KPIs from a Database section works here.
  • Cloud dashboards. Coreflux HUB Dashboards on the cloud broker subscribe to +/aggregates/# and +/alerts/# to give corporate or operations teams a unified view of every site.
  • Cross-site KPIs. A scheduled EVENT on the cloud’s database can publish company-wide KPIs (SELECT AVG(...) GROUP BY site_id) as MQTT topics, just like a single-site KPI — but rolled up across the whole portfolio.
  • AI / MCP routes on the cloud. Plug an AGENT route into the cloud broker so an AI assistant can answer questions about the entire fleet without ever needing to touch the edge.
The bridge is the boundary; everything above it is business; everything below it is operations. Each side can evolve independently.

Next Steps

Data Storage Routes

Historians, inserts, and scheduled queries across database types.

Connecting to the outside world

REST, KPIs, and credentials from this guide.
Last modified on May 22, 2026