Built an e-commerce backend system for managing users, products, orders, and more. It uses HonoJS, TypeScript, Prisma, and PostgreSQL to provide a secure and scalable RESTful API.
MIT License
Welcome to the eCommerce Backend System. This application provides a RESTful API for managing users, products, categories, orders, carts, payments, and reviews.
Clone the repository:
git clone https://github.com/venkateshramkumarg/ecommerce_backend.git
cd ecommerce-backend
Install dependencies:
npm install
Set up the database using Prisma:
npx prisma migrate dev
Start the application:
npm start
The application runs on http://localhost:3000/api
. You can use tools like Postman or curl to interact with the API.
Create Admin
POST /api/admin/create/admin/new
Request Body:
{
"user_name": "admin_name",
"password": "password",
"email": "[email protected]"
}
Delete Admin
DELETE /api/admin/delete/admin/:name
Update Admin
PUT /api/admin/update/admin/:name
Request Body:
{
"password": "new_password",
"email": "[email protected]"
}
Create User
POST /api/users/create/user/new
Request Body:
{
"user_name": "user_name",
"password": "password",
"email": "[email protected]"
}
Delete User
DELETE /api/users/delete/user/:name
Update User
PUT /api/users/update/user/:name
Request Body:
{
"password": "new_password",
"email": "[email protected]"
}
Create Product
POST /api/products/addproduct
Request Body:
{
"user_name": "admin_name",
"productName": "product_name",
"description": "product_description",
"price": "product_price",
"stock": "product_stock",
"categoryId": "category_id"
}
Delete Product
DELETE /api/products/deleteproduct/:id
Update Product
PUT /api/products/updateproduct/:id
Request Body:
{
"productName": "new_product_name",
"description": "new_product_description",
"price": "new_product_price",
"stock": "new_product_stock",
"categoryId": "new_category_id"
}
Get All Products
GET /api/products/allproducts
Get Product by ID
GET /api/products/uniqueproduct/:id
Create Category
POST /api/categories/add/category
Request Body:
{
"user_name": "admin_name",
"categoryName": "category_name"
}
Delete Category
DELETE /api/categories/delete/category/:id
Update Category
PUT /api/categories/update/category/:id
Request Body:
{
"categoryName": "new_category_name"
}
Get All Categories
GET /api/categories/allcategories
Get Category by ID
GET /api/categories/uniquecategory/:id
Create Order
POST /api/orders/create/order
Request Body:
{
"user_name": "user_name",
"productIds": ["product_id1", "product_id2"],
"totalAmount": "total_amount",
"shippingAddress": "shipping_address"
}
Delete Order
DELETE /api/orders/delete/order/:id
Update Order
PUT /api/orders/update/order/:id
Request Body:
{
"status": "new_status"
}
Get All Orders
GET /api/orders
Get Order by ID
GET /api/orders/:id
Add to Cart
POST /api/carts/addtocart
Request Body:
{
"user_name": "user_name",
"productId": "product_id",
"quantity": "quantity"
}
Delete from Cart
DELETE /api/carts/removefromcart/:id
Get User's Cart
GET /api/carts/user/:name
Process Payment
POST /api/payments/processpayment
Request Body:
{
"user_name": "user_name",
"orderId": "order_id",
"paymentMethod": "payment_method"
}
Get Payment Details
GET /api/payments/paymentdetails/:paymentid
Add Review
POST /api/reviews/addreview
Request Body:
{
"user_name": "user_name",
"productId": "product_id",
"rating": "rating",
"comment": "comment"
}
Delete Review
DELETE /api/reviews/deletereview/:id
Update Review
PUT /api/reviews/updatereview/:id
Request Body:
{
"rating": "new_rating",
"comment": "new_comment"
}
Get Reviews for Product
GET /api/reviews/product/:id
Create a .env
file in the root directory and add the following environment variables:
DATABASE_URL="your-database-url"