A Command Line Interface (CLI) shopping cart application allowing users to add products to a cart and review the total price upon purchase completion.
Upon launching the application, the CLI prompts the user to input the products they wish to add to the shopping cart. Each product should be entered on a new line, specifying the quantity with a space.
Example:
❯ Apple 2
❯ Imported Wine 1
❯ Banana 6
After completing the entries, the user can review the selected products along with the total price, including applicable taxes and duties.
Example Output:
Selected Products
Name: Apple
Price: 50
Tax: 12
Quantity: 2
Cost: 112
Name: Imported Wine
Price: 1000
Tax: 18
Quantity: 1
Import Duty: 120
Cost: 1300
Name: Banana
Price: 10
Tax: 12
Quantity: 6
Cost: 67.2
Total Discount: Rs 0
Total: Rs 1479
Cess: Rs 1.68
Grand Total: Rs 1480.68
- Selected Products: Displays the name, price, applicable tax, quantity, import duty charges, and total cost of each product.
- Calculation of Total Price:
- Discount Calculation: If the total price (excluding tax) exceeds Rs 5000, a 5% discount is applied.
- Tax Calculation: Tax rates vary by product category. For example, fruits are taxed at 5% and liquor at 30%. Imported goods incur an additional 12% import duty.
- Cess Calculation: A cess of 4% is applied to the total tax amount.
- Node.js v16.19.0
- npm v8.19.3
- MySQL v8.0.31
- Bluebird (JavaScript Library) v3.7.2
-
Install Node.js and npm: Ensure Node.js and npm are installed on your system.
-
Clone the Repository:
git clone <repository-url> cd <repository-directory>
-
Install Dependencies:
npm install
-
Set Up MySQL Database:
-
Run the Application:
node ecart.js
-
Add Products to the Cart: Enter the product name and quantity (
<productName> <quantity>
) on each line to add products to the cart. -
Complete Shopping: Press
Ctrl+D
to finish shopping and review the shopping cart and total price.
Update the database configuration in ./codebase/db.js
as needed:
var pool = mysql.createPool({
host: "localhost",
user: "root",
password: "",
database: "ecart",
port: 3306
});
This project is licensed under the MIT License. See the LICENSE file for details.
Developed by Amburi Roy. For any inquiries, please contact via LinkedIn.