Welcome to My Awesome E-Commerce Application! This is a powerful and secure e-commerce platform that allows users to browse and purchase products and services online. The application is built with Node.js, Express.js, and MongoDB, providing a seamless and enjoyable shopping experience for customers.
- User Registration and Login: Users can create accounts and log in securely with hashed passwords & logout functionality using JWT token as a cookie for efficient working.
- User Authentication: JWT-based authentication for protected routes.
- Administrator Role: Special privileges for administrators to manage products and services.
- Product and Service Management: Administrators can add new products and services to the platform.
- Shopping Cart: Users can add products and services to their shopping cart.
- Tax-Calculator functionality: adding a separate file to impose tax based on the price of product and services individually.
- Cart Management: Users can update quantities, remove items, or clear the cart entirely.
- Checkout and Order Confirmation: Users can proceed to checkout that will generate the Total-Bill and confirm their orders.
- Viewing Orders made by the customers: Administration has the previleges to check all the orders that is being made.
- Product and Service Search: A search functionality allows users to find specific items quickly.
- Order History: Users can view their order history, providing an overview of past purchases.
- User Reviews and Ratings: Customers can leave reviews and ratings for products and services.
- User Profile: Users can update their profiles and manage personal information.
To get started with the application, follow these steps:
- Clone the repository
- Install dependencies:
npm install
- Set up your MongoDB database and JWT key add your connection string & key to
.envfile for security purposes. - Create a
.envfile in the root directory with the following environment variables: Note: Replaceyour-mongodb-connection-stringwith your MongoDB URI andyour-secret-key-for-jwtwith a hashed secret key for JWT token. - Start the server:
npm start - Access the application at
http://localhost:8001 - PORT I am using is 8001 for testing purposes.
The following API endpoints are available:
- GET
/will fetch all the items (Products and Services) added by the Admin - POST
/users/registerwill register a user if not already otherwise will give an error if already registered (Use email, password, and Boolean isAdmin property to register) - POST
/users/loginwill log in the user and create and JWT Token and store this Token as a cookie for logout purposes (Use email, password to log in & and all the unauthorized access is taken care of) - GET
/users/logoutwill log out the user and delete the generated Cookie of the JWT Token - GET
/cartswill fetch the cart of the user - POST
/carts/product/product IDwill add the product to the cart (send the quantity of the product from the body itself) - POST
/carts/service/service IDwill add service to the cart (send the quantity of the service from the body itself) - DELETE
/carts/product/product IDwill delete the product from the cart - DELETE
/carts/service/service IDwill delete service from the cart - DELETE
/cartswill clear the cart - POST
/carts/checkoutwill check out the cart and generate the Total Bill - POST
/carts/confirmOrderwill make the order confirm and add this order to the total orders that will be visible to the Admin only - GET
/orderswill fetch all the orders made by the users, only Admin has the access to this Endpoint - POST
/products/addAdmin will be able to add products to the product collection of the database (send product name and the associated price) - POST
/services/addAdmin will be able to add services to the service collection of the database (send the service name and the associated price)
- Node.js
- Express.js
- MongoDB
- Mongoose
- Bcrypt.js
- Crypto
- Cookie-Parser
- JSON Web Tokens (JWT)
- dotenv
- Nodemon (for development)
- Postman (for API testing)
Contributions are welcome! If you find any bugs or have ideas for new features, please open an issue or submit a pull request. Or mail me at aarjitgiri@gmail.com for the new feature discussion.