Click Below to Get the Code

Browse, clone, and build from real-world templates powered by Harper.
Tutorial
GitHub Logo

Event-Driven Database Architecture with Harper MQTT Topics

Discover how event-driven database architecture unifies storage and real-time messaging. Harper’s MQTT topics make data updates instant and seamless.
Tutorial

Event-Driven Database Architecture with Harper MQTT Topics

Nenne Nwodo
Developer Relations
at Harper
June 17, 2025
Nenne Nwodo
Developer Relations
at Harper
June 17, 2025
Nenne Nwodo
Developer Relations
at Harper
June 17, 2025
June 17, 2025
Discover how event-driven database architecture unifies storage and real-time messaging. Harper’s MQTT topics make data updates instant and seamless.
Nenne Nwodo
Developer Relations

Event-driven database architecture with MQTT topics blurs the traditional lines between persistent storage and real-time messaging. By treating database tables as MQTT topic namespaces, this pattern provides a unified system where data persistence and live updates coexist seamlessly. In this model, developers no longer juggle separate systems or write extra synchronization logic because every change in the database can immediately flow to interested clients, and clients can even publish messages that directly update database records.

What Is MQTT?

MQTT (Message Queuing Telemetry Transport) is a lightweight publish/subscribe protocol designed for resource-constrained devices and high-latency or unreliable networks. Clients connect to an MQTT broker, subscribe to topics of interest, and publish messages tagged with topic names. When a message is published, the broker dispatches it to all clients subscribed to that topic. Its simplicity and efficiency make MQTT a natural fit for event-driven architectures.

The Traditional Divide

In conventional systems, real-time features are built by combining:

  • A database for durable, persistent storage
  • A message broker (e.g., MQTT, Kafka) for live event distribution

This separation leads to challenges:

  • Data Synchronization Complexity: Applications must keep the database and message broker in sync, often with custom polling or change-data-capture logic.
  • Dual State Management: State exists in both the database and messaging layers, forcing developers to write extra code to coordinate updates.
  • Increased Infrastructure: Running and monitoring two systems increases operational overhead and potential failure points.

How It Works

Instead of treating databases and brokers as distinct, event-driven database architecture uses database tables themselves as MQTT topic namespaces. Defining a table in your schema automatically creates a corresponding topic hierarchy:

type UserProfiles    @table @export
type ChatMessages    @table @export
type IoTSensorData   @table @export

These declarations yield topics like:

  • UserProfiles/123
  • ChatMessages/room-456/msg-789
  • IoTSensorData/device-001/temperature

Each topic maps one-to-one with a record or logical path in your schema.

When a client subscribes to an MQTT topic backed by a table, they effectively open a live view on that record.

// Polling approach (traditional):
setInterval(async () => {
  const user = await database.get('UserProfiles', 123);
  updateUI(user);
}, 1000);

// Database-native MQTT:
mqttClient.subscribe('UserProfiles/123');
mqttClient.on('message', (topic, message) => {
  const userData = JSON.parse(message);
  updateUI(userData);
});

In the traditional approach, clients poll at intervals, risking stale data or unnecessary queries. But with the database-native MQTT, clients will receive updates only when the record changes, as though the table itself is a live data stream.

Harper's MQTT topics align directly with database table paths. A topic like my-resource/some-id corresponds exactly to the record in the my-resource table with ID some-id. This creates seamless interoperability between database operations and real-time messaging:

mqttClient.subscribe('my-resource/123');
mqttClient.on('message', (topic, message) => {
  console.log('Record updated:', JSON.parse(message));
});

Conversely, publishing MQTT messages with the retain flag directly updates the database record:

mqttClient.publish('my-resource/123', JSON.stringify({
  name: "Updated Profile",
  status: "active"
}), { retain: true });

A key feature of MQTT is retained messages, which ensures subscribers immediately receive the current state upon subscribing, no extra fetch required.

// Subscribe and get current state instantly
mqttClient.subscribe('UserProfiles/123');
// First message contains current data; later messages are updates.

This atomic combine-of-fetch-and-listen eliminates race conditions and complex caching layers.

