Bamazon - Node.js & MySQL
This is an Amazon-like storefront using MySQL. The app displays products for sales, takes in orders from customers and depletes stock from the store's inventory listed in MySQL after a purchase. This app also provides a manager view which allows the user to display product information, add to inventory, view low inventory items and add new products.
- NPM Inquirer
- NPM Dotenv
- NPM Table
- NPM MySQL
- You will need to fork the repository to your own github, the pull it into your local drive. You will need installed on your local computer:
- Once you have these items on your computer and the repository folder on your computer open in git bash you can enter the code: npm install This will install the required npm packages. To view these required npms look into the package.json file. The include: inquirer, dotenv, table and mysql.
- You will need to open mySQL Workbench and add the database and table.
- You will need to create a .env file that contains your password for mySQL in the following format (enter your password where the stars are: MYSQL_PASSWORD="*********"
- YOu can choose either bamazonCustomer.js or bamazonManager.js to node to start the application. Do this by opening your gitbash and go into the folder where the repository is held and in the command line type node bamazoncustomer.js for the customer option or node bamazonmanager.js for the manager view. Please note: if there is an error or issue with node not ending the program - press CNTRL C
Customer View (bamazonCustomer.js)
- Displays product information information including:
- item_id (unique id for each product)
- product_name (Name of product)
- price (cost to customer)
- stock_quantity (how much of the product is available in stores)
- The app prompts the user the ID of the product they would like to buy.
- The second prompt asks how many of selected product they would like to buy.
- Once the user has placed the order, the application checks:
- if the store has enough of the product to meet the user's request.
- if not, the app log the phrase "Insufficient quantity!", and prevents the order from going through.
- if the store does have enough of the product, the order is filled and the total price, the item and quantity is logged.
Manager View (bamazonManager.js)
- List a set of menu options:
- View Products for Sale
- View Low Inventory
- Add to Inventory
- Add New Product
- End Program
- If a manager selects View Products for Sale, the app list every available item: the item 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 should allow the manager to add a completely new product to the store.
I was not able to get the table view to work properly or stacked. If you find any other issues while using the app or have a request or solution, please email me at firstname.lastname@example.org. Thank you for your time and suggestions!