Cardano Alerts watches the chain for addresses, stake keys, native-asset policy IDs and script hashes, and tells you when something happens to them. This post is the engineer's view: which parts the service is made of, how an event travels from a new block to your application, and why we built it this way. If you want to connect right away, Connecting to Cardano Alerts has the code; if you want the security argument in full, read How Cardano Alerts keeps each customer's data separate.

The central decision: one scan, separate storage

The obvious design gives every customer their own watcher process. It is simple to explain, but with a hundred customers it means a hundred processes running overlapping queries against the same chain tables, and the cost grows with every sign-up.

We went the other way. Each network is scanned once, every 30 seconds, and that one scan checks every customer's watch list. Isolation is enforced where the data lands: every match is written into a table that belongs to its owner, and from that point on nothing is shared. Each customer gets their own table, their own topics and their own credentials, but not their own process.

One consequence is that the scan interval is the same on every plan. Plans differ in how many criteria you can watch, which channels you get, how long events are kept and how fast you may call the API, not in how quickly a block is checked.

account_reconcilerCronJob, every 15 minCRM → active subscriptionsCONTROL PLANE · POSTGRESQLsubscriptionstoken → customeraccount_statuspush_channelswritesWatch-list API + UIwatch-list self-service on blockchain-applied.commember login → customer_idRust API · Svelte web componenttoken page links each token to itadd / pause / edit own rowstoken row at issuancePIPELINE HOSTS · PER NETWORKdb-syncchain data, one per pipelinealerts_<network>own physical DB per networkagent_state.watermarkcust_A….eventscust_B….eventscust_….events2 × mainnet · 1 × preprodINTERNAL KUBERNETES CLUSTERscan_agentper pipeline, every 30 smatches subscriptionspush_workerper pipeline, one leader per networkchannel per customer: MQTT | Kafkawebhook: plannedactive subscriptions(own network, account active)channel typenew blocksINSERTpoll · markdeliveredSELECT own schema onlyPUBLIC KUBERNETES CLUSTERmqtt_brokerMosquitto 2.1 + C auth pluginmqtt.blockchain-applied.com:8883kafka_brokerApache Kafka 4.3 · 2 brokers + 1 ctrl · RF 2kafka.blockchain-applied.com:9093pull_apiREST · bearer token · rate-limitedGET /events?since_id=…WebSocket or SSE · webhookplanned, not offered yetTraefik · SNI routing · TLS passthroughpublishproducetoken → customer_idCustomer AMQTTbca/A/eventsKafkabca.A.eventsPulltoken A → cust_Aown token · own SCRAM userCustomer BMQTTbca/B/eventsKafkabca.B.eventsPulltoken B → cust_Bown token · own SCRAM userTLSTLSSame brokers, never the sameschema, topic or credential.
The whole system. Two example customers, A and B, share the scan, the brokers and the API, but never a table, a topic or a credential. Arrows show the direction data moves; dashed boxes are channels that are planned.

An event goes through six steps:

  1. Subscribe. You add criteria on the website. The watch-list API takes your customer_id from your login, never from the request.
  2. Match. Every 30 seconds the scan agent reads new blocks from its own Cardano db-sync database and checks them against the active watch lists for its network.
  3. Store. A match is written into your event table once the block has your chosen number of confirmations.
  4. Push. The delivery worker picks up new events and publishes them to your MQTT or Kafka topic.
  5. Pull. The REST API serves the same table, page by page, at any time.
  6. Heartbeat. Every 10 minutes each push channel also gets a heartbeat with the last event id, so silence can be told apart from a broken link.

The parts

Watch-list API and UI

Customers manage their criteria themselves on blockchain-applied.com. The page embeds a small Svelte web component that talks to a Rust API. The API identifies you through your website login, maps it to your customer_id in our CRM, and filters every read and write by that id: asking for someone else's criterion returns 404. Criteria are paused, never deleted, and plan limits are checked inside a per-customer lock, so two browser tabs can't race past them.

Scan agent

