Skip to content

Instantly share code, notes, and snippets.

@VarunBatraIT
Last active April 20, 2018 06:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save VarunBatraIT/5adc9a4f662169395e461c5b6f67cb2d to your computer and use it in GitHub Desktop.
Save VarunBatraIT/5adc9a4f662169395e461c5b6f67cb2d to your computer and use it in GitHub Desktop.

Please upload codes to github and share the url when you start the test.

Two different domains and Two Systems Client/Server.

  • Please consider that your backend is running at backendserver.com and html/css/jQuery OR angular/react app is running at frontendserver.com
  • Your server doesn't contain any codes of client. Both are mutually independent of each other. One laravel app is just a rest api, other app is nothing but simple forms built with angular/react or just jquery.

Three databases

  • information_db will contain a table shops with columns shop_name, db_name & reqeusts like
id shop_name db_name requests
1 Shop A shop_a 0
2 Shop B shop_b 0
  • shop_a will contain products table
  • shop_b will contain products table.

Products Table

  • Discount is in percentage. So listed price is 100, offered price is 90 for apple below. We are storing only offered price.
id category product discount price
1 fruit apple 10 90
2 fruit mango 5 190

REST Api

  • To add a new shop url is "/shop/" which will accept shop name as a post param. It will return shop id, database name and shop name and a new db will be created with an empty products table. Example /shop/ {name:shop B}
id shop_name db_name requests
1 Shop A shop_a 0
2 Shop B shop_b 0
3 Shop B shop_b_1 0
  • To add a new product in shop with id 1, url will be /shop/1/product with post method. To update Product 1, it will be put/patch request at /shop/1/product/1
  • To add a new product in shop with id 2 will be /shop/2/product with post method. To update Product 1, it will be put/patch request at /shop/2/product/1
  • Thus urls are
  • /shop/ post creates a new shop/
  • /shop/1/products Get gets all the products in shop id 1 like below: Note changes in columns. Below output is in HTML table. Depending on header it can be in JSON.
id Category name Product Name Discount in Percentage Offered Price Original Price
1 fruit apple 10 90 100
2 fruit mango 5 190 200
  • /shop/1/product/ Post will create a new product
  • /shop/1/product/1 Delete will delete product 1 in shop 1
  • /shop/2/product/1 Put/Patch will update product. If product doesn't exist, it will return a proper error (resource not found)
  • With each request in a particular shop, requests column in information_db database (shops table) will be incremented.
  • Please create a migration for parent database in sequelize.
  • Difference between patch and put. In patch, missing params will be ignored. In put, missing params will be consider as defaults. For example if discount is missing in put metchod and earlier discount was 20, discount will become 0.
  • Please use Laravel, Bootstrap/jQuery (Better if you can add React/Angular2)

Notes

Ensure to use git and commit your codes every hour. Spend only 5 hours not more than that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment