An Amazon-like storefront using Node.js & MySQL
The app takes in orders from customers and depletes stock from the store's inventory. It also tracks product sales across store's departments and provides a summary of the highest-grossing departments in the store.
[http://recordit.co/Gc9l3AWTlj]
[http://g.recordit.co/ehAmRPtv6B.gif]
[http://g.recordit.co/MIhGlsyHcD.gif]
[http://g.recordit.co/o0hxkJdmHV.gif]
[http://g.recordit.co/9I7H3yKWLW.gif]
[http://g.recordit.co/LwhnO12GWc.gif]
[http://g.recordit.co/MUbAsFmP5p.gif]
[http://g.recordit.co/p3wWWACW0W.gif]
[http://g.recordit.co/4KeKnfL59e.gif]
[http://g.recordit.co/Kji4izwFIM.gif]
[http://g.recordit.co/ihOzY0YM7Q.gif]
Running this application first displays all of the items available for sale.
The app then prompts users for the ID of the product they would like to buy and how many units of the product they would like to buy.
Once the customer has placed the order, the application checks if the store has enough of the product to meet the customer's request.
If not, the app displays the message Insufficient quantity!, and then prevents the order from going through.
If the store does have enough of the product, it fulfills the customer's order and updates the SQL database to reflect the remaining quantity.
Once the update goes through, it shows the customer the total cost of their purchase.
Running this application will:
-
List a set of menu options:
-
View Products for Sale
-
View Low Inventory
-
Add to Inventory
-
Add New Product
If a manager selects View Products for Sale, the app lists every available item with their ids, names, prices, and quantities.
If a manager selects View Low Inventory, then it lists all items with an inventory count lower than five.
If a manager selects Add to Inventory, the app displays a prompt that will let the manager "add more" of any item currently in the store.
If a manager selects Add New Product, it allows the manager to add a completely new product to the store.
Running this application will list a set of menu options:
-
View Product Sales by Department
-
Create New Department
When a supervisor selects View Product Sales by Department, the app displays a summarized table in their terminal/bash window.
The total_profit column is calculated on the fly using the difference between over_head_costs and product_sales. A negative value indicates sales is less than overhead costs indicating a loss.
Download the application from GitHub.
Run the schema.sql file to create:
- Bamazon database
- Products table
- Departments table
Run the seeds.sql file to populate the database with values.
Run npm install to install the dependencies from package.json.
To run the three modules use:
- node bamazonCustomer.js
- node bamazonManager.js
- node bamazonSupervisor.js
- inquirer: For command line user interfaces.
- mysql: node.js driver for mysql.
- cli-table : To log the table to the console.