This project is a proof of concept (PoC) for a microservices-based architecture that uses Kafka for messaging and gRPC for inter-service communication. The project consists of three main services: a producer service, a consumer service, and an analytics service.
- Programming Languages: Go, Python, JavaScript (Node.js)
- Messaging: Apache Kafka
- gRPC: For inter-service communication
- Docker: For containerization
- Environment Variables: Managed using
.envfiles
- Language: Node.js
- Description: Produces messages to a Kafka topic and logs the messages using a gRPC call to the analytics service.
- Dependencies:
kafkajs,@grpc/grpc-js,@grpc/proto-loader,dotenv - File:
producer-service/producer.js
- Language: Go
- Description: Consumes messages from a Kafka topic and logs the messages using a gRPC call to the analytics service.
- Dependencies:
sarama,google.golang.org/grpc - File:
consumer-service/main.go
- Language: Python
- Description: Receives log messages via gRPC and stores them in log files.
- Dependencies:
grpcio,grpcio-tools,python-dotenv - File:
analytics-service/server.py
-
- Docker
- Node.js
- Go
- Python
-
- Create a
.envfile in the root directory with the following content: - add
KAFKA_ADDR=localhost:9092 ANALYTICS_GRPC_ADDR=localhost:8080
- Create a
-
-
For the analytics service (Python):
cd analytics-service make gen -
For the consumer service (Go):
cd consumer-service make gen -
For the producer service (Node.js):
cd producer-service make gen
-
-
-
Setup and start Kafka broker:
if first time setting up (run in root folder):
make setup-kafka
else, run:
make run
-
Start the analytics service:
cd analytics-service make run -
Start the consumer service:
cd consumer-service make run -
Start the producer service::
cd producer-service make run
-
The project follows a microservices architecture with the following components:
-
Producer Service: Sends messages to a Kafka topic and logs them using gRPC.
-
Consumer Service: Consumes messages from the Kafka topic and logs them using gRPC.
-
Analytics Service: Receives log messages via gRPC and stores them in log files.