Publishing with the MQTT retain flag set to true updates the database record and notifies all subscribers. Without retention, messages are ephemeral and don’t alter the stored state.

  • Retained messages ensure eventual consistency for stateful data (e.g., user profiles, sensor readings).
  • Non-retained messages suit ephemeral events (e.g., chat messages, notifications).

Conclusion

Event-driven database architecture with MQTT topics are a paradigm shift in how we think about real-time applications. By treating database tables as natural message topics, this approach eliminates the artificial separation between data persistence and real-time messaging.

This unified model simplifies application development, reduces infrastructure complexity, and provides natural scalability for real-time features. As applications increasingly require immediate responsiveness to data changes, this architecture pattern offers a compelling foundation for building the next generation of real-time, data-driven applications.

The main thing here is recognizing that databases and message brokers aren't inherently separate concerns, they're different aspects of the same fundamental need to manage and distribute state changes in real-time systems. With this unified view, developers can build more robust, scalable, and maintainable real-time applications.

Event-driven database architecture with MQTT topics blurs the traditional lines between persistent storage and real-time messaging. By treating database tables as MQTT topic namespaces, this pattern provides a unified system where data persistence and live updates coexist seamlessly. In this model, developers no longer juggle separate systems or write extra synchronization logic because every change in the database can immediately flow to interested clients, and clients can even publish messages that directly update database records.

What Is MQTT?

MQTT (Message Queuing Telemetry Transport) is a lightweight publish/subscribe protocol designed for resource-constrained devices and high-latency or unreliable networks. Clients connect to an MQTT broker, subscribe to topics of interest, and publish messages tagged with topic names. When a message is published, the broker dispatches it to all clients subscribed to that topic. Its simplicity and efficiency make MQTT a natural fit for event-driven architectures.

The Traditional Divide

In conventional systems, real-time features are built by combining:

  • A database for durable, persistent storage
  • A message broker (e.g., MQTT, Kafka) for live event distribution

This separation leads to challenges:

  • Data Synchronization Complexity: Applications must keep the database and message broker in sync, often with custom polling or change-data-capture logic.
  • Dual State Management: State exists in both the database and messaging layers, forcing developers to write extra code to coordinate updates.
  • Increased Infrastructure: Running and monitoring two systems increases operational overhead and potential failure points.

How It Works

Instead of treating databases and brokers as distinct, event-driven database architecture uses database tables themselves as MQTT topic namespaces. Defining a table in your schema automatically creates a corresponding topic hierarchy:

type UserProfiles    @table @export
type ChatMessages    @table @export
type IoTSensorData   @table @export

These declarations yield topics like:

  • UserProfiles/123
  • ChatMessages/room-456/msg-789
  • IoTSensorData/device-001/temperature

Each topic maps one-to-one with a record or logical path in your schema.

When a client subscribes to an MQTT topic backed by a table, they effectively open a live view on that record.

// Polling approach (traditional):
setInterval(async () => {
  const user = await database.get('UserProfiles', 123);
  updateUI(user);
}, 1000);

// Database-native MQTT:
mqttClient.subscribe('UserProfiles/123');
mqttClient.on('message', (topic, message) => {
  const userData = JSON.parse(message);
  updateUI(userData);
});

In the traditional approach, clients poll at intervals, risking stale data or unnecessary queries. But with the database-native MQTT, clients will receive updates only when the record changes, as though the table itself is a live data stream.

Harper's MQTT topics align directly with database table paths. A topic like my-resource/some-id corresponds exactly to the record in the my-resource table with ID some-id. This creates seamless interoperability between database operations and real-time messaging:

mqttClient.subscribe('my-resource/123');
mqttClient.on('message', (topic, message) => {
  console.log('Record updated:', JSON.parse(message));
});

Conversely, publishing MQTT messages with the retain flag directly updates the database record:

mqttClient.publish('my-resource/123', JSON.stringify({
  name: "Updated Profile",
  status: "active"
}), { retain: true });

A key feature of MQTT is retained messages, which ensures subscribers immediately receive the current state upon subscribing, no extra fetch required.

