An open API service indexing awesome lists of open source software.

https://github.com/rafaelfgx/microservices

Clean Architecture, Event-Driven Architecture, Clean Code, SOLID Principles, Resilience, Idempotency, Folder-by-Feature, Patterns (Mediator, Result, Strategy, Outbox, Retry, Circuit Breaker), Java, Spring Boot, Kong, Keycloak, Kafka, MongoDB, Redis, Elastic, Kibana, Swagger, Docker.
https://github.com/rafaelfgx/microservices

circuit-breaker-pattern clean-architecture clean-code elasticsearch event-driven-architecture java kafka keycloak kong mediator-pattern mongodb outbox-pattern redis retry-pattern solid spring-boot strategy-pattern

Last synced: about 1 month ago
JSON representation

Clean Architecture, Event-Driven Architecture, Clean Code, SOLID Principles, Resilience, Idempotency, Folder-by-Feature, Patterns (Mediator, Result, Strategy, Outbox, Retry, Circuit Breaker), Java, Spring Boot, Kong, Keycloak, Kafka, MongoDB, Redis, Elastic, Kibana, Swagger, Docker.

Awesome Lists containing this project

README

          

# Microservices

![](https://github.com/rafaelfgx/Microservices/actions/workflows/build.yaml/badge.svg)

![](https://repository-images.githubusercontent.com/984733323/c9dda1b0-6c40-4806-b2fc-2d0f14ec05db)

## Ebooks












## Flow

```mermaid
sequenceDiagram
participant Client
participant AuthService
participant CustomerService
participant ProductService
participant OrderService
participant PaymentService
participant Kafka

Client->>AuthService: POST /auth
AuthService-->>Client: JWT

Client->>CustomerService: POST /customers
CustomerService-->>Client: Customer Created

Client->>ProductService: POST /products
ProductService-->>Client: Product Created

Client->>OrderService: POST /orders
OrderService-->>Client: Order Created
OrderService->>Kafka: OrderEvent Published

Kafka-->>PaymentService: OrderEvent Consumed
Note right of PaymentService: Payment Created

Client->>PaymentService: PUT /payments/order/{orderId}/status/{status}
PaymentService-->>Client: Payment Status Updated
PaymentService->>Kafka: PaymentEvent Published

Kafka-->>OrderService: PaymentEvent Consumed
Note right of OrderService: Status Updated
```

## Architecture, Design and Principles

- [Screaming Architecture](https://blog.cleancoder.com/uncle-bob/2011/09/30/Screaming-Architecture.html)
- [Clean Architecture](https://blog.cleancoder.com/uncle-bob/2012/08/13/the-clean-architecture.html)
- [Event-Driven Architecture](https://martinfowler.com/articles/201701-event-driven.html)
- [Clean Code](https://www.oreilly.com/library/view/clean-code-a/9780136083238)
- [Domain-Driven Design](https://martinfowler.com/bliki/DomainDrivenDesign.html)
- [SOLID Principles](https://www.baeldung.com/solid-principles)
- [Separation of Concerns](https://blog.cleancoder.com/uncle-bob/2012/08/13/the-clean-architecture.html)
- [Common Closure Principle](https://blog.cleancoder.com/uncle-bob/2012/08/13/the-clean-architecture.html)
- [Common Reuse Principle](https://blog.cleancoder.com/uncle-bob/2012/08/13/the-clean-architecture.html)
- [Test Pyramid](https://martinfowler.com/articles/practical-test-pyramid.html)

## Patterns

- [Ambassador Pattern](https://www.geeksforgeeks.org/system-design/ambassador-pattern-in-distributed-systems)
- [Circuit Breaker Pattern](https://www.geeksforgeeks.org/circuit-breaker-vs-retry-pattern)
- [Mediator Pattern](https://refactoring.guru/design-patterns/mediator)
- [Outbox Pattern](https://www.geeksforgeeks.org/outbox-pattern-for-reliable-messaging-system-design)
- [Result Pattern](https://www.codingexplorations.com/blog/mastering-the-result-pattern-in-software-development)
- [Retry Pattern](https://www.geeksforgeeks.org/circuit-breaker-vs-retry-pattern)
- [Strategy Pattern](https://refactoring.guru/design-patterns/strategy)

## Technologies and Tools

- [Java](https://www.oracle.com/java)
- [Spring Boot](https://spring.io/projects/spring-boot)
- [Kong](https://konghq.com)
- [Keycloak](https://www.keycloak.org)
- [OAuth2](https://oauth.net/2)
- [JWT](https://jwt.io)
- [Kafka](https://kafka.apache.org)
- [MongoDB](https://www.mongodb.com)
- [Debezium](https://debezium.io)
- [Redis](https://redis.io/)
- [Elastic](https://www.elastic.co)
- [Swagger](https://swagger.io)
- [Testcontainers](https://testcontainers.com)
- [Docker](https://www.docker.com)
- [Kubernetes](https://kubernetes.io)

## Docker

`docker compose up --detach --build --remove-orphans`

## Starter

Install Into Local Maven Repository: `mvn clean install`

## Tools

- **Kong:** `http://localhost:8002`

- **Keycloak:** `http://localhost:8005` **Username:** `admin` **Password:** `password`

- **Kafka:** `http://localhost:9000`

- **Mongo:** `http://localhost:27018`

- **Redis:** `http://localhost:6380`

- **Logs:** `http://localhost:5601/app/management/data/index_management/data_streams`

- **APM:** `http://localhost:5601/app/apm/services`

## Services

### AuthService

**Localhost:** `http://localhost:8010`

**Docker:** `http://localhost:9010`

**Kong:** `http://localhost:8000/authservice`

| Method | Endpoint | Description |
|:--------------------------------------------------:|-------------|-------------|
| ![GET](https://img.shields.io/badge/GET-green) | /auth | Get |
| ![POST](https://img.shields.io/badge/POST-blue) | /auth | Auth |
| ![POST](https://img.shields.io/badge/POST-blue) | /users | Save |
| ![DELETE](https://img.shields.io/badge/DELETE-red) | /users/{id} | Delete |

### ConfigurationService

**Localhost:** `http://localhost:8015`

**Docker:** `http://localhost:9015`

**Kong:** `http://localhost:8000/configurationservice`

| Method | Endpoint | Description |
|:---------------------------------------------------:|------------------------------------|---------------|
| ![GET](https://img.shields.io/badge/GET-green) | /configurations | List |
| ![GET](https://img.shields.io/badge/GET-green) | /configurations/{id} | Get |
| ![POST](https://img.shields.io/badge/POST-blue) | /configurations | Create |
| ![DELETE](https://img.shields.io/badge/DELETE-red) | /configurations/{id} | Delete |
| ![PATCH](https://img.shields.io/badge/PATCH-purple) | /configurations/{id}/value/{value} | Update Value |
| ![POST](https://img.shields.io/badge/POST-blue) | /configurations/broadcast | Broadcast |

### CustomerService

**Localhost:** `http://localhost:8020`

**Docker:** `http://localhost:9020`

**Kong:** `http://localhost:8000/customerservice`

| Method | Endpoint | Description |
|:--------------------------------------------------:|-----------------|-------------|
| ![GET](https://img.shields.io/badge/GET-green) | /customers | List |
| ![GET](https://img.shields.io/badge/GET-green) | /customers/{id} | Get |
| ![POST](https://img.shields.io/badge/POST-blue) | /customers | Create |
| ![PUT](https://img.shields.io/badge/PUT-orange) | /customers/{id} | Update |
| ![DELETE](https://img.shields.io/badge/DELETE-red) | /customers/{id} | Delete |

### ProductService

**Localhost:** `http://localhost:8025`

**Docker:** `http://localhost:9025`

**Kong:** `http://localhost:8000/productservice`

| Method | Endpoint | Description |
|:--------------------------------------------------:|----------------|-------------|
| ![GET](https://img.shields.io/badge/GET-green) | /products | List |
| ![GET](https://img.shields.io/badge/GET-green) | /products/{id} | Get |
| ![POST](https://img.shields.io/badge/POST-blue) | /products | Create |
| ![PUT](https://img.shields.io/badge/PUT-orange) | /products/{id} | Update |
| ![DELETE](https://img.shields.io/badge/DELETE-red) | /products/{id} | Delete |

### OrderService

**Localhost:** `http://localhost:8030`

**Docker:** `http://localhost:9030`

**Kong:** `http://localhost:8000/orderservice`

| Method | Endpoint | Description |
|:-----------------------------------------------:|--------------|-------------|
| ![GET](https://img.shields.io/badge/GET-green) | /orders | List |
| ![GET](https://img.shields.io/badge/GET-green) | /orders/{id} | Get |
| ![POST](https://img.shields.io/badge/POST-blue) | /orders | Create |

### PaymentService

**Localhost:** `http://localhost:8035`

**Docker:** `http://localhost:9035`

**Kong:** `http://localhost:8000/paymentservice`

| Meth od | Endpoint | Description |
|-----------------------------------------------------|-------------------------------------------|-----------------|
| ![GET](https://img.shields.io/badge/GET-green) | /payments | List |
| ![GET](https://img.shields.io/badge/GET-green) | /payments/{id} | Get |
| ![GET](https://img.shields.io/badge/GET-green) | /payments/order/{orderId} | Get By Order Id |
| ![PATCH](https://img.shields.io/badge/PATCH-purple) | /payments/order/{orderId}/status/{status} | Update Status |

## Examples

### Cache

```java
@Service
public class ProductService {
@Cacheable(value = "products")
public List get() {
return repository.findAll();
}

@Cacheable(value = "products", key = "#id")
public Optional get(final UUID id) {
return repository.findById(id);
}

@CachePut(value = "products", key = "#product.id")
public Product save(final Product product) {
return repository.save(product);
}

@CacheEvict(value = "products", key = "#id")
public void delete(final UUID id) {
repository.deleteById(id);
}

@CacheEvict(value = "products", allEntries = true)
public void delete() {
repository.deleteAll();
}
}
```

### Kafka

```bash
echo KEY:{"Key":"KEY"} | docker exec -i kafka /opt/kafka/bin/kafka-console-producer.sh --bootstrap-server localhost:9094 --topic TOPIC --reader-property parse.key=true --reader-property key.separator=":"
```

```bash
docker exec -i kafka /opt/kafka/bin/kafka-console-consumer.sh --bootstrap-server localhost:9094 --topic TOPIC --from-beginning --formatter-property print.key=true --formatter-property key.separator=:
```