Skip to content

Faruktulumcu/event-driven-system-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

8 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Microservices Event-Driven System with Spring Boot, RabbitMQ, Kafka, PostgreSQL, Docker, and Kubernetes

This project demonstrates a simple event-driven microservices architecture where a User Service triggers events upon user registration. The events are consumed by the Email Service (via RabbitMQ) and the Analytics Service (via Kafka). The whole system is containerized using Docker and deployed with Kubernetes.


πŸ“Œ Architecture Overview

  1. User Service (Spring Boot):

    • Handles user registration and stores user data in PostgreSQL.
    • Publishes events to RabbitMQ upon successful registration.
  2. Email Service (Spring Boot):

    • Listens to RabbitMQ for user registration events.
    • Sends a welcome email upon receiving an event.
  3. Analytics Service (Spring Boot):

    • Listens to Kafka for user registration events.
    • Logs or processes the event data for analytical purposes.
  4. Infrastructure:

    • RabbitMQ: For handling messaging between User Service and Email Service.
    • Kafka: For streaming messages to the Analytics Service.
    • PostgreSQL: For persisting user data.
    • Docker & Kubernetes: For containerization and orchestration.

πŸ’‘ Tech Stack

  • Java 17
  • Spring Boot (3.x)
  • Spring Data JPA
  • Spring AMQP (RabbitMQ)
  • Spring Kafka
  • PostgreSQL
  • Docker
  • Kubernetes (Minikube / Kind / Local Kubernetes Cluster)

πŸ“‚ Project Structure

β”œβ”€β”€ user-service
β”œβ”€β”€ email-service
β”œβ”€β”€ analytics-service
β”œβ”€β”€ docker-compose.yml
β”œβ”€β”€ k8s
β”‚   β”œβ”€β”€ user-service.yaml
β”‚   β”œβ”€β”€ email-service.yaml
β”‚   β”œβ”€β”€ analytics-service.yaml
β”‚   β”œβ”€β”€ rabbitmq.yaml
β”‚   β”œβ”€β”€ kafka.yaml
β”‚   β”œβ”€β”€ zookeeper.yaml
β”‚   └── postgresql.yaml
└── README.md

πŸš€ Getting Started

Prerequisites

  • Docker & Docker Compose
  • Kubernetes (Minikube / Kind / Local Cluster)
  • Java 17 & Maven

Running Locally (Docker Compose)

  1. Build the services:
mvn clean install -DskipTests
  1. Start all services:
docker-compose up --build

πŸ“¦ Deployment to Kubernetes

  1. Create Kubernetes resources:
kubectl apply -f k8s/
  1. Verify pods are running:
kubectl get pods

πŸ” Testing

  • Register a user by making a POST request to the User Service endpoint:
POST /api/v1/users/register
Content-Type: application/json
{
    "username": "johndoe",
    "email": "johndoe@example.com",
    "password": "password123"
}
  • Check the logs of the Email Service and Analytics Service to confirm they received and processed the event.

πŸ“š To Do

  • Implement User Service (Spring Boot, PostgreSQL, RabbitMQ).
  • Implement Email Service (Spring Boot, RabbitMQ).
  • Implement Analytics Service (Spring Boot, Kafka).
  • Set up Docker Compose and Kubernetes configuration.
  • Test the complete workflow.

About

An example of event driven desgined system

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors