Work

Personal project · 2026 · in development

Blippy

Community platform with servers, text and voice channels, attachments and screen sharing. I'm the main author; the project has one contributor on the advanced media features.

Role
Main author (architecture and implementation)
Stack
NestJS, PostgreSQL, Redis, Go, NATS JetStream, Protobuf, LiveKit, Vue 3, Electron
  • 3nodes in the NATS JetStream cluster
  • ~94%of commits, as main author

The problem

I wanted to study up close what holds up a real-time chat: delivering the message fast, not losing it when something goes down and not duplicating it when the client retries. Blippy is a Discord-style community platform, with servers, text and voice channels, permissions, attachments and screen sharing.

The hard problems are in the middle of the path. If the API writes the message to the database and dies before telling the broker, nobody gets it. If it publishes before writing, it announces something that doesn't exist. If the client resends a POST that timed out, the message shows up twice.

I designed the contract with large scale in mind, but implemented only what an MVP needs, in verifiable slices.

What I did

Two planes

I split the system into a control plane and a data plane. The NestJS (Fastify) API, with PostgreSQL and Redis, decides and persists. A real-time gateway in Go holds the WebSockets and pushes the events. A clustered NATS JetStream connects the two. If the API goes down, the system degrades. If the gateway goes down, real time stops. A CI check fails if the gateway imports a database driver.

The Go gateway was written with heavy AI assistance. The Protobuf contract, the decisions and the review are mine.

Idempotent sending and outbox

The client generates a nonce and shows the message as pending. The API writes the message, the nonce and the outgoing event (outbox) in the same transaction. Only then does it publish to NATS. If the process dies between the commit and the publish, a reconciler republishes.

blippy · #general
a
ana n-7f3a

call at 9pm?

l
leo n-91bc

deal, I'll open the voice channel

client log

  1. send a message…
Simplified. The nonce is generated on the client; the server keeps recent nonces and answers the retry with the message that already exists.
// Inside the send transaction (pseudocode)
try {
  await tx.query(
    `INSERT INTO message_nonces (channel_id, author_id, nonce, message_id)
     VALUES ($1, $2, $3, $4)`, [canal, autor, nonce, id]);
} catch (err) {
  // Retry of the same send: return the id that already exists
  if (isUniqueViolation(err)) return { duplicate: true, id: await buscarPorNonce(...) };
  throw err;
}
await tx.query('INSERT INTO messages ...');
await tx.query('INSERT INTO outbox ...'); // event in the same transaction

Single contract and IDs

The contract between TypeScript and Go is generated Protobuf, checked in CI. IDs are Snowflake, with the node-id leased in Redis. The message tables are partitioned in Postgres.

Voice, screen and desktop

Voice and screen sharing use LiveKit, a self-hosted SFU. The desktop app is Electron, with a cross-platform release pipeline. The advanced media features, such as noise suppression and multiple live streams, come from a project contributor.

Quality

Gates with semgrep, gitleaks, actions pinned by SHA and mutation testing. The outbox has a fault-injection test: the API "dies" after the commit and the test checks that the reconciler delivers the event.

Decisions and trade-offs

NATS with JetStream instead of Kafka, RabbitMQ or Redis Pub/Sub. Hierarchical subjects with wildcards, such as guild.*.channel.*.msg, match routing by server and channel. Kafka is heavy for topics this granular. Redis Pub/Sub persists nothing. The cost: today the gateway subscribes in plain NATS mode and nobody consumes the persisted stream, which just accumulates messages. It's groundwork for future consumers, and it needs a retention limit.

Transactional outbox instead of publish-and-hope. It guarantees no event is lost. The cost is accepting at-least-once delivery, with possible duplicates. The consumer has to tolerate that.

Partitioned Postgres instead of Scylla. The data model follows Scylla's shape, keyed by channel and time window, but runs on Postgres. It avoids premature operational cost and keeps the migration path open. The cost: the schema is created in code, at boot, without versioned migrations.

Opaque payload in the gateway. The gateway numbers the events without decoding their content. It's cheaper per message, and new events don't require changing the gateway. The cost is losing visibility into the content at that layer.

Outcome

Blippy runs end to end: servers, text and voice channels, attachments, screen sharing and a desktop app. I'm the main author, with about 94% of the commits. Most of the rest comes from one contributor, on the media features.

There was a real incident: LiveKit was advertising the wrong ICE port, and I fixed it.

There are no user numbers, and I won't make them up. The value here is in the design and in the guarantees I was able to test.

What I would do differently

I would use versioned migrations from the start. A schema created at boot doesn't alter anything and can also collide when several replicas start at once.

I would add FOR UPDATE SKIP LOCKED to the outbox reconciler. With more than one API replica, they would all scan the same rows and publish duplicates.

I would handle session resume outside the process memory. Today, after a deploy, the client rebuilds the session from scratch.

I would replace the gateway's single mutex with partitioned maps and set retention for the JetStream stream and for the nonces table.

Maycon Liborio

São José dos Campos, SP, Brazil

© 2026 · Handmade with Nuxt, modern CSS and zero UI libraries. Data generated from my master profile on every build.

esc

Go to

Projects

Posts

Actions

↑↓ navigate↵ open/ or ⌘K toggles