Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
17 views6 pages

Technologies Used For Backend: Node - Js and Express - Js

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views6 pages

Technologies Used For Backend: Node - Js and Express - Js

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

 TECHNOLOGIES USED FOR BACKEND

 Node.js and Express.js:

 Node.js: JavaScript runtime for building fast, scalable server-side


applications.
 Express.js: Framework for Node.js, providing robust features for web and
mobile applications.

 MongoDB:

 A NoSQL database for storing and retrieving data in a flexible, JSON-like


format.

 Mongoose:

 An ODM (Object Data Modeling) library for MongoDB and Node.js,


providing a straightforward, schema-based solution to model application data.

 DATABASE SCHEMA

COLLECTION IN MONGODB

 Users Collection

o Purpose: Stores user information for authentication and user


management.

o Fields:
 name (String): The name of the user.
 email (String): The email of the user.
 password (String): The hashed password of the user.
 MovieDetails Collection

o Purpose: Stores detailed information about movies.

o Fields:
 mname (String): Name of the movie.
 director (String): Director of the movie.
 genre (String): Genre of the movie.
 language (String): Language of the movie.
 rating (Number): Average rating of the movie.
 review (String): Summary review of the movie.
 image (String): URL of the movie poster image.
 trailer (String): URL of the movie trailer.
 isLatest (Boolean): Indicates if the movie is the latest
release.

 Items Collection

o Purpose: Stores user reviews for movies.

o Fields:
 name (String): Name of the user submitting the review.
 email (String): Email of the user submitting the review.
 mname (String): Name of the movie being reviewed.
 director (String): Director of the movie being reviewed.
 rating (Number): Rating given by the user.
 review (String): Review text submitted by the user.

 BACKEND ROUTES AND FUNCTIONS

The app.js file contains the routes and functions that interact with these collections:
 User Authentication:

 Signup:

 Route: POST /signup


 Function: Checks for existing user and inserts new user data into the
users collection.

 Login:

 Route: POST /login


 Function: Verifies user credentials against the users collection.

 Movie Management:

 Add Movie:

 Route: POST /addMovie


 Function: Inserts movie data into the movieDetails collection.

 View Movie Details:

 Route: GET /movies/:id


 Function: Fetches and renders details of a specific movie by ID from
the movieDetails collection.

 Review Management:

 Add Review:

 Route: POST /insert


 Function: Inserts review data into the items collection.

 Update Review:
 Route: POST /update
 Function: Updates an existing review in the items collection based
on user name and email.

 Delete Review:

 Route: POST /delete


 Function: Deletes a review from the items collection based on the
provided data.

 View Reviews:

 Route: GET /report


 Function: Generates an HTML report of all reviews in the items
collection.

 Search Functionality:

 Search Movies:

 Route: GET /search


 Function: Searches for movies by name using a case-insensitive regex
query in the movieDetails collection.

MONGODB SCHEMA WITH MONGOOSE

const mongoose = require('mongoose');

// User Schema

const userSchema = new mongoose.Schema({


name: { type: String, required: true },
email: { type: String, required: true, unique: true },
password: { type: String, required: true }
});

// MovieDetails Schema

const movieDetailsSchema = new mongoose.Schema({


mname: { type: String, required: true },
director: { type: String, required: true },
genre: { type: String, required: true },
language: { type: String, required: true },
rating: { type: Number, default: 0 },
review: { type: String, default: '' },
image: { type: String, default: '' },
trailer: { type: String, default: '' },
isLatest: { type: Boolean, default: false }
});

// Items Schema (User Reviews)

const itemsSchema = new mongoose.Schema({


name: { type: String, required: true },
email: { type: String, required: true },
mname: { type: String, required: true },
director: { type: String, required: true },
rating: { type: Number, required: true },
review: { type: String, required: true }
});

// Models

const User = mongoose.model('User', userSchema);


const MovieDetails = mongoose.model('MovieDetails', movieDetailsSchema);
const Items = mongoose.model('Items', itemsSchema);
module.exports = { User, MovieDetails, Items };

 SUMMARY

The backend design revolves around three primary collections in MongoDB: users,
movieDetails, and items, each serving distinct roles in user management, movie
information, and user reviews, respectively. These collections are accessed and manipulated
through various Express routes defined in the app.js file. The combination of Node.js,
Express.js, MongoDB, and Mongoose ensures a robust, scalable, and flexible backend for the
movie review system.

You might also like