Cuide-se Mais

Attendance management with a realtime queue at its core

20261 min read

Cuide-se Mais is a health program that runs 24 free events across different regions of Brazil’s Federal District, offering integrative practices like acupuncture, reiki, yoga and nutrition, plus wellness services like haircuts and massages. I built the software the team uses to run each event: checking people in, managing the queue for every service, and calling them in to be seen.

The realtime queue

  • Check-in puts each person in the queue for the services they came for, with priority handling.
  • Staff call the next person from a grid of stations, then start and finish each attendance.
  • Group sessions, for activities like yoga, run alongside one-on-one services.
  • A public board keeps everyone who’s waiting up to date.

Keeping every screen in sync

Each event has its own Durable Object that acts as the realtime authority for its queue. D1 stays the source of truth: the room reads the queue, stamps it with a persisted, ever-increasing revision, and pushes it to every connected screen over WebSockets. Because revisions are assigned in one place, a stale update can never overwrite newer state on a staff screen. The room uses the WebSocket Hibernation API, so it can leave memory while connections stay open.

Screens reconnect with jittered backoff and only fall back to polling when realtime delivery isn’t healthy, and an end-to-end test checks that every client converges on the same queue.

Around the queue

  • Online booking, with WhatsApp confirmations and day-before reminders through Better Zap
  • Staff and invite management
  • A message audit trail for LGPD compliance

It’s a Turborepo monorepo that runs entirely on Cloudflare: a Next.js app deployed with OpenNext, a Hono worker for WhatsApp, and a shared Drizzle schema on D1.

Built with

  • Next.js
  • Cloudflare Workers
  • Durable Objects
  • WebSockets
  • Hono
  • Cloudflare D1
  • Drizzle
  • Better Zap
  • Turborepo
Next projectChooselife