Skip to content
A store that sells things
JavaScript
Branch: master
Clone or download
Latest commit c22220a Feb 27, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
assets/images
.gitignore
README.md
bamazon.sql
bamazonCustomer.js
bamazonManager.js
bamazonSupervisor.js
package-lock.json
package.json

README.md

bamazon

This is a small command-line application demonstrating usage of MySQL with Node.js.

Installation and setup

To install it, do the following:

cd bamazon
npm install

You also need MySQL running on the same machine (localhost) listening on port 3306. Run the included SQL script bamazon.sql to create the bamazon database and populate it with sample data. To specify the MySQL username and password to use, create a file called .env in the same directory that looks like this:

MYSQL_USER=<username>
MYSQL_PASSWORD=<password>

...filling in the <username> (can be root) and <password> with the appropriate values. You can also specify these values as environment variables.

Running the customer application

To run the customer application, do the following:

node bamazonCustomer.js

A table containing product IDs, product names, and prices appears: product table screenshot

Below the table, you are prompted for a product ID. Selecting a valid product then prompts you for how many to purchase. After entering a quantity, you're informed of the total purchase price and returned to your command prompt. buying product screenshot

Behind the scenes, the application has reduced the quantity stored in the bamazon database. Users are prevented from buying more than the database has in stock.

Running the manager application

To run the manager application, do the following:

node bamazonManager.js

A menu of choices appears: manager menu screenshot

Use the arrow keys to select items from the menu. After performing a function, the menu will reappear.

View Products for Sale

Selecting View Products for Sale displays all products, including their ID, name, unit price, and stock quantity. view products for sale screenshot

View Low Inventory

Selecting View Low Inventory will eother yield a message indicating there is no low inventory... no low inventory screenshot

...or a table of products with a stock quantity less than 5. low inventory screenshot

Add to Inventory

Selecting Add to Inventory presents a scrolling menu of products to which you may add more stock. add to inventory menu screenshot

After selecting a product, you may type in how many more of the product you wish to stock. A total stock count is then displayed. add to inventory quantity screenshot

Add New Product

The Add New Product selection enables you to add new products into the database. You will be prompted for produt name, department name, unit price, and units in stock. The new product ID is then printed. add new product screenshot

Quit

Finally, the Quit menu item quits the application and returns you to your command prompt. quit screenshot

Running the supervisor application

To run the manager application, do the following:

node bamazonSupervisor.js

A menu of choices appears: supervisor menu screenshot

Use the arrow keys to select items from the menu. After performing a function, the menu will reappear.

View Product Sales by Department

Selecting View Product Sales by Department shows a list of all departments' performance, including overhead costs, product sales and total profit. department product sales screenshot

Create New Department

Selecting Create New Department will prompt you for a new department name and overhead costs for the new department. create new department screenshot

Quit

Finally, the Quit menu item quits the application and returns you to your command prompt. quit screenshot

Libraries used

You can’t perform that action at this time.