The scan agent is written in Rust and reads a Cardano db-sync database. Mainnet runs on two independent pipelines, each with its own db-sync, scan agent and event store; preprod has its own pipeline. Event ids are computed from the event itself rather than handed out by a counter, so both mainnet pipelines produce identical rows and either one can serve you. The agent recognises funds received and spent on payment addresses, funds received on stake addresses, mints and burns under a policy ID, and script invocations including redeemer and datum. It only uses a block once it is buried deep enough for your min_confirmations.

Event store

Every customer has their own PostgreSQL schema with one events table, in a separate database per network. Each internal service gets only the permissions it needs: the scan agent may insert, the REST API may read and note when an event was first fetched, and the delivery worker may read and update two delivery-bookkeeping columns, nothing else. Customers never receive database credentials. Retention follows your plan: 30, 90 or 365 days.

Delivery worker

The delivery worker is also Rust and runs once per pipeline. Since both mainnet pipelines hold the same events, the workers of a network compete for a Kubernetes Lease, and only the holder delivers. Each cycle it takes up to 200 undelivered events per customer, locks them so a second worker can't grab the same rows, publishes them, and marks them delivered only after the broker has acknowledged: QoS 1 on MQTT, acks=all on Kafka. A failed event is retried up to five times; after that it stays in your table for the REST API. Which channel you use is a per-customer setting.

REST API

The pull endpoint, GET /events?since_id=, is part of the same Rust API platform as our other BCA APIs and shares its token handling, cache and rate limiting. The token's hash tells the API who you are and which plan you're on; the request has no parameter that could name another customer's table.

MQTT broker

MQTT runs on Mosquitto 2.1, built from source with an authentication plugin we wrote for it. We started the plugin in Rust, but the binding generator couldn't handle current Mosquitto headers, so it is a small C module that implements two checks. On connect it verifies that your access token, which you send as the MQTT username, is valid. On every subscribe it looks up which customer the token belongs to and allows only topics under bca/<customer_id>/, read only. If the lookup fails, the answer is no.

Kafka

Kafka runs on Apache Kafka 4.3 in KRaft mode: two brokers and a third controller, one on each of three nodes, with every topic replicated to both brokers. Each Kafka customer has one topic with one partition, so events stay in order, retained for 7 or 30 days. Clients log in with SCRAM-SHA-512, and each customer's user may read its own topic and use consumer groups that start with its customer_id, nothing more. Until November 2026 this layer ran on Redpanda; we moved to Apache Kafka to stay on an open-source licence, and because clients only speak the Kafka protocol, nothing changed for them.

Ingress and the control plane

All public connections enter through Traefik. For MQTT and Kafka it routes by host name without decrypting, so TLS ends inside the broker that makes the access decision; certificates come from Let's Encrypt. The watch lists, the mapping from tokens to customers, account status and channel settings live in a highly available PostgreSQL cluster. Every 15 minutes an account job copies the list of active subscriptions from our CRM, and a customer without an active subscription simply isn't scanned.

How a client connects

MQTT and the REST API share one credential, your access token. The broker checks it once when you connect, and checks which topics you may read every time you subscribe:

ONE PROCESS: MOSQUITTO + AUTH PLUGINpush_workerinternal clusterCustomer clientmosquitto_sub, paho…Traefikmqtts entrypoint :8883Mosquitto 2.1.2mqtt.blockchain-applied.comauth plugin (C)in-process, v4 auth APIRedis (Sentinel)token cachebca_api Postgrestoken → customer_id1 · TLSTLS ClientHello (SNI)SNI route, bytes passed throughLet's Encrypt cert · TLS terminates in Mosquitto2 · CONNECT = WHO ARE YOUCONNECT username = bca_… token, password unusedunpwd_check()sha256(token)is this token hash valid? (cache)key present?CONNACK accepted · miss or Redis error → refused3 · SUBSCRIBE = WHAT MAY YOU READSUBSCRIBE bca/<cid>/eventsacl_check()SELECT customer_id … WHERE api_key_hash = $1customer_idallow only if topic = bca/<cid>or starts with bca/<cid>/,and access is read / subscribeSUBACK grantedother customer’s topic, bca/#, +/…, any PUBLISH → denied4 · DELIVERYCONNECT as delivery service · PUBLISH bca/<cid>/events, QoS 1delivery service may publishevent / heartbeat JSON, with network field
An MQTT session, from TLS handshake to the first event. The token check on connect uses a cache; the topic check asks the database on every subscribe.

