-
User Authentication & Authorization:
- User registration and login using JSON Web Tokens (JWT).
- Role-based access control: admin vs. regular user.
-
Movie Management:
- Admins can create, update, and delete movies.
- Each movie has a title, description, genre, and poster image.
-
Showtime Management:
- Admins can create, update, and delete showtimes for each movie.
- Users can browse available showtimes.
-
Reservation Management:
- Users can reserve seats for specific showtimes.
- Users can view and cancel their reservations (only for upcoming showtimes).
- Admins can view all reservations, seat capacity, and revenue reports.
- Node.js installed on your machine.
- PostgreSQL database.
-
Clone the repository:
git clone https://github.com/iArchitSharma/movie-reservation-system.git cd movie-reservation-system
-
Install dependencies:
npm install
-
Create a
.env
file with your environment variables:touch .env
Add the following variables in your .env file:
PORT=3000 DB_HOST=localhost DB_USER=root DB_PASSWORD=your_password DB_NAME=movie_reservation JWT_SECRET=your_jwt_secret
-
Create the Database Manually: Before running the app, you need to create the movie_reservation database manually in PostgreSQL since Sequelize only syncs tables and does not create the database itself.
- Open your PostgreSQL terminal or a PostgreSQL client and run:
CREATE DATABASE movie_reservation;
- Open your PostgreSQL terminal or a PostgreSQL client and run:
-
Sync database schema: Since migrations are not being used, Sequelize will automatically sync your models to the database tables. Ensure your database is up and running, and run the app:
npm start
POST http://localhost:3000/auth/register
Body: {
"name": "John Doe",
"email": "[email protected]",
"password": "securepassword",
"role": "admin"
}
POST http://localhost:3000/auth/login
Body: {
"email": "[email protected]",
"password": "securepassword"
}
GET http://localhost:3000/users
POST http://localhost:3000/movies
Body: {
"title": "Inception",
"description": "A mind-bending thriller about dream invasion.",
"genre": "Sci-Fi",
"posterImage": "inception.jpg"
}
GET http://localhost:3000/movies
PUT http://localhost:3000/movies/1
Body: {
"title": "Inception (update)",
"description": "A mind-bending thriller about dream invasion.",
"genre": "Sci-Fi",
"posterImage": "inception_update.jpg"
}
DELETE http://localhost:3000/movies/1
POST http://localhost:3000/movies/:movieId/showtimes
Body: {
date: '2023-10-05',
time: '19:30',
capacity: 100
}
GET http://localhost:3000/movies/:movieId/showtimes
POST http://localhost:3000/reservations
Body: {
"showtimeId": 1,
"seats": 2
}
GET http://localhost:3000/reservations/my-reservations
DELETE http://localhost:3000/reservations/:reservationId:
POST http://localhost:3000/reservations/showtime/:showtimeId: