How ducanhle1992/ticket-booking-app works
Project Type and Purpose
• This is a full-stack, microservices-based ticket-booking platform written in Node.js/TypeScript.
• It uses an event-driven architecture over NATS Streaming to decouple services and ensure eventual consistency.
Main Components
a. Client (Next.js frontend)
b. Auth Service
c. Tickets Service
d. Orders Service
e. Payments Service
f. Expiration Service
g. Common Package (shared npm module)
h. NATS Streaming Cluster (Event Bus)
i. Databases (MongoDB instance per service)
j. Redis (for Expiration service)
k. External Stripe API
l. Kubernetes Cluster (Ingress, Deployments, Services)
m. CI/CD (GitHub Actions workflows & Skaffold)
Relationships and Data Flows
• Client ↔ HTTP ↔ Auth/Tickets/Orders/Payments APIs
• Auth issues JWTs for secure calls to other services.
• Each service ↔ MongoDB (its own collection)
• Orders, Tickets, Payments, Expiration publish/subscribe events via NATS:
• Tickets publishes ticket-created/updated → Orders & Payments subscribe.
• Orders publishes order-created/cancelled → Expiration & Payments subscribe.
• Expiration publishes expiration-complete → Orders subscribes (cancels unpaid).
• Payments publishes payment-created → Orders subscribes (marks paid).
• Expiration service also uses Redis as an in-memory queue for TTL management.
• Payments service calls Stripe’s external API for real payments.
Architectural Patterns & Principles
• Microservices: each service is independently deployed (Docker+K8s).
• Event-Driven Architecture: loose coupling via NATS Streaming (pub/sub).
• Optimistic Concurrency Control in Mongo models.
• Single Responsibility per service (Auth, Tickets, Orders, Payments, Expiration).
• Shared code extracted into a “common” npm package for models, middleware, and event definitions.
Technologies & Frameworks
• Backend: Node.js, Express, TypeScript
• Frontend: Next.js (React)
• Databases: MongoDB (one per service), Redis (Expiration)
• Messaging: NATS Streaming
• Containerization: Docker
• Orchestration: Kubernetes (Deployments, Services, Ingress)
• CI/CD: GitHub Actions, Skaffold
• External Service: Stripe API