This is a Demo Project for an E-commerce Microservices Application that demonstrates Event-driven architecture using Kafka.
The System consists of 3 microservices as shown in the next figure.
- ms-orders: a restful webservice & an orchestrator for the ordering process.
- ms-stock: management of product inventory.
- ms-payments: for payment processing.
First, we'll need to execute the docker compose file in order to initialize the required containers for our environment.
- mysql
- kafka-cluster-1
- kafka-cluster-2
- zookeeper-1
- zookeeper-2
run this command in the root directory
docker-compose up -d
The generated containers will have their name prefixed with "ecommerce". In order to list generated containers, run this command:
docker ps --filter "name=ecommerce"
Since we are going to utilize 5 Docker containers which should communicate with
each other, we will need to start them on same network.
By default, these containers will be mapped to a generated network named
ecommerce_default with a (Bridge) driver.
To list docker networks, run this command to validate.
docker network ls
You can also run this command to inspect this network.
docker network inspect ecommerce_default
To validate containers' ports
docker port {container_name}
Next, we'll create Docker images for our 3 spring-boot apps.
docker build -t ecommerce-orders -f DockerFile .
docker build -t ecommerce-payments -f DockerFile .
docker build -t ecommerce-stock -f DockerFile .
Finally, you can run those images locally (ms-orders is exposed to port 9091).
Alternately, you can use those images with Kubernetes.
Java (JDK 11) - The Main Programming Language and Framework.
Spring Boot - Software Platform for creating and delivering Web Applications.
Apache Kafka - distributed data streaming platform.
MySQL - A relational database management system [Optional].
Docker - A containerization platform.
Maven - Build tool & Dependency Management.