// Subscribe and get current state instantly
mqttClient.subscribe('UserProfiles/123');
// First message contains current data; later messages are updates.

This atomic combine-of-fetch-and-listen eliminates race conditions and complex caching layers.

Publishing with the MQTT retain flag set to true updates the database record and notifies all subscribers. Without retention, messages are ephemeral and don’t alter the stored state.

  • Retained messages ensure eventual consistency for stateful data (e.g., user profiles, sensor readings).
  • Non-retained messages suit ephemeral events (e.g., chat messages, notifications).

Conclusion

Event-driven database architecture with MQTT topics are a paradigm shift in how we think about real-time applications. By treating database tables as natural message topics, this approach eliminates the artificial separation between data persistence and real-time messaging.

This unified model simplifies application development, reduces infrastructure complexity, and provides natural scalability for real-time features. As applications increasingly require immediate responsiveness to data changes, this architecture pattern offers a compelling foundation for building the next generation of real-time, data-driven applications.

The main thing here is recognizing that databases and message brokers aren't inherently separate concerns, they're different aspects of the same fundamental need to manage and distribute state changes in real-time systems. With this unified view, developers can build more robust, scalable, and maintainable real-time applications.

Discover how event-driven database architecture unifies storage and real-time messaging. Harper’s MQTT topics make data updates instant and seamless.

Download

White arrow pointing right
Discover how event-driven database architecture unifies storage and real-time messaging. Harper’s MQTT topics make data updates instant and seamless.

Download

White arrow pointing right
Discover how event-driven database architecture unifies storage and real-time messaging. Harper’s MQTT topics make data updates instant and seamless.

Download

White arrow pointing right

Explore Recent Resources

Livestream
GitHub Logo

2 Hour Build - Live Stream for Non-Developers

A non-developer's live stream walkthrough of building Flow State, a Colorado river-flow app for rafters, in two hours using ChatGPT dictation, Claude Code, Claude Design, and Harper. Scaffold with npm create harper@latest and deploy to Harper Fabric. No coding background required.
Livestream
A non-developer's live stream walkthrough of building Flow State, a Colorado river-flow app for rafters, in two hours using ChatGPT dictation, Claude Code, Claude Design, and Harper. Scaffold with npm create harper@latest and deploy to Harper Fabric. No coding background required.
Person with short dark hair and moustache, wearing a colorful plaid shirt, smiling outdoors in a forested mountain landscape.
Aleks Haugom
Senior Manager of GTM
Livestream

2 Hour Build - Live Stream for Non-Developers

A non-developer's live stream walkthrough of building Flow State, a Colorado river-flow app for rafters, in two hours using ChatGPT dictation, Claude Code, Claude Design, and Harper. Scaffold with npm create harper@latest and deploy to Harper Fabric. No coding background required.
Aleks Haugom
May 2026
Livestream

2 Hour Build - Live Stream for Non-Developers

A non-developer's live stream walkthrough of building Flow State, a Colorado river-flow app for rafters, in two hours using ChatGPT dictation, Claude Code, Claude Design, and Harper. Scaffold with npm create harper@latest and deploy to Harper Fabric. No coding background required.
Aleks Haugom
Livestream

2 Hour Build - Live Stream for Non-Developers

A non-developer's live stream walkthrough of building Flow State, a Colorado river-flow app for rafters, in two hours using ChatGPT dictation, Claude Code, Claude Design, and Harper. Scaffold with npm create harper@latest and deploy to Harper Fabric. No coding background required.
Aleks Haugom
Tutorial
GitHub Logo

Production Quality at Vibe Code Velocity: Dispatched Agent Teams with Harper

Harper enables production-grade agentic engineering by collapsing database, cache, runtime, and messaging into one process, reducing agent complexity and review burden. A multi-model dispatch workflow lets specialized agents plan, code, QA, and review in parallel while humans retain control over critical decisions.
Tutorial
Harper enables production-grade agentic engineering by collapsing database, cache, runtime, and messaging into one process, reducing agent complexity and review burden. A multi-model dispatch workflow lets specialized agents plan, code, QA, and review in parallel while humans retain control over critical decisions.
Person with very short hair and a goatee wearing a plaid button‑up shirt over a white undershirt, smiling outdoors with leafy greenery behind.
Jeff Darnton
SVP, Professional Services & Customer Success
Tutorial

