/plushcap/analysis/hasura/a-simple-real-time-event-driven-architecture-with-qr-codes

A Simple, Realtime, Event Driven Architecture with QR Codes

What's this blog post about?

The use of QR codes has become increasingly popular due to their convenience and efficiency. They can be used for various purposes such as access passes, evidence of having the correct paperwork, or shortcuts to apps. QR codes are essentially bits of data that trigger web requests when scanned by a compatible client like modern phones. A simplified event-driven architecture using QR codes involves several actions: creating content accessible behind a QR code, generating a QR code representation with access instructions, exposing the QR code, scanning it, and receiving triggers from this flow. Hasura can be used to store messages, associated QR codes, and act as the destination for scans. Real-time subscriptions can also be added into the mix. An example app displays a user and admin view side-by-side, showing created QR codes, their number of times scanned, and the scannable QR code itself. This pattern could work for promotional purposes, check-in purposes, or authentication. To build such an app, we need to assemble services like a handler to create the QR code, a handler to read and process the QR code, a service to persist content, and a service to show the QR code. Pipedream can be used for creating actions, while Hasura provides flexibility in handling QR code scans. The QR creation code process involves generating a QR code using NodeJs and writing data back into Hasura. Using Hasura subscriptions, we can listen for the write-back and show this as a real-time response to the person generating the code. The QR code processing service handler follows a similar pattern, with triggers from HTTP requests and REST requests to Hasura REST endpoints. To connect event triggers, proper coordination in Hasura is required using both event triggers and REST handlers. We can now invoke the API using our standard GraphQL API with these services in place and our event orchestration defined. Using two services and Hasura, we can replicate any number of custom behaviors driven by QR code interaction. This simplified process allows us to focus on our domain and not on writing queue management, resolvers, or other non-value-adding code.

Company
Hasura

Date published
Feb. 11, 2022

Author(s)
Jesse Martin

Word count
855

Hacker News points
None found.

Language
English


By Matt Makai. 2021-2024.