Monorepo REST API built with microservices architecture.
- Gateway
- Discovery server
- Config server
- Employee microservice
- Department microservice
- Microservices architecture
- Spring cloud
- Zipkin support (can be run inside a container)
The gateway uses the following dependencies:
- Gateway (to route to API)
- Eureka Discovery Client (REST based service to read config)
- Config Client (Read from config server)
- Spring Boot Actuator (Operation and Expose metrics)
- Zipkin
The discovery server needs:
- Eureka Server (for the discovery server)
- Config Client (for reading from config)
- Spring Boot Actuator
The Config server needs the following dependencies
- Config Sever
The Employee microservice needs the following main dependencies:
- DB driver (MySQL, PostgreSQL, etc)
- Lombok
- Spring Data JPA
- Spring Web
- Config client
- Eureka Discovery Client
- Spring Boot Actuator
- Zipkin
- Spring REST Docs
- Spring Auto REST Docs
The Department microservice needs the following dependencies:
- DB driver (MySQL, PostgreSQL, etc)
- Lombok
- Spring Data JPA
- Spring Web
- Config client
- Eureka Discovery Client
- Spring Boot Actuator
- OpenFeign (added after some coding)
- Zipkin
- Spring REST Docs
- Spring Auto REST Docs
- After creating the gateway, discovery server (Eureka) and config server, add them to the project via File/new/module from existing sources
- Configure the
application.propertiesorapplication.ymlfile. - Create and import the employee microservice
- Config the employee microservice (including JDBC properties to connect to the DB)
- Create entity inside employee class with the annotations:
- @Entity (jpa)
- @Getter (lombok)
- @Setter (lombok)
- @AllArgsConstructor (lombok)
- @NoArgsConstructor (lombok)
- @Builder (lombok)
- @Id (jpa)
- Create repository interface (dao) to extend JPA Repository
- Create the service (interface and implementation)
- Create the REST controller for employee
- Create entity inside employee class with the annotations:
- Create the department microservice (can use employee as a guide)
- Establish the HTTP connection between both microservices by using the REST API of Employee in Department
- Create the client connection in the Department microservice and establish the connection. Can edit the URL so, both microservices communicate using the gateway.
- Move the config properties to the config server.
- Use zipkin to track traces between microservices.
- Use Docker compose yml file to describe the service Zipkin
- Add the
zipkinrelated dependencies to the microservices:- Discovery server
- Employee
- Department
- Execute zipkin after docker desktop.
- Add the dependencies needed for
j-unit 5andrest docsin microservices with endpoints- org.junit.jupiter
- org.springframework.restdocs
- Configure the test for each operation
- Add Dependencies and plugins for
spring auto rest docs. - Write the test for the full CRUD support
