This project is a web application that allows users to search for movies and TV shows using the OMDb API. The
application is built using Node.js, Express.js, Axios and MongoDB. It provides a user-friendly interface for searching
and browsing movies and TV shows, along with a feature to watch the videos directly in the app.
The application provides the following features:
- Search for movies and TV shows using the OMDb API.
- Display search results on the screen.
- Watch videos directly on the webpage using the VidSrc video API.
- Display movie and TV show posters on the screen.
- Comments under each movie/series via Disqus.
- User registration, login, logout, profile and watchlist functionality via a MongoDB database.
- Configuration files to set up Nginx and systemd for running as a webapp under a domain name.
- Documentation to help you get setup with MongoDB and other items for making the app work.
- A RapidAPI file for macOS and Visual Studio with all the OMDb API endpoints for you to test with.
The core project's structure is as follows:
app.js
: The main entry point of the application, which sets up the server and listens for incoming requests..env.example
file: Example file containing environment variables used by the application (see instructions below)./config
directory: Contains all the application config files./helpers
directory: Contains helper files for reusable components./public
directory: Contains static assets that are served directly to the client browser./routes
directory: Contains various app route files./views
directory: Contains EJS templates for rendering web pages.
By default, the app will work out the box, however, it is also capable of handling user registration, login, logout, profile and watchlist functionality through the use of a MongoDB database. I figured that MongoDB may be beyond some people's scope, so I wanted to keep the app lightweight and easy to get running without complex configuration, therefore enabling MongoDB is optional.
The authentication and user project structure is as follows:
migrate-mongo-config.js
: The configuration file for running MongoDB migrations/controllers
directory: Contains auth and watchlist application controller login./middleware
directory: Contains the application auth middleware./migrations
directory: Contains migrations to setup and alter the MongoDB./models
directory: Contains the User model and any future models.
You can decide to run the app in its basic format where it will just act as a search engine and video player. However, you can also enable the Authentication & User format which uses MongoDB to save items to user's profiles.
To install and set up the basic project, follow these steps:
- Clone the repository to your local machine.
- Navigate to the project directory in your terminal.
- Install the required dependencies by running
yarn install
. - Rename
.env.example
to simply.env
in the project root directory and change the following lines:-
OMDB_API_KEY=your_api_key_here
- replaceyour_api_key_here
with your actual OMDB API key. -
API_PORT=3000
- replace3000
with the port you want the node server to run on. -
APP_URL=binger.uk
- replacebinger.uk
with your website/app's live URL.
-
- Start the application by running
yarn start
.
Included in the /system
folder are two configuration files:
/system/nginx/binger.uk.conf
: this is an Nginx config file for running the app using Nginx/system/systemd/binger.service
: this is an Ubuntu/Debian systemd config file for booting up the Node.js server
Modify these to suite your environment to get the app running.
Note: the empty folder /system/nginx-root/
is used in the /system/nginx/binger.uk.conf
nginx file for SSL.
If you would like to use SSL we recommend installing certbot
and then executing this command:
# replace binger.uk with your domain name
$ sudo certbot --nginx -d binger.uk
To get the authentication and user functionality working, make sure you've followed all the steps above in the Basic Application and then follow these steps.
-
Install and configure MongoDB. There are detailed instructions here:
- Install for Debian Bookworm found at
./docs/mongodb/INSTALL_DEBIAN.md
- Install for Ubuntu 20.04 found at
./docs/mongodb/INSTALL_UBUNTU.md
- note that these instructions come from ChatGPT and I haven't tested them. I have a Debian server so please correct the instructions if you find any are incorrect and submit a PR.
- Install for Debian Bookworm found at
-
Uncomment the following in your
.env
file:#MONGO_URI="mongodb://localhost:27017" #MONGO_DATABASE=binger-uk #MONGO_USERNAME= #MONGO_PASSWORD= #MONGO_HOST=localhost #MONGO_PORT=27017
With them uncommented your
.env
file should look like this (assuming you followed the supplied tutorial in step 1):MONGO_URI="mongodb://localhost:27017" MONGO_DATABASE=binger-uk MONGO_USERNAME=myAdminUser MONGO_PASSWORD=myAdminPassword MONGO_HOST=localhost MONGO_PORT=27017
At a minimum, you must have added in values for
MONGO_URI
andMONGO_DATABASE
. You only need to add username and password if you secured your MongoDB installation as per my Step 1 documentation. -
You need to run the MongoDB migrations once you've added your MongoDB details to your
.env
file. Open up a terminal and in the project root run the following:yarn db:migrate
Or if you are using NPM:
npm run db:migrate
-
With the MongoDB collection now migrated, you can begin using your app. Simply restart your node server so your latest configs are loaded. If you've used the systemd service file I've supplied at
./system/systemd/binger.service
then all you need to do is restart the service with:sudo systemctl restart binger.service
-
You can now test your app URL paths like
./user/register
,./user/login
and./user/profile
paths to see if data is being stored correctly.
Included in this repository is a RapidAPI file created by the macOS app RapidAPI which is free. There is also a VSCode extension which should be able to work with this file but YMMV.
The file is located at /docs/api/OMDb_API.paw and contains a working implementation of the OMDb API used in this project. Open the file and begin testing the API to see responses.
- The application currently does not handle errors gracefully. If an error occurs during the search request or while rendering the webpage, it may cause the application to crash.
-
The application does not have a proper authentication mechanism. Anyone with access to the application can perform searches and watch videos. - The application does not have a proper logging mechanism. If an error occurs during the search request or while rendering the webpage, it may not be logged or displayed to the user.
-
There are some layout issues on mobile and tablet that need resolving.
-
Improve UI on View player page to include movie/tv information and title. - Change layout to include all episodes on the view screen.
-
Implement a proper authentication mechanism to restrict access to the application. - Add more features such as:
-
User profiles - Personalised recommendations
-
Better search interface -
Bookmarks to save items to profile
-
- Implement a proper logging mechanism to track errors and user interactions.
- Improve the error handling mechanism to provide better feedback to the user when an error occurs.
Copyright (c) 2024 Justin Hartman. All rights reserved.
The application is licensed under the MIT license.