Skip to content

Suvidh-kaushik/Movie_Booking_System

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 

Repository files navigation

Architecture Overview

Screenshot from 2025-10-06 14-28-23

Live Links

Movie Booking System

Microservices-based movie-booking platform with two backend services:

  • user service: auth (OTP via email), user/admin profiles, movies, shows, bookings
  • mail service: consumes RabbitMQ queue and sends emails for OTP, booking confirmation

Tech stack

  • Node.js, Express, TypeScript
  • MongoDB (Mongoose), Redis, RabbitMQ
  • Nodemailer, Cloudinary (image upload for movies)
  • Next.js frontend (in frontend/)

Getting started (local)

Prereqs

  • Node.js 20+
  • MongoDB
  • Redis
  • RabbitMQ
  1. Clone and install
cd backend/user && npm install
cd backend/mail && npm install
  1. Create .env files
  • Backend user service: create backend/user/.env (see examples below)
  • Mail service: create backend/mail/.env
  1. Run dev Terminal A (user service):
cd backend/user
npm run build && npm run start
# or for watch mode
npm run dev

Terminal B (mail service):

cd backend/mail
npm run build && npm run start
# or
npm run dev

Ensure MongoDB, Redis, and RabbitMQ are already running and the connection variables in .env match your setup.


Getting started (Docker)

There are per-service Dockerfiles and docker-compose files. External infra

  1. User service
cd backend/user
docker build -t movie-user-service:latest .

# Provide env via compose (recommended) or `--env-file`
docker compose up -d

Notes:

  • Code expects MONGODB_URL (not MONGO_URI). If using the included compose file, set MONGODB_URL in your environment or adjust the compose file to map MONGODB_URL instead of MONGO_URI.
  1. Mail service
cd ../mail
docker build -t movie-mail-service:latest .
docker compose up -d

Example infra containers (optional):

# MongoDB
docker run -d --name mongo -p 27017:27017 mongo:7

# Redis
docker run -d --name redis -p 6379:6379 redis:7

# RabbitMQ (with management UI)
docker run -d --name rabbit -p 5672:5672 -p 15672:15672 \
  -e RABBITMQ_DEFAULT_USER=user -e RABBITMQ_DEFAULT_PASS=pass rabbitmq:3-management

.env examples

Create the following files with your values.

backend/user/.env

# Service
PORT=5000
NODE_ENV=development
FRONTEND_URL=http://localhost:3000

# Datastores
MONGODB_URL=mongodb://localhost:27017
REDIS_URL=redis://localhost:6379

# RabbitMQ
RABBIT_MQ_HOST=localhost
RABBIT_MQ_USER=user
RABBIT_MQ_PASSWORD=pass
RABBIT_MQ_VHOST=/

# Auth
JWT_SECRET=change_me

# Cloudinary (either use individual keys below OR CLOUDINARY_URL)
CLOUD_NAME=your_cloud
API_KEY=your_key
API_SECRET=your_secret
# CLOUDINARY_URL=cloudinary://<api_key>:<api_secret>@<cloud_name>

backend/mail/.env

PORT=5001

# RabbitMQ
RABBIT_MQ_HOST=localhost
RABBIT_MQ_USER=user
RABBIT_MQ_PASSWORD=pass
RABBIT_MQ_VHOST=/

# Email (Gmail example)
NODEMAILER_USER=[email protected]
NODEMAILER_PASS=your_app_password

API reference (user service)

Base URL: http://localhost:5000/api/v1

Auth

  • POST /auth/login – request OTP to email. body: { email }
  • POST /auth/user/verify – verify OTP for user login/signup. body: { email, otp } → sets jwt cookie
  • POST /auth/admin/verify – verify OTP for admin login/signup. body: { email, otp } → sets jwt cookie
  • POST /auth/logout – clears jwt cookie

User

  • GET /user/self – get profile (cookie auth)
  • POST /user/self – update username. body: { username } (cookie auth)

Admin

  • GET /admin/self – get admin profile (cookie auth)
  • POST /admin/self – update admin username. body: { username } (cookie auth)
  • GET /admin/theater – list theaters for admin (cookie auth)
  • POST /admin/theater – create theater. body: { theaterName, location } (cookie auth)
  • POST /admin/theater/:theaterId/screen – add screen to theater (cookie auth)
  • GET /admin/theater/:theaterId/screen – list screens for theater (cookie auth)
  • POST /admin/screen/:screenId/show – add show. body: { movieId, time, duration } (cookie auth)
  • GET /admin/screen/:screenId/show – list shows for a screen (cookie auth)
  • POST /admin/movie – add movie with image upload (multipart/form-data field image) and fields { title, duration, genre, language, releaseDate } (cookie auth)

Booking

  • GET /booking/movie – list all movies
  • GET /booking/:movieId/shows?date=YYYY-MM-DD – list shows for a movie on a date
  • GET /booking/show/:showId/seats – get available seats
  • PATCH /booking/show/:showId/book – book seats. body: { seats: [{row, col}, ...] } (cookie auth)
  • GET /booking/self – list bookings for current user (cookie auth)

Cookie auth

  • Successful verify routes set a jwt httpOnly cookie for subsequent requests

Notes

  • Ensure RabbitMQ credentials match both services.
  • Mail service reads queue send-mail and sends via Gmail SMTP; enable App Passwords.
  • If running behind a different frontend origin, update FRONTEND_URL in backend/user/.env.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages