I've created an Amazon-like storefront using MySQL and Node, specializing in products celebrating the 2018 NBA Playoffs.
The app takes in orders from customers, checks to see if there is enough product in stock, depletes from the store inventory, and lastly, displays how much the order will cost. This application runs entirely through a computer's command line or terminal.
To run the application locally, please initialize node from your terminal or command line: npm init
Then, copy and paste the code in bamazonSeeds.sql file into your favorite MySQL GUI tool.
PC users might want MySQL Workbench. Mac users might like Sequel Pro.
This will create the MySQL database (picture the MySQL database as a big Excel spreadsheet).
Now, we need to create the table which will hold our product inventory, and fill it with each product for sale. A MySQL table is a bit like a tab or sheet on an Excel spreadsheet. Do this by copying and pasting the code in bamazonSchema.sql.
Now, it's time to see the products available. To do this, make sure you're in the Bamazon application folder, and run bamazonCustomer.js: node bamazonCustomer.js
The store's inventory will display in a table, followed by the prompt Which item would you like? Type the item ID and hit enter. Perhaps you're a Houston Rockets fan and want some Beard Oil as a keepsake from this year's playoff's run?
Enter the correct Item ID (in this case, 7) followed by the quantity desired. You will then be given a total cost for your order. Refreshing the MySQL table will show the change in store inventory in the fifth column, stock_quantity.
But, you are not alone in loving the NBA. What happens if our NBA Playoffs store is out of that product?
There are only 5 customized Joel Embiid jerseys, for instance. What happens if you try to order one for everybody on your Rec League team (because they are AWESOME)?
You’ll learn the store is sold out of the product.
You will have the choice to either keep shopping or to stop shopping. Entering 'yes' will start the shopping process over again, revealing the store inventory in a table and asking which item you'd like.
Entering 'no' prompts a simple "have a nice day". Thank you for visiting my application!