https://github.com/iarchitsharma/movie-reservation-system
This is the backend system for a movie reservation service, which allows users to sign up, log in, browse movies, reserve seats for specific showtimes, and manage their reservations.
https://github.com/iarchitsharma/movie-reservation-system
bcrypt dotenv express javascript jwt nodejs nodemon postgresql sequelize
Last synced: about 2 months ago
JSON representation
This is the backend system for a movie reservation service, which allows users to sign up, log in, browse movies, reserve seats for specific showtimes, and manage their reservations.
- Host: GitHub
- URL: https://github.com/iarchitsharma/movie-reservation-system
- Owner: iArchitSharma
- Created: 2024-09-09T18:38:41.000Z (8 months ago)
- Default Branch: main
- Last Pushed: 2024-10-14T18:25:54.000Z (7 months ago)
- Last Synced: 2025-01-16T19:03:58.552Z (3 months ago)
- Topics: bcrypt, dotenv, express, javascript, jwt, nodejs, nodemon, postgresql, sequelize
- Language: JavaScript
- Homepage:
- Size: 105 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Movie Reservation System
## Features
* **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.## Installation and Setup
### Prerequisites
* Node.js installed on your machine.
* PostgreSQL database.### Steps
1. **Clone the repository**:
```bash
git clone https://github.com/iArchitSharma/movie-reservation-system.git
cd movie-reservation-system
```2. **Install dependencies**:
```bash
npm install
```3. **Create a `.env` file** with your environment variables:
```bash
touch .env
```Add the following variables in your .env file:
```env
PORT=3000
DB_HOST=localhost
DB_USER=root
DB_PASSWORD=your_password
DB_NAME=movie_reservation
JWT_SECRET=your_jwt_secret
```4. **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:
```sql
CREATE DATABASE movie_reservation;
```5. **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:
```bash
npm start
```## Test the API Routes
### Register a new user:
```
POST http://localhost:3000/auth/register
Body: {
"name": "John Doe",
"email": "[email protected]",
"password": "securepassword",
"role": "admin"
}
```### Login:
```
POST http://localhost:3000/auth/login
Body: {
"email": "[email protected]",
"password": "securepassword"
}
```### Get all users:
```
GET http://localhost:3000/users
```### Create a movie (Admin only):
```
POST http://localhost:3000/movies
Body: {
"title": "Inception",
"description": "A mind-bending thriller about dream invasion.",
"genre": "Sci-Fi",
"posterImage": "inception.jpg"
}
```### Get all movies (Admin only):
```
GET http://localhost:3000/movies
```### Update a movie (Admin only):
```
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 a movie (Admin only):
```
DELETE http://localhost:3000/movies/1
```### Create a showtime for a movie (Admin only):
```
POST http://localhost:3000/movies/:movieId/showtimes
Body: {
date: '2023-10-05',
time: '19:30',
capacity: 100
}
```### Get showtimes for a movie:
```
GET http://localhost:3000/movies/:movieId/showtimes
```### Reserve seats for a showtime.
```
POST http://localhost:3000/reservations
Body: {
"showtimeId": 1,
"seats": 2
}
```### Fetch all reservations for the logged-in user
```
GET http://localhost:3000/reservations/my-reservations
```### Cancel a reservation
```
DELETE http://localhost:3000/reservations/:reservationId:
```### Fetch all reservations for a specific showtime (Admin only)
```
POST http://localhost:3000/reservations/showtime/:showtimeId:
```CC: https://roadmap.sh/projects/movie-reservation-system