Production Quality at Vibe Code Velocity: Dispatched Agent Teams with Harper

Harper enables production-grade agentic engineering by collapsing database, cache, runtime, and messaging into one process, reducing agent complexity and review burden. A multi-model dispatch workflow lets specialized agents plan, code, QA, and review in parallel while humans retain control over critical decisions.
Jeff Darnton
May 2026
Tutorial

Production Quality at Vibe Code Velocity: Dispatched Agent Teams with Harper

Harper enables production-grade agentic engineering by collapsing database, cache, runtime, and messaging into one process, reducing agent complexity and review burden. A multi-model dispatch workflow lets specialized agents plan, code, QA, and review in parallel while humans retain control over critical decisions.
Jeff Darnton
Tutorial

Production Quality at Vibe Code Velocity: Dispatched Agent Teams with Harper

Harper enables production-grade agentic engineering by collapsing database, cache, runtime, and messaging into one process, reducing agent complexity and review burden. A multi-model dispatch workflow lets specialized agents plan, code, QA, and review in parallel while humans retain control over critical decisions.
Jeff Darnton
Tutorial
GitHub Logo

Change Data Capture Into a Runtime: One Pipeline for Pages, Search, and AI Agents

Learn how Harper turns CDC streams into real-time workflows that refresh cached pages, update search indexes, and keep AI agent context current. See why landing changes in an application runtime beats warehouses, queues, and traditional CDNs.
Tutorial
Learn how Harper turns CDC streams into real-time workflows that refresh cached pages, update search indexes, and keep AI agent context current. See why landing changes in an application runtime beats warehouses, queues, and traditional CDNs.
Person with very short hair and a goatee wearing a plaid button‑up shirt over a white undershirt, smiling outdoors with leafy greenery behind.
Jeff Darnton
SVP, Professional Services & Customer Success
Tutorial

Change Data Capture Into a Runtime: One Pipeline for Pages, Search, and AI Agents

Learn how Harper turns CDC streams into real-time workflows that refresh cached pages, update search indexes, and keep AI agent context current. See why landing changes in an application runtime beats warehouses, queues, and traditional CDNs.
Jeff Darnton
May 2026
Tutorial

Change Data Capture Into a Runtime: One Pipeline for Pages, Search, and AI Agents

Learn how Harper turns CDC streams into real-time workflows that refresh cached pages, update search indexes, and keep AI agent context current. See why landing changes in an application runtime beats warehouses, queues, and traditional CDNs.
Jeff Darnton
Tutorial

Change Data Capture Into a Runtime: One Pipeline for Pages, Search, and AI Agents

Learn how Harper turns CDC streams into real-time workflows that refresh cached pages, update search indexes, and keep AI agent context current. See why landing changes in an application runtime beats warehouses, queues, and traditional CDNs.
Jeff Darnton
Tutorial
GitHub Logo

Harper + Vertex AI: The Architecture Every Agent Builder Should Know

Production agents bleed tokens and latency on repeated queries. Pair a managed model layer with a vector-indexed data layer at the edge, and an 80% cache hit rate cuts LLM spend by 80% while delivering sub-100ms responses on semantically similar requests.
Tutorial
Production agents bleed tokens and latency on repeated queries. Pair a managed model layer with a vector-indexed data layer at the edge, and an 80% cache hit rate cuts LLM spend by 80% while delivering sub-100ms responses on semantically similar requests.
Person with styled reddish‑brown hair and a full beard wearing a gray suit with a light blue shirt and dark green tie, posing outdoors with a blurred pathway and greenery behind.
Drew Chambers
CMO
Tutorial

Harper + Vertex AI: The Architecture Every Agent Builder Should Know

