Skip to content

Repository files navigation

🎟️ Full Stack Ticket Booking + Wallet System

πŸ“Œ Overview

This project is a full-stack ticket booking system with an integrated wallet and admin dashboard. It enables users to reserve and book event seats while ensuring data consistency, concurrency safety, and transactional integrity.

πŸš€ Features

πŸ‘€ User Features

  • User registration & login (JWT-based authentication)
  • Add money to the wallet
  • View wallet balance & transaction history
  • Browse events
  • View seat availability
  • Reserve seats (with 5-minute expiry)
  • Book seats using your wallet
  • View booking history

πŸ› οΈ Admin Features

  • Admin authentication
  • Create/update/delete events
  • Bulk create and manage seats
  • Monitor bookings
  • View wallet transactions
  • Cancel bookings
  • Process refunds

🧱 System Architecture

1. Backend (Core Logic)

  • RESTful APIs
  • Business logic implementation
  • Concurrency handling
  • Transaction management
  • Idempotency handling

2. Frontend (UI)

  • User interface for booking
  • Wallet dashboard
  • Admin panel

3. Database

  • MongoDB (NoSQL)

  • Optimized schema design for:

    • Users
    • Wallet transactions
    • Events
    • Seats
    • Bookings

βš™οΈ Tech Stack

Backend

  • Node.js
  • Express.js
  • TypeScript

Frontend

  • Next.js (Recommended)
  • Tailwind CSS
  • ShadCN UI
  • Redux (State management)

Database

  • MongoDB (with Mongoose)

πŸ” Authentication Module

Requirements

  • User signup & login
  • Admin login
  • JWT-based authentication

Security Considerations

  • Password hashing (bcrypt)
  • Token expiration & refresh strategy
  • Role-based access control (User/Admin)

πŸ’° Wallet System

Features

  • Credit (Add money)
  • Debit (Booking payment)
  • Transaction history
  • Optional: Wallet transfer

Rules

  • ❌ No negative balance
  • βœ… Use integer values (paise/cents)
  • βœ… Maintain transaction ledger

Data Model (Concept)

{
  userId: ObjectId,
  balance: number,
  transactions: [
    {
      type: "credit" | "debit",
      amount: number,
      status: "success" | "failed",
      referenceId: string
    }
  ]
}

🎫 Event & Seat Booking System

Features

  • List events
  • View seat availability
  • Reserve seats
  • Book seats

πŸͺ‘ Seat States

AVAILABLE β†’ RESERVED β†’ BOOKED

⏳ Reservation Rules

  • Seats are locked for 5 minutes
  • Expired reservations are auto-released

πŸ’³ Booking Flow

  1. Reserve seats
  2. Validate reservation
  3. Deduct wallet balance
  4. Confirm booking

⚠️ Constraints

  • Atomic operations (all-or-nothing)
  • No double booking
  • No double spending

πŸ“œ History Module

Users can view:

  • Booking history
  • Wallet transaction history

πŸ§‘β€πŸ’Ό Admin Dashboard

Event Management

  • Create/update/delete events

Seat Management

  • Bulk seat creation
  • View seat states

Booking Monitoring

  • View all bookings

  • Filter by:

    • User
    • Event
    • Status

Wallet Monitoring

  • View all transactions

Refund & Cancellation

  • Cancel booking
  • Refund wallet

⚠️ Critical Requirements

βš”οΈ Concurrency Handling

  • Prevent double booking
  • Prevent race conditions in wallet deduction

πŸ” Idempotency

  • APIs must be retry-safe
  • Prevent duplicate booking/payment

⏳ Expiry Handling

  • Reservation timeout (5 minutes)
  • Auto-release seats

πŸ’₯ Atomicity

  • Booking + payment must succeed or fail together

πŸ§ͺ Edge Cases to Handle

  • Parallel booking requests for the same seat
  • Wallet race conditions
  • Expired reservations during payment
  • Duplicate API requests
  • Partial failures in booking flow

πŸ› οΈ Setup Instructions

Clone Repository

mkdir project
git clone <repo-url>
cd project

Install node modules

npm install

Deployment

Start the app locally in your system (http://localhost:3000)

npm run dev

Create a build of the application

npm run build

To deploy this project, run

  npm run start

🧠 Design Decisions

  • MongoDB Transactions for atomic booking & payment
  • Optimistic/Pessimistic locking for seat reservation
  • Separate Wallet Ledger for auditability
  • Reservation expiry via TTL / cron job
  • Idempotency keys for payment APIs

πŸ“ˆ Future Improvements

  • Payment gateway integration
  • WebSockets for real-time seat updates

About

This project is a full-stack ticket booking system with an integrated wallet and admin dashboard. It enables users to reserve and book event seats while ensuring data consistency, concurrency safety, and transactional integrity.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages