This repository contains the backend code for an e-commerce application, including user authentication, product management, cart functionality, and more. The APIs are documented below, covering various aspects of the system, such as cart management, address handling, and user authentication.
Before you start, ensure you have the following installed on your machine:
-
Clone the repository:
git clone https://github.com/jash707/ecommerce-go.git
-
Navigate to the project directory:
cd ecommerce-go
-
Install the required Go modules:
go mod tidy
-
Run the application:
go run main.go
-
The server will start on
https://localhost:8000
.
-
Add to Cart
GET /addtocart?productID=<productID>&userID=<userID>
Headers:
token
: JWT token for authentication
-
Remove from Cart
GET /removeitem?productID=<productID>&userID=<userID>
Headers:
token
: JWT token for authentication
-
List Cart Items
GET /listcart?userID=<userID>
Headers:
token
: JWT token for authentication
-
Checkout Cart
GET /cartcheckout?userID=<userID>
Headers:
token
: JWT token for authentication
-
Add Address
POST /addaddress?userID=<userID>
Headers:
token
: JWT token for authentication
Body:
{ "house_name": "white house", "street_name": "white street", "city_name": "washington", "pin_code": "332423432" }
Note: The Address array is limited to two values: Home and Work addresses.
- The first address added will be saved as the Home address.
- The second address added will be saved as the Work address.
- Adding more than two addresses is not acceptable.
-
Edit Home Address
PUT /edithomeaddress?userID=<userID>
Headers:
token
: JWT token for authentication
Body:
{ "house_name": "aangan", "street_name": "citylight", "city_name": "surat", "pin_code": "395007" }
-
Edit Work Address
PUT /editworkaddress?userID=<userID>
Headers:
token
: JWT token for authentication
Body:
{ "house_name": "white house", "street_name": "white street", "city_name": "washington", "pin_code": "332423432" }
-
Delete Addresses
PUT /deleteaddresses?userID=<userID>
Headers:
token
: JWT token for authentication
-
Sign Up
POST /users/signup
Body:
{ "first_name": "Tony", "last_name": "Stark", "email": "[email protected]", "password": "tony1234", "phone": "+918569745600" }
-
Login
POST /users/login
Body:
{ "email": "[email protected]", "password": "tony1234" }
-
Add Product
POST /admin/addproduct
Body:
{ "product_name": "Hp pavillion", "price": 4500, "rating": 7, "image": "hp.jpg" }
-
View Products
GET /users/productview
-
Search Product by Query
GET /users/search?name=<query>