bamazon-cli

Bamazon

This activity is about creating storefront with node.js and MySQL.

There are three applications in this exercise:

Prepare the Applications

To use the applications:

  1. Clone the repository to your computer.
  2. Once cloned, change into the directory with the cloned files.
  3. At the command prompt type yarn and press
  4. While in the root folder of the project, create a file called .env.
  5. Within the .env file, create the following entries:
DB_USER=<mysql_db_user>
DB_PASSWORD=<mysql_db_user_password>

There should be no spaces around the equal sign, and the values should not be surrounded by quotes.

  1. Save the file once you have updated the credentials.
  2. Edit the bamazon.sql file.
  3. Un-comment lines 1 through 4.
  4. Supply the password on line 2 between the single quotes.
  5. On the command line execute the following:
mysql -u root < bamazon.sql
mysql -u root < bamazon_supervisor.sql

bamazonCustomer.js

When the bamazonCustomer.js application is launched, a list of the currently available products are displayed. The customer is then asked to choose an item for purchase, by entering the Id of the item. If they have selected a valid Id, then they are asked to enter how many of the selected product they would like to purchase. If the item Id and the quantity to purchase are valid, the sale is completed and the customer is shown the total price for their purchase. They are then asked if they’d like to make another purchase or exit.

Demonstration

The images below demonstrate each of the functions required by the exercise.

Quit during the purchase process

These demonstrations shows the ability to quit from the purchasing screens

Purchasing Quit at first Prompt Purchasing Quit from the quantity to purchase

Product Id and Quantity Validation

This demonstration shows input validation for the product Id. This is when the customer enters an Id for something that is not in the list displayed.

Validation for the selected product to purchase

This demonstration shows input validation for the stock amount. Primarily for those cases where the customer attempts to purchase more than are available in stock.

Validation for the quantity to purchase

Successful Purchase

This demonstrates a successful purchase, including the display of the final purchase price.

Successful Purchase

bamazonManager.js

The bamazonManager.js application presents the manager with a menu of options for managing store inventory.

bamazonSupervisor.js

The bamazonSupervisor.js application presents the supervisor with a menu of options: