This project demonstrates a scalable microservices-based architecture for an order processing system using Apache Kafka. Each microservice interacts by writing to and reading from Kafka topics, simulating the communication flow in a distributed system.
The architecture consists of the following components:
- Frontend: Sends order details to the Orders Backend.However, in this project we will simulate the generation of order.
- Orders Backend: Writes order details to the
order_details
Kafka topic. - Kafka Pipeline: Acts as the central message broker between services, facilitating communication through topics.
- Transactions Backend: Consumes messages from the
order_details
topic, simulates mutating payment processing behavior, and writes processed messages to theorder_confirmed
topic. - Email Notification Service: Reads messages from the
order_confirmed
topic to simulate sending email notifications. - Analytics Backend: Reads messages from the
order_details
topic to simulate producing analytics on the orders.
order_details
: Stores raw order details from the Orders Backend.order_confirmed
: Stores processed and confirmed order details from the Transactions Backend.
- The Orders Backend receives order details from the Frontend and writes them to the
order_details
Kafka topic. - The Transactions Backend reads messages from the
order_details
topic, simulates payment processing behavior, and writes processed data to theorder_confirmed
Kafka topic. - The Email Notification Service reads confirmed orders from the
order_confirmed
topic and simulates sending email notifications. - The Analytics Backend reads raw orders from the
order_details
topic and simulates generating analytics data.
- Docker and Docker Compose installed.
- Python 3.9 or later with the required libraries (see
requirements.txt
). - Apache Kafka setup using Docker Compose.
-
Clone this repository:
git clone "https://github.com/nomannaq/scalable-microservices-apache-kafka" cd scalable-microservices-apache-kafka
-
Start Kafka and Zookeeper services using Docker Compose:
docker-compose up -d zookeeper kafka
-
Build and run each microservice using Docker Compose:
docker-compose up --build
-
Monitor the logs of each service to see the message flow between Kafka topics:
docker logs -f <service-name>
.
├── analytics_backend
│ ├── analytics_backend.py
├── email_notification_service
│ ├── emailconsumer.py
├── orders_backend
│ ├── orderbackend.py
├── transactions_backend
│ ├── transaction.py
├── docker-compose.yml
└── README.md
- Implement actual business logic for each microservice instead of only reading/writing to Kafka topics.
- Add a proper frontend for user interaction.
- Introduce a database for persistent storage.
- Deploy the microservices to a Kubernetes cluster for improved scalability and orchestration.