The idea behind this project is to PoC an integrated microservice architecture using common patterns:
- Database per Service pattern
- Containerized (Docker and Docker Compose)
- API Gateway/Façade pattern/API composition (implemented with Spring Zuul)
- Publish/Subscribe pattern (based on events, implemented with Kafka)
- CQRS pattern
- Service Discovery (implemented with Eureka)
- Observability (Spring Boot Admin/Actuator)
This REST API is responsible for the CRUD on two entities:
- /consents: to expose with GDPR consents
- /treatments: to expose the treatments linked to a consent (i.e. newsletter, marketing campaigns)
The reference used to identity a user is coming from the user-service.
This API also broadcasts events for consent creation, i.e.
{
"type": "CREATE",
"consent": {
"id": 4,
"personId": "1",
"treatment": {
"id": 1
},
"optin": false
}
}This REST API is responsible for the CRUD on a user database:
- /users: to expose the users
This API also broadcasts events for user creation, i.e.
{
"type": "CREATE",
"user": {
"id": 1,
"firstname": "Thomas",
"lastname": "K"
}
}... and deletion:
{
"type": "DELETE",
"user": {
"id": 1
}
}This API doesn't have a dedicated datastore but implement a "facade pattern" to expose the routes from gdpr-service and user-service:
- /consents
- /treatments
- /users
Moreover, it implements a dedicated route (/consents-full) to enrich the consents with the username (enrichment/aggregatation pattern)
This app subscribes to the topics "consent" and "user" to replicate locally the objects and expose an aggregated route:
- /consents
This app implements a service registry thanks to Eureka. The services periodically register with this app in order to maintain an up-to-date service registry.
This app exposes an admin console (Spring Boot Admin) in order to observe the microservices (metrics, configuration etc) The services are discovered thanks to Eureka
First step is to build the services:
mvn clean package
Remove the potential previous created containers:
sudo docker-compose rm -f
And then build & launch the docker-compose:
sudo docker-compose up --build
