This is a microservices-based ticketing platform where users can create and sell tickets, place orders, and process payments. The system includes authentication, ticket management, order management, expiration handling, and payment services. The architecture is built using Docker, Kubernetes, and NATS Streaming for event-driven communication between services.
- Frontend: Next.js (Client Service)
- Backend: Node.js, Express, MongoDB
- Event Bus: NATS Streaming
- Containerization & Orchestration: Docker, Kubernetes
- Authentication: JWT
- Queue Handling: Bull (Redis-based queue for expiration service)
- Payments: Stripe API
- Handles user registration, login, and authentication using JWT.
- Provides authentication middleware for other services.
- Allows users to create and manage tickets.
- Listens for order-related events to update ticket availability.
- Publishes events when tickets are created or updated.
{
"title": { "type": "String", "required": true },
"price": { "type": "String", "required": true },
"userID": { "type": "String", "required": true },
"orderID": { "type": "String" }
}
- Manages ticket orders, ensuring that a ticket can only be purchased once.
- Publishes order creation and cancellation events.
- Listens for ticket updates and payment confirmation.
{
"userID": { "type": "String", "required": true },
"status": { "type": "String", "required": true },
"expiresAt": { "type": "Date" },
"ticket": { "type": "mongoose.Schema.Types.ObjectId", "ref": "Ticket" }
}
- Listens for order creation events and starts a countdown timer (5 minutes) for payment.
- Publishes an event when an order expires.
- Processes payments using Stripe.
- Listens for order expiration and order creation events.
- Publishes payment confirmation events.
{
"orderId": { "type": "String", "required": true },
"stripeId": { "type": "String", "required": true }
}
- Ticket Creation: A user creates a ticket. The Ticket Service publishes a
ticket:created
event. - Order Placement: A user places an order. The Order Service publishes an
order:created
event. - Order Expiration Countdown: The Expiration Service listens for
order:created
events and starts a 5-minute countdown. It publishes anexpiration:completed
event upon timeout. - Payment Handling:
- If a payment is made before expiration, the Payment Service publishes a
payment:created
event, and the Order Service marks the order as completed. - If no payment is made, the Order Service listens for
expiration:completed
and cancels the order, allowing the ticket to be resold.
- If a payment is made before expiration, the Payment Service publishes a
- Node.js
- Docker
- Kubernetes
- NATS Streaming Server
- Redis (for expiration queue)
- Stripe API Keys
- Clone the repository:
git clone https://github.com/Himu25/ticketing-app.git cd ticketing-app
- Install dependencies:
npm install
- Start services using Docker:
docker-compose up --build
- Deploy to Kubernetes:
kubectl apply -f infra/k8s/
- Set environment variables:
export JWT_KEY="your-secret" export STRIPE_KEY="your-stripe-secret"
POST /api/users/signup
– User signupPOST /api/users/signin
– User login
POST /api/tickets
– Create a ticketGET /api/tickets/:id
– Get a ticketPUT /api/tickets/:id
– Update a ticket
POST /api/orders
– Create an orderGET /api/orders/:id
– Get an orderDELETE /api/orders/:id
– Cancel an order
POST /api/payments
– Process a payment
This project is licensed under the MIT License.
Himanshu Singh