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.examplefile: Example file containing environment variables used by the application (see instructions below)./configdirectory: Contains all the application config files./helpersdirectory: Contains helper files for reusable components./publicdirectory: Contains static assets that are served directly to the client browser./routesdirectory: Contains various app route files./viewsdirectory: 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/controllersdirectory: Contains auth and watchlist application controller login./middlewaredirectory: Contains the application auth middleware./migrationsdirectory: Contains migrations to setup and alter the MongoDB./modelsdirectory: 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
bun install. - Rename
.env.exampleto simply.envin the project root directory and change the following lines:-
OMDB_API_KEY=your_api_key_here- replaceyour_api_key_herewith your actual OMDB API key. -
API_PORT=3000- replace3000with the port you want the node server to run on. -
APP_URL=binger.uk- replacebinger.ukwith your website/app's live URL.
-
- Start the application by running
bun 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.ukTo 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
.envfile:#MONGO_URI="mongodb://localhost:27017" #MONGO_DATABASE=binger-uk #MONGO_USERNAME= #MONGO_PASSWORD= #MONGO_HOST=localhost #MONGO_PORT=27017
With them uncommented your
.envfile 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_URIandMONGO_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
.envfile. Open up a terminal and in the project root run the following:bun 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.servicethen 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/loginand./user/profilepaths to see if data is being stored correctly.
- Run
bun run testto execute the test suite. - Run
bun test:coverageto generate coverage for the entire project. A summary will be printed to the console and full reports will be written to thecoverage/folder (HTML, lcov, text).
- Run
bun lintto type-check all TypeScript files using the TypeScript compiler in no-emit mode and lint EJS templates. - Run
bun lint:tsto type-check only the TypeScript files. - Run
bun lint:ejsto lint EJS templates.
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.
Would love some help on these...
- Work out a way to stop the video player from adding popups when watching1.
- Add personalised recommendations. (not so easy to do)
- 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.
It's nice to tick some things off the list...
- Migrate code to TypeScript for better extensibility.
- Improve UI on View player page to include movie/tv information and title.
- Implement a proper authentication mechanism to restrict access to the application.
- Add next and previous buttons to easily switch between series.
- Add more features such as:
- User profiles
- Better search interface
- Bookmarks to save items to profile
- Add test suite so we can code better.
- Add code coverage reporting
- Change layout to include all episodes on the view screen.
- Complete test suite.
Copyright (c) 2024-2025 Justin Hartman. All rights reserved.
The application is licensed under the MIT license.
Footnotes
-
This is a product of not hosting your own video content and the video feed providers try monetise through popups. I want a way to kill this because there's known malware in these popups! ↩