This is the backend API for an E-commerce application. It provides various endpoints for managing products, categories, user authentication, carts, orders, and more.
Before setting up the project, ensure you have the following dependencies installed:
-
Clone the repository:
git clone https://github.com/yash-levi1896/E-commerce-API.git
-
Navigate to the project directory:
cd E-commerce-API
-
Install dependencies:
npm install
-
Create a .env file in the project root and configure your environment variables:
PORT = any port number MongoURL=your-mongodb-connection-uri Secret_key=your-secret-key
-
Start the server:
npm run server
This backend API provides the following functionality:
- User registration, login and logout with JWT authentication.
- Category management (create and list categories).
- Product management (create, list by category, and retrieve product details).
- Cart management (add products, view cart, update quantities, and remove items).
- Order placement (place an order with products from the cart).
- Order history (fetch order history for authenticated users).
- Order details (retrieve detailed information about a specific order by ID).
- POST /user/register: Register a new user.
- POST /user/login: Authenticate and log in a user.
- GET /user/logout:Logout the user
- GET /category/getcategory: Retrieve a list of all categories.
- POST /category/addcategory: Create a new category.
- GET /product/getproduct/:Id: Retrieve products by category.
- GET /product/getproductbyid/:productId: Retrieve product details by ID.
- GET /product/getproduct: Retrive all the product present.
- POST /product/addproduct: Create a new product.
- POST /cart/addtocart/:productId: Add a product to the cart.
- GET /cart/getcartitem: Retrieve all products in the user's cart.
- PATCH /cart/increasequantity/:itemid : Increase item quantity by one.
- PATCH /cart/decreasequantity/:itemid : Decrease item quantity by one.
- DELETE /cart/removeitem/:itemid: Delete the item from the user's cart.
- POST /order/placeorder: Place order on the basis of the cart items.
- GET /order/orderhistory: Get the order history for the particular user.
- GET /order/orderdetail/:orderid: Get the specific order by orderid.