Production agents bleed tokens and latency on repeated queries. Pair a managed model layer with a vector-indexed data layer at the edge, and an 80% cache hit rate cuts LLM spend by 80% while delivering sub-100ms responses on semantically similar requests.
Drew Chambers
May 2026
Tutorial

Harper + Vertex AI: The Architecture Every Agent Builder Should Know

Production agents bleed tokens and latency on repeated queries. Pair a managed model layer with a vector-indexed data layer at the edge, and an 80% cache hit rate cuts LLM spend by 80% while delivering sub-100ms responses on semantically similar requests.
Drew Chambers
Tutorial

Harper + Vertex AI: The Architecture Every Agent Builder Should Know

Production agents bleed tokens and latency on repeated queries. Pair a managed model layer with a vector-indexed data layer at the edge, and an 80% cache hit rate cuts LLM spend by 80% while delivering sub-100ms responses on semantically similar requests.
Drew Chambers
Blog
GitHub Logo

Why Harper is the Definitive Platform for Enterprise Citizen Developers

Harper bridges the gap between business agility and IT security. Utilizing a unified runtime, Harper Fabric guarantees data sovereignty across any environment, from public clouds to air-gapped facilities. Empower users with secure, compliant AI application development and robust governance.
Blog
Harper bridges the gap between business agility and IT security. Utilizing a unified runtime, Harper Fabric guarantees data sovereignty across any environment, from public clouds to air-gapped facilities. Empower users with secure, compliant AI application development and robust governance.
A smiling man with a beard and salt-and-pepper hair stands outdoors with arms crossed, wearing a white button-down shirt.
Stephen Goldberg
CEO & Co-Founder
Blog

Why Harper is the Definitive Platform for Enterprise Citizen Developers

Harper bridges the gap between business agility and IT security. Utilizing a unified runtime, Harper Fabric guarantees data sovereignty across any environment, from public clouds to air-gapped facilities. Empower users with secure, compliant AI application development and robust governance.
Stephen Goldberg
May 2026
Blog

Why Harper is the Definitive Platform for Enterprise Citizen Developers

Harper bridges the gap between business agility and IT security. Utilizing a unified runtime, Harper Fabric guarantees data sovereignty across any environment, from public clouds to air-gapped facilities. Empower users with secure, compliant AI application development and robust governance.
Stephen Goldberg
Blog

Why Harper is the Definitive Platform for Enterprise Citizen Developers

Harper bridges the gap between business agility and IT security. Utilizing a unified runtime, Harper Fabric guarantees data sovereignty across any environment, from public clouds to air-gapped facilities. Empower users with secure, compliant AI application development and robust governance.
Stephen Goldberg
Comparison
GitHub Logo

Harper vs. Vercel + Supabase

Harper offers a unified application platform alternative to Vercel + Supabase, combining database, cache, app logic, messaging, vectors, and real-time capabilities in one globally distributed runtime to reduce latency, operational complexity, and total cost of ownership.
Comparison
Harper offers a unified application platform alternative to Vercel + Supabase, combining database, cache, app logic, messaging, vectors, and real-time capabilities in one globally distributed runtime to reduce latency, operational complexity, and total cost of ownership.
Colorful geometric illustration of a dog's head resembling folded paper art in shades of teal and pink.
Harper
Comparison

Harper vs. Vercel + Supabase

Harper offers a unified application platform alternative to Vercel + Supabase, combining database, cache, app logic, messaging, vectors, and real-time capabilities in one globally distributed runtime to reduce latency, operational complexity, and total cost of ownership.
Harper
May 2026
Comparison

Harper vs. Vercel + Supabase

Harper offers a unified application platform alternative to Vercel + Supabase, combining database, cache, app logic, messaging, vectors, and real-time capabilities in one globally distributed runtime to reduce latency, operational complexity, and total cost of ownership.
Harper
Comparison

Harper vs. Vercel + Supabase

Harper offers a unified application platform alternative to Vercel + Supabase, combining database, cache, app logic, messaging, vectors, and real-time capabilities in one globally distributed runtime to reduce latency, operational complexity, and total cost of ownership.
Harper