Git Product home page Git Product logo

read-to-win-pub's Introduction

Read to Win Publications - Book Management App

This Backend Service is intended to keep track of book records and their authors while assessing social popularity of books in the database.

This App is Built with NodeJS powered Express Server to serve as a backend API.

Pre-requisites

  1. MongoDB Installation
  • Install MongoDB by following the tutorial mentioned here.
  • (Optional) Install MongoDBCompass for ease of importing dummy-data to local mongoDB
  1. Node JS Runtime - Simply download & install it from here.

  2. Node Package Manager

  • Run the following command on your terminal
 npm install npm@latest -g
  1. Postman (Optional) - This will be used to demonstrate functionality. Download from here

Initial Setup

  1. Run Mongod server on localhost
  • As instructed in above Mongo Installation tutorial, run the mongod server from localhost after installing MongoDB
  1. Clone the repository to your local machine.
   git clone https://github.com/YOUR_USERNAME_HERE/read-to-win-pub.git
  1. Open Command Line Terminal inside the Root of the Project

ex: PS E:\read-to-win-pub>

  1. First, execute npm install to install the dependencies
  2. Then, execute npm run dev to start the server on local port 5000.

Setting Up Dummy Data

  1. After setting up above, you can move onto importing the data collections provided in /dummy_data dir
├── dummy_data
    │   ├── authors.json
    │   ├── books.json
  • Use following namings to setup the new database when importing
* DB_NAME - `bookStore`
* collections - `authors` & `books`
  • Follow, the given tutorial here.
  • If this seems hefty, try with MongoDB Compass for easier importing.

Resources

This Server consists of two main sub-routes

  1. /author
  2. /books
  • BaseURL - 'localhost:5000'
  • You can follow these links via baseurl/linksformat.

ex: POST http://localhost:5000/books

  • Note: When passing body parameters, setup Content-Type header to application/x-www-form-urlencoded

Author

This will be used to carryout Author related transactions in DB.

POST /authors/- This will be used to create new authors in DB

  • this request requires 4 mandatory body parameters
    firstName - String, simple+capital-letters-only
    lastName - String, simple+capital-letters-only
    email - String , email-format-check[[email protected]]
    contactNo - Number[0-9], Length[10]
    

Request

image

Response

image

Books

This will be used to carryout Book related transactions in DB.

POST /books/ - This will be used to create new books in DB

  • this request requires 4 mandatory body parameters
    isbn - String, alphanumerics-only
    category - String
    title - String , alphanumerics-only
    authorId - Author ObjectID - created when adding a new author
    

Request

image

Response

image

GET /books/:isbn - this will be used to find a book in DB with its ISBN.

  • Here, :isbn will be replaced with Book's ISBN number.

Request

image

Response

image

PUT /books/:id/like - this will be used to handle when a user likes a specific book.

  • Here, :id will be replaced with Book's DB ObjectID (Which is set when the book is created).
  • This will increase likeCount { type: Number, defaultValue:0 } property of the book by 1.

Request

image

Response

image

Logging

Server Logs are available in logs/ Dir

  • There are 2 types of logging in this server
  1. Event Logging - This is done for every request in the app and saved in logs/server.log

  2. Author Popularity Logging

  • This is done per a 5 mins-step Schedule, where a report is generated on each Author's like Count every 5 mins.
  • Saved in logs/authorPopularity/likesCount.log

read-to-win-pub's People

Contributors

nadungg avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.