Movie Search Application

Hello everyone. Here, I will talk about an application that searches a MongoDB database and shows us the properties of the movie we're looking for. Additionally, we'll see the use of RedisCache and acceleration of query operations. You can follow my Github account for source code:

Fork me

Technologies Used
MongoDB

Before going into the details of the application, let's briefly talk about MongoDB. MongoDB, in simple terms, is an open-source NoSQL database application. It has become popular in a short time and is used by a wide audience due to its flexibility and ease of use. We can list its features as follows:

MongoDB Installation for Windows
Redis Cache

Redis is an in-memory data structure store used as a NoSQL database, for caching, and as a message server. The reason Redis calls itself a data structure store is that it supports more data types than its alternatives. We can list its advantages as follows:

Running the Project

This project is a web application that uses the Movies.csv file located on the github page and is written with Node.js/Express/MongoDB/RedisCache and we can run it on our local computer. First, we need to import the Movies.csv file to the MongoDB database on your computer.

mongoimport --db databaseName --collection collectionName --type csv --headerline --file csvFileName.csv

GET requests to the root directory return an HTML page containing a text box where the user can enter data and a search button as a response. After a POST request where the user sends a movie name written in this text box to the web server by clicking the search button, all properties of the relevant movie are returned as a response in a table. The movie name that reaches the server with a POST request is first searched in the cache and if found, it is sent back immediately. Movie information not found in the cache is searched in the database and if found, it is both brought to the cache and sent to the user as a response in table format. Hash data structure was used for data stored in the cache.

When running the project, a command screen should be opened in the root directory where the project is located and we need to first do the initialization process to create the environment. After this process, we will get various questions. We can answer them if we want, or we can skip them by pressing enter.

npm init

Then the modules we used while writing the project should be installed in order.

npm install express
npm install redis
npm install body-parser
npm install mongoose

After downloading the modules, we can run our project.

node moviesIndexDemo.js

After entering the port address shown in the command screen into our web browser, our application will appear.


We need to enter a movie name that exists in our database in the search screen on our main page and press the Search button. After the process, all information about the movie we searched for in the database is reflected to us.


If the movie we searched for is not found in Redis Cache, the movie is added to Redis Cache. In other searches, it is used from Redis Cache.


If we leave the box empty, a warning box is shown to us.


When we enter a movie name that is not in the database in the box, a text appears saying that the movie could not be found.



This is how the application's interfaces and functionality work.