https://github.com/ldmtam/ecommerce-demo
https://github.com/ldmtam/ecommerce-demo
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/ldmtam/ecommerce-demo
- Owner: ldmtam
- Created: 2022-11-20T07:25:20.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2022-11-20T08:52:35.000Z (over 3 years ago)
- Last Synced: 2025-01-27T23:45:00.545Z (over 1 year ago)
- Language: Go
- Size: 157 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## Sequence diagram
### Create new product

### Get product

### Search product

### Get user activities

## How to run
Firstly, run the following command to run necessary components
```bash
make start-docker
```
Please make sure those ports are available
```
MySQL: 3306
Adminer: 8080
Zookeeper: 2181
Kafka: 9092
Application: 3000
```
Secondly, start the application
```
make run-local
```
When finished, execute the following command to cleanup containers
```
make stop-docker
```
## cURL
### Create new product
```bash
curl --location --request POST 'localhost:3000/api/v1/products' \
--header 'Content-Type: application/json' \
--data-raw '{
"name": "Ultraboost 22 shoes",
"price": 250
}'
```
```bash
curl --location --request POST 'localhost:3000/api/v1/products' \
--header 'Content-Type: application/json' \
--data-raw '{
"name": "Ultraboost 4DFWD shoes",
"price": 300
}'
```
```bash
curl --location --request POST 'localhost:3000/api/v1/products' \
--header 'Content-Type: application/json' \
--data-raw '{
"name": "Stan Smith shoes",
"price": 200
}'
```
### Get product by id
```bash
curl --location --request GET 'localhost:3000/api/v1/products/1' \
--header 'Content-Type: application/json' \
--header 'Cookie: user_id=123' \
--data-raw ''
```
```bash
curl --location --request GET 'localhost:3000/api/v1/products/2' \
--header 'Content-Type: application/json' \
--header 'Cookie: user_id=456' \
--data-raw ''
```
### Seach product by names
```bash
curl --location --request GET 'localhost:3000/api/v1/products/seachByName/boost' \
--header 'Cookie: user_id=123' \
--data-raw ''
```
```bash
curl --location --request GET 'localhost:3000/api/v1/products/seachByName/shoe' \
--header 'Cookie: user_id=123' \
--data-raw ''
```
### Get customer activities
```bash
curl --location --request GET 'localhost:3000/api/v1/customer_activities/123' \
--data-raw ''
```
```bash
curl --location --request GET 'localhost:3000/api/v1/customer_activities/456' \
--data-raw ''
```
```bash
curl --location --request GET 'localhost:3000/api/v1/customer_activities/123/actions/VIEW_PRODUCT' \
--data-raw ''
```