This repository is a small event-driven demo that shows how I think about decoupling, resilience and failure handling in real-world systems.
It implements a minimal booking pipeline:
- A client sends a booking request to an HTTP API.
- The API publishes an event to a NATS subject.
- A worker consumes the event and processes the booking.
- Failed events are sent to a dead-letter subject for inspection.
- A small dashboard subscribes to events and exposes a simple HTTP endpoint.
-
services/api
HTTP API that validates input and publishes booking.requested events. -
services/worker
Background worker that consumes booking.requested and either confirms the booking or sends it to a dead-letter stream. -
services/dashboard
Minimal service that subscribes to booking.* subjects and exposes a simple HTTP endpoint to inspect recent events. -
NATS
Lightweight message broker used as the event backbone.
- Node.js
- TypeScript
- NATS (with JetStream enabled)
- pnpm workspaces
Prerequisites:
- Node.js (>= 20)
- pnpm
- Docker (optional, for local broker via docker-compose)
Install dependencies from the repository root:
pnpm install
This will install all workspaces under services/.
In separate terminals:
API:
pnpm --filter event-demo-api dev
Worker:
pnpm --filter event-demo-worker dev
Dashboard:
pnpm --filter event-demo-dashboard dev
In addition, you need a running NATS broker. The simplest way is:
docker run --rm -p 4222:4222 -p 8222:8222 nats:2.10 -js
From the repository root:
docker-compose up --build
This will start:
- NATS
- API on http://localhost:5000
- Worker
- Dashboard on http://localhost:5100
Send a booking request:
curl -X POST http://localhost:5000/bookings \
-H "Content-Type: application/json" \
-d '{
"customerId": "cust-123",
"productId": "trip-456",
"requestedDate": "2025-01-10T10:00:00Z"
}'
Inspect events via dashboard:
curl http://localhost:5100/events
- To demonstrate how I design event-driven systems.
- To show my approach to failure handling and dead-letter patterns.
- As a small but realistic architecture + code case study for someone.
Strategy to life – Architecture to code.