Method: POST
Content Type: application/json
Request Payload
{
"clientID": "string",
"productID": "string",
"quantity": "integer"
}
Response
{
"status": "string",
"error": "string"
}
Method: POST
Content Type: application/json
Request Payload
{
"clientID": "string"
}
Response
{
"status": "string",
"error": "string"
}
+------------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+------------+--------------+------+-----+---------+-------+
| client_id | varchar(100) | YES | | NULL | |
| product_id | varchar(100) | YES | | NULL | |
| quantity | int | YES | | NULL | |
+------------+--------------+------+-----+---------+-------+
+--------------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+--------------+--------------+------+-----+---------+-------+
| product_id | varchar(100) | YES | | NULL | |
| product_name | varchar(100) | YES | | NULL | |
| quantity | int | YES | | NULL | |
+--------------+--------------+------+-----+---------+-------+
+------------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+------------+--------------+------+-----+---------+-------+
| reserve_id | varchar(100) | YES | | NULL | |
| product_id | varchar(100) | YES | | NULL | |
| quantity | int | YES | | NULL | |
+------------+--------------+------+-----+---------+-------+
The project has 4 micro-services:
Developed in NodeJS. It is exposed at port 5003 and has two endpoints:
/addToCart
/checkOutCart
The swagger documentation has the specification. Accessed using http://localhost:5003/documentation (need to start up the containers first)
Developed in Golang. It is a worker solely responsible to talk to CartDB.
The worker gets job from RMQ channel and performas follwoing categories of task:
-
Add Item To Cart: Adds an item to cart and responds to the API with the status
-
Checkout Cart: Checks out all the items in a cart and moves to payment gateway
Developed in Golang and exposed as a gRPC service. It is solely responsible to talk to InventoryDB.
It performs a series of important operations:
-
Checks Item Quantity in Inventory
-
Reserves Items for Check out
-
Commits Reserved Items after successful Checkout: This operation depicts the following taks in order -
- Update the Inventory Table to reduce the available quantity
- Remove the reserved token from the reservation table
-
Rollback Reserved Items after unsuccessfuk CheckOut
Developed in Golang. It is a worker which gets the job pushed by only Cart manager.
On getting a job to check out the list of items,it performs the following taks:
- Asks Invenory Manager to Reseve the items
- Starts payment processing
- If successful asks Inventory Manager to commit the reservations
- If failed asks Inventory Manager to rollback the reservations
- Microservices - Mentoioned above
- RabbitMQ - Queuing mechanisms for the workers so that they can scale easily
- MySQL - Backend DB to hold the data
- Install Docker and Docker-Compose in the system
- Make sure you have bash shell
- Run setup.sh
- Certain workers can still fail after starting. Need to get them separately. Pitfalls discussed below.
- Limited testing done. So bugs are expected.
- No Unit tests available because of limited time.
- Docker containers need to be set properly with some time out to get RMQ up first.
- No Redis setup to improve the performance of the system using caching.
- No Load balancer added to scale up the API or the gRPC service.
- RMQ channels can be better named and typed.