All Projects
01Event-driven reservation enginePersonal project

Flight Booking Microservices

Event-Driven Saga Transaction Engine

6-service distributed flight booking with database-per-service isolation, Saga compensation, and end-to-end tracing.

View source on GitHub
NestJSTypeScriptPostgreSQLRedisRabbitMQDockerOTel

6 Microservices

Saga Orchestration

Redis Locks

OpenTelemetry

The engineering problem

Core Challenge

Preventing double-booking across distributed services without 2PC deadlock overhead.

Architecture Solution

Redis mutex locking with TTL + Saga orchestrator issuing compensating unlock events on payment failure.

Resilience Guardrail

Idempotency-Key header required; RabbitMQ dead-letter queues for deterministic replay.

Service topology & IPC protocols

API Gateway (Envoy)

Reverse proxy, rate limiting, x-request-id

HTTP / REST

Auth Service

JWT issuance, refresh token rotation, RBAC

gRPC

Flight Inventory

Seat catalogue, Redis mutex lock with TTL

PostgreSQL + Redis

Booking Coordinator

Saga state machine orchestrator

RabbitMQ / AMQP

Payment Service

Stripe/Tranglo idempotency webhook handler

HTTPS Webhook

Notification Service

Async ticket generator & PDF dispatcher

RabbitMQ Consumer
  • API Gateway — rate limiting & correlation ID injection
  • Auth — JWT with RBAC & refresh token rotation
  • Flights — inventory search with Redis reservation locks
  • Bookings — Saga coordinator for seat holds
  • Payments — idempotent webhook processing
  • Notifications — async queues via RabbitMQ

Canonical event / payload contract

application/json
{
  "eventId": "evt_98319f8a",
  "eventType": "booking.payment_failed",
  "aggregateId": "bk_778102",
  "timestamp": "2026-09-01T14:32:00.000Z",
  "correlationId": "trace_9921fa4b",
  "payload": {
    "bookingId": "bk_778102",
    "seatNumber": "24A",
    "reason": "CARD_DECLINED",
    "actionRequired": "COMPENSATE_UNLOCK_SEAT"
  }
}

Resilience & high availability

Saga Orchestration: Automatic backward rollback releasing seat locks upon payment authorization failure.
Idempotency Guard: All mutating payment endpoints require UUIDv4 Idempotency-Key in Redis.
Dead-Letter Queues (DLQ): RabbitMQ consumer errors routed to DLQ with exponential backoff and replay.
Distributed Tracing: OpenTelemetry spans injected at gateway and propagated across IPC boundaries.
Compensating Saga transactionsDatabase-per-service isolationOpenTelemetry distributed tracing