This is the backend API for the Movie Website project, built using Node.js, Express, and MongoDB. The API provides endpoints for user authentication, movie management, ratings, and more.
- Project Overview
- Features
- Technologies Used
- Installation
- Usage
- API Endpoints
- Environment Variables
- Live Demo
- Frontend Repository
This backend API powers a movie discovery platform, allowing users to browse movies, submit ratings, and manage their favorites or watch later lists. It includes user authentication using JWT and OAuth for Google login, and handles database operations with MongoDB.
- User Authentication: Sign up, login, and Google login (OAuth 2.0).
- Movie Management: Fetch, filter, and manage movies in the database.
- Favorites & Watch Later: Add and retrieve movies from user lists.
- Ratings: Submit, view, and aggregate movie ratings.
- JWT Authentication: Secure endpoints with JSON Web Tokens (JWT).
- Node.js
- Express.js
- MongoDB (Database)
- Mongoose (ORM for MongoDB)
- JWT (Authentication)
- Google OAuth (Authentication)
- Dotenv (Environment variable management)
To run the backend API locally, follow these steps:
-
Clone the repository:
git clone https://github.com/manar255/Movie-app.git cd movie-app -
Install dependencies:
npm install
-
Set up environment variables: Create a
.envfile in the root directory and add the following variables:PORT=5000 DATABASE=your_mongodb_connection_string DATABASE_PASSWORD=your_mongodb_password SECRET_KEY=your_jwt_secret CLOUDINARY_NAME=your_cloudinary_name CLOUDINARY_API_KEY=your_cloudinary_api_key CLOUDINARY_API_SECRET=your_cloudinary_api_secret GOOGLE_CLIENT_ID=your_google_client_id GOOGLE_CLIENT_SECRET=your_google_client_secret
-
Start the server:
npm start
The server will be running at
http://localhost:5000.
Once the backend server is running, it will provide several RESTful API endpoints for managing users, movies, and ratings. These endpoints are secured using JWT, and user authentication is required for many actions, such as submitting ratings or managing favorites.
- POST /auth/signUp - Create a new user account.
- POST /auth/signIn - Log in with an email and password.
- POST /auth/google - Log in with Google OAuth.
- GET /movie/movies - Fetch all movies.
- GET /movies/:id - Get details of a specific movie.
- POST /movie - Add a new movie (Admin only).
- GET /movie/category/:category - Get movies by category name
- PUT /movie//rate/:id - Edit movie rate
- DELET /movie/:title - delete movie by title
- GET /user/ -get all user data
- GET /user/favList - Get the user's favorite movies.
- PUT /user/favList/id - Add or remove a movie to/from favorites.
- GET /user/watctLater - Get the user's watch later list.
- PUT /user/watctLater/:id - Add or remove a movie to/from the watch later list.
You need to configure the following environment variables in a .env file for the backend API to function properly:
- PORT: The port the server will run on (e.g.,
5000). - DATABASE: The MongoDB connection string.
- DATABASE_PASSWORD: Password for your MongoDB database.
- SECRET_KEY: Secret key used to sign and verify JWT tokens.
- CLOUDINARY_NAME: Your Cloudinary account name.
- CLOUDINARY_API_KEY: Cloudinary API key for handling image uploads.
- CLOUDINARY_API_SECRET: Cloudinary API secret for secure operations.
- GOOGLE_CLIENT_ID: Google OAuth client ID.
- GOOGLE_CLIENT_SECRET: Google OAuth client secret.
Check out the live demo of the Movie Website here: Live Demo Link
The frontend of this project is built with Angular. You can find the frontend repository here: Frontend Repository