Kafka has its own login, because Kafka clients authenticate with SCRAM rather than a bearer token. We create the topic, the user and two read permissions when you choose Kafka; after that the broker enforces everything on its own:

push_workerinternal clusterCustomer consumerkcat, librdkafka, JavaTraefikkafkassl entrypoint :9093Kafka 4.3 (2 + 1)kafka, kafka-0/1 :9093BCA setuponce per customer0 · PROVISIONING, ONCE PER CUSTOMERtopic bca.<cid>.events · 1 partition · RF 2 · 7 d / 30 d · ≤ 1 GiBSCRAM-SHA-512 user cust_<cid>_kafkaACLs: READ this topic (literal) · READ groups bca.<cid>.*username + password, handed over out of band1 · TLS + SASL = WHO ARE YOUTLS ClientHello (SNI)SNI route, bytes passed throughLet's Encrypt cert (kafka, kafka-0/1) · TLS terminates in KafkaSASL SCRAM-SHA-512 · cust_<cid>_kafkaprincipal User:cust_<cid>_kafka · bad password → connection closed2 · METADATAMetadata(bca.<cid>.events)leader is kafka-N.blockchain-applied.com:9093 → reconnect, TLS + SASL again3 · CONSUME = WHAT MAY YOU READJoinGroup bca.<cid>.readerACL: group id starts with bca.<cid>. ?Fetch bca.<cid>.eventsACL: READ on exactly this topic?records, offsets kept in the consumer groupother topic → TOPIC_AUTHORIZATION_FAILED · Produce → denied4 · DELIVERYProduce bca.<cid>.events, acks = alldelivery service user: write-onlyin-sync replicas on both brokersack → only now delivered_at is set
A Kafka consumer: one-time setup, login, the redirect to the partition leader, and consumption. Anything outside your topic and your consumer groups is refused by the broker itself.

Ready-to-run commands and client code for all three channels are in Connecting to Cardano Alerts, and our open-source bca-alert-client follows an MQTT or Kafka stream from a single docker run.

Built to keep going

Alerts are only useful if they keep arriving. These are the choices that keep them flowing:

  • Two mainnet pipelines. Either one can scan and deliver; the other takes over the lease when the leader stops renewing it.
  • Deterministic event ids. Both pipelines write the same rows, so a takeover doesn't renumber anything.
  • At-least-once delivery. An event is marked delivered only after the broker acknowledges it. A takeover can resend recent events, which is why consumers de-duplicate on id.
  • Pull as the safety net. Whatever happens to a push, the event stays in your table, and since_id lets you resume exactly where you stopped.
  • Heartbeats. Every 10 minutes, on every push channel, so monitoring can alert on silence.
  • Fail closed. If an identity check can't complete, access is refused rather than granted.

We also check the delivery pipeline with a formal model in TLA+. It found the conditions under which a lease takeover could deliver twice, and it checks that no event can reach another customer's reader. The details are in the isolation post.

The stack at a glance

PartBuilt with
Scan agent, delivery worker, REST API, watch-list APIRust
Watch-list UISvelte web component on the Ghost site
Chain dataCardano db-sync on PostgreSQL
Event store and control planePostgreSQL, highly available cluster for the control plane
MQTTMosquitto 2.1 with our own C authentication plugin
KafkaApache Kafka 4.3, KRaft, SCRAM-SHA-512
Token cacheRedis
Runtime and ingressKubernetes (k3s), Traefik, Let's Encrypt via cert-manager

What's next

  • planned Webhooks, signed with a per-customer secret.
  • planned WebSocket or Server-Sent Events, for dashboards and browser apps.
  • planned The preview testnet, next to mainnet and preprod.
  • planned A clustered MQTT broker, so MQTT can spread across nodes the way Kafka already does.
  • planned Enterprise options: several push channels at once and dedicated endpoints.