- e-commerce application that handles user authentication, product management, and order processing.
- Microservices Architecture
- Concurrency Control (written in go)
- Clustering and High Availability
- Implement API rate limiting to prevent abuse.
- Message queues for asynchronous communication between microservices.
- Implement caching strategies to improve system performance.
- monitoring and alerting solutions for the microservices.
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.
What you need to install the software:
- Go 1.18+
- Docker and Docker Compose (optional)
- PostgreSQL
Clone the repository:
git clone https://github.com/vigasdeep/eCommerceGo.git
cd eCommerceGorename configure .env and add values appropriately
mv env.example .env Install Go dependencies:
go mod tidyTo run the application locally:
go run .To run using Docker:
docker-compose up --buildAPI Endpoints (Postman Docs here)
The application provides several RESTful endpoints, grouped by functionality:
-
POST
/register: Register a new user.- Request Body Example:
{ "email": "example@example.com", "password": "password123" } - Response Example:
{ "message": "User registered successfully." }
- Request Body Example:
-
POST
/login: Login for existing users.- Request Body Example:
{ "email": "example@example.com", "password": "password123" } - Response Example:
{ "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..." }
- Request Body Example:
-
GET
/api/products: Retrieve all products.- Response Example:
[ { "id": 1, "name": "Widget", "price": 19.99 } ]
- Response Example:
-
POST
/api/products: Create a new product.- Request Body Example:
{ "name": "New Product", "price": 29.99 } - Response Example:
{ "id": 2, "name": "New Product", "price": 29.99 }
- Request Body Example:
-
PUT
/api/products/{id}: Update an existing product.- Request Body Example:
{ "name": "Updated Product", "price": 39.99 } - Response Example:
{ "id": 1, "name": "Updated Product", "price": 39.99 }
- Request Body Example:
-
DELETE
/api/products/{id}: Delete a product.- Response Example:
{ "message": "Product deleted successfully." }
- Response Example:
-
POST
/api/orders: Create a new order.- Request Body Example:
{ "userId": 1, "items": [ { "productId": 1, "quantity": 2 } ] } - Response Example:
{ "id": 1, "userId": 1, "total": 39.98, "status": "Pending", "items": [ { "productId": 1, "quantity": 2, "price": 19.99 } ] }
- Request Body Example:
-
GET
/api/orders/{userId}: Retrieve all orders for a user.- Response Example:
[ { "id": 1, "userId": 1, "total": 39.98, "status": "Pending", "items": [ { "productId": 1, "quantity": 2, "price": 19.99 } ] } ]
- Response Example:
-
POST
/api/orders/{orderId}/items: Add a new item to an order.- Request Body Example:
{ "productId": 2, "quantity": 1 } - Response Example:
{ "orderId": 1, "itemId": 3, "productId": 2, "quantity": 1, "price": 9.99 }
- Request Body Example:
-
PUT
/api/orders/items/{itemId}: Update an existing order item.- Request Body Example:
{ "quantity": 3 } - Response Example:
{ "orderId": 1, "itemId": 3, "productId": 2, "quantity": 3, "price": 9.99 }
- Request Body Example:
-
DELETE
/api/orders/items/{itemId}: Remove an item from an order.- Response Example:
{ "message": "Order item deleted successfully." }
- Response Example:
-
GET
/api/orders/{orderId}/items: Get all items for a specific