/Book-Store-Backe-End-project

Book Store Back-End built using Express and Node JS as a college project

Primary LanguageJavaScriptThe UnlicenseUnlicense

Book-Store-Back-End-project

Task One

Our project is depending on NodeJs to build a Book Store, Which provides different types of books and make customer able to buy any of them. Each book has its Name, Author and Price as an initial attributes.

In File: Books.js you can see the basic set of books which we created.

The Basic functions we used is: Get, Post, Delete, and Put to make basic proccesses in our BookSet, you can see this here: BookController . With help of Postman these functions are applied. Like that:

Post

Adding book by ID:4:

new

Get

Getting all books:

95

Getting one book by ID:1

96

Put

Editing specific book by ID:4

98

Delete

*Deleting one book ID:2 and showing the rest books:

100

Deleting specific book by ID:

99

Note

1-The validation function file: BookValidation is used to validate the rules which we predetermined, we call it in need (e.g.: Put and Post).

2-The Router file: BookRouter is used to access all functions when it's called.

.................................................................................................................................................................................................

Task Two

In this task, We created a simple Nosql DataBase in MongoDB: it's consists of

1- Books: Which contains all books in DB which have some attributes, such like: BookName, BookAuthor, PublicationYear, and BookCount.

2- User: User can make order by choosing any available books, each user has an specific order in which we can specify and calculate all total amount of books he has orderd.

3-Order: This order contains all books the user has chosen (Each user with specific order). We handle the case of ordering some Books which is above the number of our available books, In addition to making user able to Enter his information (e.g. Address, Name, Email, PhoneNumber,...) and in case of confirmation order (checkout) the total price is calculated, and the quantity of available books also.

The relation between tables:

Schema

now we add 2 books in our Books table as shown, each book has its attributes like name, author, price, and count that shown the number of avaliable books in the store.

Note: we apply CRUID operations in books table

books

now user fill his information like username, password and email to register the website and we saved this data in our users table as shown.

Note: we apply CRUID operations in users table

user

now user ready to order books from website, he needs to enter his phonenumber, address and quantity of the book(we compare the quantity of book he ordered with the count of the avaliable books in books table). and we store the price of his order in orders table in attribute called amount which calculated from price of the book and the quantity of the book he ordered.

Note: we apply CRUID operations in orders table

order

We make Two functions editOrder and confirmOrder in order_controller.

editOrder : it make any user which already request an order to edit on its order details like count of books that he need.

this picture before editing order. before editing

but this after editing order(which edit Phone number and address and quantity of book which he want then amount changed automatically). After editing

confirmOrder : this function for user for confirmation order and after confirm he can't change or edit anything in his order and before confirmation status of order will be not confirmed but after confirmation will be confirmed and waiting mean waiting for shipping for someone.

this picture before confirmed before confirmed

but this after confirmed after confirmed

At this time, it's admin respinsability to handle the status case, in the Admin table which contains some attributes attached to admin himself (Such like:Name, Password, and Email) as shown in our DB :

2023-04-20_10h52_56

This Admin can handle the case of the status if it arrived to user or not, As shown the Status is changed from: Confirmed and Waiting to: Shipped :

The Admin can also Delete (aka block) some users if he needed, when user didn't complete order in the proper way (as user didn't pay his payment of order).