- 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.
- 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.
- 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 |
- 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 | |
2 | fruit | mango | 5 | 190 |
- /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)
Ensure to use git and commit your codes every hour. Spend only 5 hours not more than that.