Case study
Loom
An event-driven ticket marketplace
- Role
- Re-architecture and documentation
- Stack
- TypeScript · Kafka
- Status
- Open source
- Since
- 2026
The problem
Loom is a marketplace where people list event tickets and buy each other’s tickets. Buying one touches four services. Orders creates the order, tickets reserves the ticket, expiration holds it for fifteen minutes, and payments charges the card. Each service owns its own database, so there is no single transaction that can do all of that at once.
The project started from the baseline of a well-known microservices course (Stephen Grider’s ticketing app), and the README says so. That baseline ran on NATS Streaming, which is end-of-life, kept its data in MongoDB, and shared every event’s TypeScript interface through one package. I rebuilt the broker, the persistence, the event contracts, the shared code, the client and the test suite, and wrote down every major decision as an ADR that compares it with the baseline.
Decisions and what they cost
Kafka in KRaft mode instead of NATS Streaming
Kafka’s consumer groups give the same “one replica handles each message” behavior the services relied on, and partitions add parallelism. Ordering in Kafka is per partition, so every event is keyed by the id of the entity it is about. All events for one order land on the same partition and stay in order. KRaft removes ZooKeeper from the setup. The cost is a heavier broker to run locally, and a concept the team has to understand, because ordering is no longer free.
Avro contracts in a schema registry
In the baseline, services shared TypeScript interfaces for their events, which coupled them at build time and checked nothing at runtime. In Loom every event has an Avro schema in a Confluent Schema Registry, producers serialize with it, and consumers read each message with the schema it was written with. Changing an event now means evolving a schema under compatibility rules, which is slower and exactly the point.
Postgres per service, with optimistic concurrency
Each service has its own Postgres database, accessed through Kysely. Rows carry a version number, and an update only succeeds if the version it read is still current. Events carry the version too. A consumer that gets an update out of order doesn’t apply it. It leaves the message unacknowledged and Kafka delivers it again later, after the update it was waiting for. It costs a column and a retry path. It prevents lost updates without locks across services.
A choreographed saga
No service runs the purchase. Each one reacts to events and publishes its own, and the flow comes out of those reactions. If no payment arrives before the order expires, the expiration service publishes an event, orders cancels the order, and tickets releases the ticket. Choreography keeps the services decoupled, and the cost is that the flow is written down nowhere in the code. So the project has a document that draws the whole saga, both the happy path and the compensating one.
An infrastructure-only shared package
The shared npm package holds only infrastructure: error classes, Express middleware and the Kafka base classes. No event types and no business logic. A service that wants to know what an event looks like reads the schema, not another service’s code.
Proof
- A testing pyramid with 78 backend tests, run against real Postgres instead of mocks.
- Six ADRs, each with the context, the options and the consequences.
- Documentation written to teach. There are concept pages on Kafka, Avro and optimistic concurrency, and one page per service with its API, events and data model.
- The whole system runs locally on Kubernetes with one command (
skaffold dev).
What’s next
Production hardening is out of scope on purpose, so there’s no managed Kafka, no secrets manager and no observability stack. Loom is a reference for how the pieces fit, and the ADRs say where a production version would need to go further.