Skip to content

spotlight-core2code/event-driven-core2code-demo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Event-driven core²code demo – Resilient Booking Pipeline

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:

  1. A client sends a booking request to an HTTP API.
  2. The API publishes an event to a NATS subject.
  3. A worker consumes the event and processes the booking.
  4. Failed events are sent to a dead-letter subject for inspection.
  5. A small dashboard subscribes to events and exposes a simple HTTP endpoint.

Architecture Overview

  • 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.

Tech Stack

  • Node.js
  • TypeScript
  • NATS (with JetStream enabled)
  • pnpm workspaces

Getting Started

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/.

Run services locally (without Docker)

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

Run everything via docker-compose

From the repository root:

docker-compose up --build

This will start:

Example Requests

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

When This Repository Is Useful

  • 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.

About

Minimal event-driven booking pipeline demo using Node.js, TypeScript and NATS. Shows decoupling, resilience and dead-letter handling.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors