- Usecases
- Architecture
- What's Next?
- Setup
- Flows Ping
- Flows Create Account and Products
- Flows Add Product to Cart and Move to Order #1
- Flows Add Product to Cart and Move to Order #2
Reference: http://www.itk.ilstu.edu/faculty/bllim/wwwdev/sample1.htm
- Visit a site
- Login
- Search for Products
- Check Availability of Products
- Add Products to Shopping Cart
- Edit Products in the Shopping Cart
- remove Products from the Shopping Cart
- heck out the Shopping Cart
- Check Order Status
- Browse Order History
- Display Product Details
- Logout
- Leave a site
- Split Authentication from Account Service
- Handle Basic Auth
- Handle Oauth like Google, FB, Twitter, etc.
- Handle Token Auth
- Handle Limit Failed Auth Attempts
- Edit (Change, Delete) Account Info
- Reporting Order, Shipping, Payment via Email
- Secure Personally Identifiable Information (PII) like email, phone, address, etc.
- Use synchronous encryption for internal service purposes
- Use asynchronous encryption for external purposes (client, user, partner, etc.)
- Maintain (Add, Change, Delete) Inventory
- Create Product Review
- Create Product Discussion
- Split Cart from Product Service
- Focus on Carting and Wishlist
- View Order Summary & Detail
- Change Order ID into Invoice Number
- View History Date of Status Changes (Order, Payment, Shipping)
- Split Payment from Order Service
- Focus Handle Third-party Payment API like BCA, BRI, BNI, Gopay, Ovo, etc.
- Split Shipping from Order Service
- Focus Handle Third-party Shipping API like JNE, JNT, Gojek, Grab, etc.
1. Install Go Language
2. Install Docker + Docker Compose (Docker Desktop)
3. Running Docker Desktop until the Engine Running (Green Highlight)
4. Open CLI, change to project directory, and run :
$ docker-compose up -d --build
GET /ping
curl --location --request GET 'localhost:8081/ping'
{
"message": "Hello World from Account Service"
}
GET /ping
curl --location --request GET 'localhost:8082/ping'
{
"message": "Hello World from Product Service"
}
GET /ping
curl --location --request GET 'localhost:8083/ping'
{
"message": "Hello World from Order Service"
}
POST /
curl --location --request POST 'localhost:8081/' \
--header 'Content-Type: application/json' \
--data-raw '{
"email": "user@test.com",
"password": "password",
"phone": "08123456678",
"address": "JL. Thamrin"
}'
{
"id": 1,
"email": "user@test.com",
"phone": "08123456678",
"address": "JL. Thamrin"
}
POST /
curl --location --request POST 'localhost:8082/' \
--header 'Content-Type: application/json' \
--data-raw '{
"name": "Product Test #1",
"stock": 100,
"price": 1000
}'
{
"id": 1,
"name": "Product Test #1",
"stock": 100,
"price": 1000
}
POST /
curl --location --request POST 'localhost:8082/' \
--header 'Content-Type: application/json' \
--data-raw '{
"name": "Product Test #2",
"stock": 200,
"price": 2000
}'
{
"id": 2,
"name": "Product Test #2",
"stock": 200,
"price": 2000
}
POST /
curl --location --request POST 'localhost:8082/' \
--header 'Content-Type: application/json' \
--data-raw '{
"name": "Product Test #3",
"stock": 300,
"price": 3000
}'
{
"id": 3,
"name": "Product Test #3",
"stock": 300,
"price": 3000
}
POST /
curl --location --request POST 'localhost:8082/' \
--header 'Content-Type: application/json' \
--data-raw '{
"name": "Product Test #4",
"stock": 400,
"price": 4000
}'
{
"id": 4,
"name": "Product Test #4",
"stock": 400,
"price": 4000
}
POST /
curl --location --request POST 'localhost:8082/' \
--header 'Content-Type: application/json' \
--data-raw '{
"name": "Product Test #5",
"stock": 500,
"price": 5000
}'
{
"id": 5,
"name": "Product Test #5",
"stock": 500,
"price": 5000
}
GET /
curl --location --request GET 'localhost:8082/'
[
{
"id": 1,
"name": "Product Test #1",
"stock": 100,
"price": 1000
},
{
"id": 2,
"name": "Product Test #2",
"stock": 200,
"price": 2000
},
{
"id": 3,
"name": "Product Test #3",
"stock": 300,
"price": 3000
},
{
"id": 4,
"name": "Product Test #4",
"stock": 400,
"price": 4000
},
{
"id": 5,
"name": "Product Test #5",
"stock": 500,
"price": 5000
}
]
POST /login
curl --location --request POST 'localhost:8081/login' \
--header 'Content-Type: application/json' \
--data-raw '{
"email": "user@test.com",
"password": "password"
}'
{
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJBQ0NPVU5UX1NFUlZJQ0VfSVNTVUVSIiwiZXhwIjoxNjcyNTcyMTYwLCJpZCI6MSwiZW1haWwiOiJ1c2VyQHRlc3QuY29tIiwicGhvbmUiOiIwODEyMzQ1NjY3OCIsImFkZHJlc3MiOiJKTC4gVGhhbXJpbiJ9.MV4j709mXainNlGf4shbfmt07tGBsKisJ3TQtgzjlTg"
}
POST /cart
curl --location --request POST 'localhost:8082/cart' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer <token>' \
--data-raw '{
"product_id": 1,
"quantity": 10
}'
{
"id": 1,
"account_id": 1,
"product_id": 1,
"quantity": 10
}
POST /cart
curl --location --request POST 'localhost:8082/cart' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer <token>' \
--data-raw '{
"product_id": 2,
"quantity": 20
}'
{
"id": 2,
"account_id": 1,
"product_id": 2,
"quantity": 20
}
POST /cart
curl --location --request POST 'localhost:8082/cart' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer <token>' \
--data-raw '{
"product_id": 3,
"quantity": 30
}'
{
"id": 3,
"account_id": 1,
"product_id": 3,
"quantity": 30
}
POST /
curl --location --request POST 'localhost:8083/' \
--header 'Authorization: Bearer <token>'
{
"invoice": "7c338f43-6030-4e4f-a934-29592cba7f7d",
"status": "PENDING",
"payment_status": "AWAITING PAYMENT",
"shipping_status": "AWAITING SHIPPING"
}
GET /<income>
curl --location --request GET 'localhost:8083/<invoice>' \
--header 'Authorization: Bearer <token>'
{
"invoice": "7c338f43-6030-4e4f-a934-29592cba7f7d",
"status": "PENDING",
"payment_status": "AWAITING PAYMENT",
"shipping_status": "AWAITING SHIPPING",
"list_order_product": [
{
"id": 1,
"product_id": 1,
"product_name": "Product Test #1",
"quantity": 10,
"price": 1000
},
{
"id": 2,
"product_id": 2,
"product_name": "Product Test #2",
"quantity": 20,
"price": 2000
},
{
"id": 3,
"product_id": 3,
"product_name": "Product Test #3",
"quantity": 30,
"price": 3000
}
]
}
GET /
curl --location --request GET 'localhost:8082/'
[
{
"id": 1,
"name": "Product Test #1",
"stock": 90,
"price": 1000
},
{
"id": 2,
"name": "Product Test #2",
"stock": 180,
"price": 2000
},
{
"id": 3,
"name": "Product Test #3",
"stock": 270,
"price": 3000
},
{
"id": 4,
"name": "Product Test #4",
"stock": 400,
"price": 4000
},
{
"id": 5,
"name": "Product Test #5",
"stock": 500,
"price": 5000
}
]
POST /cart
curl --location --request POST 'localhost:8082/cart' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer <token>' \
--data-raw '{
"product_id": 4,
"quantity": 40
}'
{
"id": 4,
"account_id": 1,
"product_id": 4,
"quantity": 40
}
POST /cart
curl --location --request POST 'localhost:8082/cart' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer <token>' \
--data-raw '{
"product_id": 5,
"quantity": 50
}'
{
"id": 5,
"account_id": 1,
"product_id": 5,
"quantity": 50
}
POST /
curl --location --request POST 'localhost:8083/' \
--header 'Authorization: Bearer <token>'
{
"invoice": "277a73ac-d8c8-486d-ba1e-8e46562c6e00",
"status": "PENDING",
"payment_status": "AWAITING PAYMENT",
"shipping_status": "AWAITING SHIPPING"
}
GET /<income>
curl --location --request GET 'localhost:8083/<invoice>' \
--header 'Authorization: Bearer <token>'
{
"invoice": "277a73ac-d8c8-486d-ba1e-8e46562c6e00",
"status": "PENDING",
"payment_status": "AWAITING PAYMENT",
"shipping_status": "AWAITING SHIPPING",
"list_order_product": [
{
"id": 4,
"product_id": 4,
"product_name": "Product Test #4",
"quantity": 40,
"price": 4000
},
{
"id": 5,
"product_id": 5,
"product_name": "Product Test #5",
"quantity": 50,
"price": 5000
}
]
}
GET /
curl --location --request GET 'localhost:8083/' \
--header 'Authorization: Bearer <token>'
[
{
"invoice": "7c338f43-6030-4e4f-a934-29592cba7f7d",
"status": "PENDING",
"payment_status": "AWAITING PAYMENT",
"shipping_status": "AWAITING SHIPPING"
},
{
"invoice": "277a73ac-d8c8-486d-ba1e-8e46562c6e00",
"status": "PENDING",
"payment_status": "AWAITING PAYMENT",
"shipping_status": "AWAITING SHIPPING"
}
]
GET /
curl --location --request GET 'localhost:8082/'
[
{
"id": 1,
"name": "Product Test #1",
"stock": 90,
"price": 1000
},
{
"id": 2,
"name": "Product Test #2",
"stock": 180,
"price": 2000
},
{
"id": 3,
"name": "Product Test #3",
"stock": 270,
"price": 3000
},
{
"id": 4,
"name": "Product Test #4",
"stock": 360,
"price": 4000
},
{
"id": 5,
"name": "Product Test #5",
"stock": 450,
"price": 5000
}
]