E-commerce Microservices
Using Docker Compose 🐳
Introduction
This guide will walk you through testing an E-commerce microservices application with Keploy. The app contains three microservices:
- User Service
- Product Service
- Order Service
Each service uses its own MySQL database, and LocalStack SQS is used for messaging. Keploy will help you automatically generate test cases and mocks for these services.
Don’t have Keploy installed yet?
Before running this sample, make sure Keploy is installed on your system.
👉 Go to Installation GuideClone the Sample Application
First, clone the repository that contains the sample app:
git clone https://github.com/keploy/ecommerce_sample_app.git
cd ecommerce_sample_app
Note: You can view the architecture diagram of the application here
Start the Microservices
The app is set up with Docker Compose, making it easy to start all services together. Let’s begin with the User Service.
Capture Test Cases with Keploy
To start capturing API test cases, use the following command:
keploy record -c "docker compose up" --container-name="order_service" --build-delay 40 --path="./order_service" --config-path="./order_service"

Once the services are up, use the Postman collection provided with the app to make some API calls. Keploy will capture these requests and create test cases.
You can see in the logs that Keploy starts recording all the network calls.

Stop the Recording
And once you are done, you can stop the recording and give yourself a pat on the back! With that simple spell, you've conjured up a test case with a mock! Explore the keploy directory and you'll discover your handiwork in tests
directory and mocks.yml
.
# Generated by Keploy (2.10.9)
version: api.keploy.io/v1beta1
kind: Http
name: test-1
spec:
metadata: {}
req:
method: POST
proto_major: 1
proto_minor: 1
url: http://localhost:8080/api/v1/orders
header:
Accept: "*/*"
Accept-Encoding: gzip, deflate, br
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJiMTNjNWJhZS04OTc5LTExZjAtOGM0Ny1iNmM3ZmQwZmY2MmQiLCJ1c2VybmFtZSI6ImFkbWluIiwiaWF0IjoxNzU2OTg0ODQxLCJleHAiOjE3NTk1NzY4NDF9.1OVaOL09j10oB7ahwOKu4mi-ZgnI8ha72MhhaUzKAnE
Connection: keep-alive
Content-Length: "141"
Content-Type: application/json
Host: localhost:8080
Idempotency-Key: 904a1d88-707b-4c14-b7d6-9bd9accea3e7
Postman-Token: ede87575-325e-42f6-83e5-5cd55a9dca7e
User-Agent: PostmanRuntime/7.45.0
body: |-
{
"userId": "afdc272e-d748-4108-a701-59802b93ea29",
"items": [ { "productId": "11111111-1111-4111-8111-111111111111", "quantity": 1 } ]
}
timestamp: 2025-09-04T11:30:48.75326438Z
resp:
status_code: 201
header:
Content-Length: "65"
Content-Type: application/json
Date: Thu, 04 Sep 2025 11:30:48 GMT
Server: Werkzeug/3.1.3 Python/3.11.13
body: |
{"id":"44b0885e-e6e7-4e27-8ffe-97d87791b0b1","status":"PENDING"}
status_message: Created
proto_major: 0
proto_minor: 0
timestamp: 2025-09-04T11:30:50.896837215Z
objects: []
assertions:
noise:
header.Date: []
created: 1756985450
This is how the mocks.yml
looks like:
# Generated by Keploy (2.10.9)
version: api.keploy.io/v1beta1
kind: MySQL
name: mock-0
spec:
metadata:
connID: "0"
requestOperation: HandshakeV10
responseOperation: OK
type: config
requests:
- header:
header:
payload_length: 32
sequence_id: 1
packet_type: SSLRequest
message:
capability_flags: 431991437
max_packet_size: 1073741824
character_set: 255
filler:
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
- header:
header:
payload_length: 301
sequence_id: 2
packet_type: HandshakeResponse41
message:
capability_flags: 431991437
max_packet_size: 1073741824
character_set: 255
filler:
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
username: user
auth_response:
[
209,
97,
143,
83,
102,
55,
162,
43,
183,
166,
61,
254,
156,
7,
42,
33,
137,
77,
61,
133,
242,
40,
130,
251,
227,
181,
38,
254,
127,
21,
114,
230,
]
database: order_db
auth_plugin_name: caching_sha2_password
connection_attributes:
_client_name: libmysql
_client_version: 9.0.0
_connector_license: GPL-2.0
_connector_name: mysql-connector-python
_connector_version: 9.0.0
_os: Linux
_pid: "1090"
_platform: aarch64
_source_host: 44b86cee3ae3
zstdcompressionlevel: 0
- header:
header:
payload_length: 9
sequence_id: 4
packet_type: plain_password
message: cGFzc3dvcmQA
responses:
- header:
header:
payload_length: 74
sequence_id: 0
packet_type: HandshakeV10
message:
protocol_version: 10
server_version: 8.0.43
connection_id: 9
auth_plugin_data:
[
116,
65,
114,
34,
83,
28,
115,
61,
126,
49,
53,
28,
111,
34,
76,
37,
91,
73,
114,
88,
0,
]
filler: 0
capability_flags: 3758096383
character_set: 255
status_flags: 2
auth_plugin_name: caching_sha2_password
- header:
header:
payload_length: 2
sequence_id: 3
packet_type: AuthMoreData
message:
status_tag: 1
data: PerformFullAuthentication
- header:
header:
payload_length: 20
sequence_id: 5
packet_type: OK
message:
header: 0
affected_rows: 0
last_insert_id: 0
status_flags: 16386
warnings: 0
info: "\0\v\x01\t\border_db"
created: 1756985266
reqtimestampmock: 2025-09-04T11:27:46.15043888Z
restimestampmock: 2025-09-04T11:27:46.162389255Z
Check Test Coverage
Keploy also helps you track test coverage for your app.
The overall coverage report by files:

The overall coverage report by functions:

Run the Tests
Now, let’s run the tests that were automatically generated by Keploy. Use this command:
keploy test -c "docker compose up" --containerName="order_service" --delay 30 --path="./order_service" --config-path="./order_service"

The --delay
flag gives the app a short pause (in seconds) before running the tests. After the tests finish, you can inspect the results and tweak the test data in the mocks.yml
or test-x.yml
files.
Note: We have just tested only one microservice (Order Service). You can use the same command to test other microservices by changing the name and config path.
Conclusion 🎉
Well done! You’ve seen how Keploy helps test your microservices without writing any code. You've generated test cases, run tests, and checked coverage—all with just a few commands. Keep experimenting and enhancing your tests to ensure your app’s reliability.