The sample is based on a simple API written for a inventory-management system. Following is the high level component diagram.
Following is the interface of the Order service.
type OrderService service object {
*http:Service;
resource function get orders() returns Order[]|error;
resource function get orders/[int id]() returns Order|OrderNotFound|error;
resource function post orders(NewOrder newOrder) returns OrderCreated;
};
- Ballerina Swan Lake Update 8 (or higher)
- Docker
Ballerina
andREST Client
extensions in VSCode
- Checkout the code base and move to the root folder.
- Execute
build-docker-images.sh
script to generate the necessary docker images. - Execute
docker compose up
.
- Setup a MySQL database.
- Execute the script
init.sql
in db-setup. - Build and run the
inventory_svc
project.
bal build inventory_svc;
bal run inventory_svc/target/bin/inventory_svc.jar
- Build and run the
order_svc
project.
bal build order_svc;
bal run order_svc/target/bin/order_svc.jar
- To start the completed setup run
docker compose up
. - To send request open
inventory-mng-request.http
file using VS Code withREST Client
extension.