A demonstration of a microservices architecture using Spring Boot, gRPC, Kafka, and monitoring with Prometheus and Grafana.
This project implements a microservices architecture with the following components:
- REST Service: Provides RESTful API endpoints for product management
- gRPC Service: Provides gRPC endpoints for internal service communication
- Kafka: Message broker for event-driven communication between services
- Prometheus: Metrics collection and monitoring
- Grafana: Visualization of metrics and dashboards
The application uses the Outbox Pattern for reliable event publishing and follows domain-driven design principles.
- Java 17
- Spring Boot 3.2.3
- Spring Data JPA
- gRPC
- Apache Kafka
- H2 Database
- Prometheus
- Grafana
- Docker & Docker Compose
- Maven
- Lombok
- OpenTelemetry
The project is organized into multiple modules:
- common: Shared code, models, and utilities
- rest-service: RESTful API service for product management
- grpc-service: gRPC service for internal communication
- docker: Docker configuration files
- Java 17 or higher
- Maven 3.6 or higher
- Docker and Docker Compose
-
Clone the repository:
git clone https://github.com/yourusername/microservices-demo.git cd microservices-demo -
Build the application:
mvn clean package -DskipTests
-
Start the services using Docker Compose:
docker-compose up -d
-
The following services will be available:
- REST API: http://localhost:8082/api/products
- Swagger UI: http://localhost:8082/swagger-ui/index.html
- Prometheus: http://localhost:9091
- Grafana: http://localhost:3000 (login: admin/admin)
- GET /api/products: Get all products
- GET /api/products/{id}: Get a product by ID
- POST /api/products: Create a new product
- PUT /api/products/{id}: Update a product
- DELETE /api/products/{id}: Delete a product
The application includes comprehensive monitoring with Prometheus and Grafana.
- JVM metrics (memory, GC, threads)
- HTTP request metrics
- Database connection metrics
- Kafka metrics
- Custom business metrics
You can set up Grafana dashboards for:
- System monitoring
- Application performance
- Business metrics
The application uses an event-driven architecture with Kafka:
- REST service creates/updates/deletes products
- Events are published to Kafka using the Outbox pattern
- gRPC service consumes events and processes them
- Implement the feature in the appropriate service
- Add tests
- Update documentation
- Submit a pull request
mvn testThis project is licensed under the MIT License - see the LICENSE file for details.
- Spring Boot team for the excellent framework
- The open-source community for all the tools and libraries used in this project