Car Rental Project with Microservice Architecture
It is the intended approach for microservices to migrate to development and production environments
For installation, we need to install the spring cloud config server package in the pom.xml file
application.yml file configuration
- For the config server to work, you need to write the @EnableConfigServer annotation in the configserver application startup class.
- If you want to run it on Docker, you can install it with the docker pull muhammedinan/config-server-image command from https://hub.docker.com/r/muhammedinan/config-server-image
- You can run it as a container on docker with the command docker run -d -p 8888:8888 muhammedinan/config-server-image
By registering our microservice applications to the eureka server, we can communicate with each other from a single point. Thanks to this registration process, the eureka discovery server also undertakes the load balancer task. After the projects are up, our microservices, defined as eureka clients, are connected to the eureka server, and in this way, we monitor and manage features such as network communication and load balancer of our applications from the center.
For installation, we need to install the spring-cloud-starter-netflix-eureka-server package in the pom.xml
In order to run discovery server in development and production environments, we need to configure the config server.
We need to add the spring cloud config client package to the pom.xml file
application.yml file configuration
For the eureka server to work, you need to write the @EnableEurekaServer annotation in the discoveryserver application startup class.
Discovery Server Development application.yml https://github.com/mhmmedinan/configServer/blob/master/eureka-server-dev.yml
Discovery Server Production application.yml https://github.com/mhmmedinan/configServer/blob/master/eureka-server-prod.yml
If you want to run it on Docker, you can install it with the docker pull muhammedinan/discovery-server-image command from https://hub.docker.com/r/muhammedinan/discovery-server-image
You can run it as a container on docker with the command docker run -d -p 9001:9001 muhammedinan/discovery-server-image
The main function of API Gateway is to receive the request from the client and forward it to the appropriate service.
We need to install spring-cloud-starter-gateway package in api gateway pom.xml
We need to add the spring cloud config client package to the pom.xml file
For eureka server connection we need to install spring-cloud-starter-netflix-eureka-client package
We need to install the spring-sleuth-zipkin package to develop the logs on a multi-service system.
To monitor our applications, we need to install the micrometer-registry-prometheus package.
To the apigateway application class for eureka server connection We need to add @EnableDiscoveryClient annotation
We need to add the spring cloud config client package to the pom.xml file
Api Gateway Development application.yml https://github.com/mhmmedinan/configServer/blob/master/api-gateway-dev.yml
Api Gateway Production application.yml https://github.com/mhmmedinan/configServer/blob/master/api-gateway-prod.yml
If you want to run it on Docker, you can install it with the docker pull muhammedinan/api-gateway-image command from https://hub.docker.com/r/muhammedinan/api-gateway-image
You can run it as a container on docker with the command docker run -d -p 9011:9011 muhammedinan/api-gateway-image
Brand, Model, Car we add service.
There is a @ManyToOne relationship between Model and Brand. There is a @OneToMany relationship between Brand and Model.
There is @ManyToOne relationship between Car and Model. There is a @OneToMany relationship between Model and Car.
we are using JpaRepository for data access.
I applied the request response design pattern in this service.
I wrote the global error exception method in this service
I used modelmapper infrastructure in this service
I established asynchronous communication with rentacar service in this service. I used kafka for this.
I have established asynchronous communication between this service and the filterservice that I will be filtering.
To the invertoryservice application class for eureka server connection We need to add @EnableDiscoveryClient annotation
To use global exceptino methods, we add @RestControllerAdvice annotation to the invertoryservice startup class
We create configuration class for kafka usage
We need to add the spring cloud config client package to the pom.xml file
To communicate with eureka server, it is necessary to install the spring-cloud-starter-netflix-eureka-client package.
To use jparepository we need to install spring-boot-starter-data-jpa package
For the message queue system, we need to install the spring-kafka package.
we need to install lombok and postgresql packages
To monitor our applications, we need to install the micrometer-registry-prometheus package.
we install the spring-boot-starter-validaton package to perform validation operations.
we install spring-boot-starter-web package to develop web application
Invertory Service Development application.yml https://github.com/mhmmedinan/configServer/blob/master/invertory-service-dev.yml
Invertory Service Production application.yml https://github.com/mhmmedinan/configServer/blob/master/invertory-service-prod.yml
If you want to run it on Docker, you can install it with the docker pull muhammedinan/invertory-service-api command from https://hub.docker.com/r/muhammedinan/invertory-service-api
You can run it as a container on docker with the command docker run -d -p muhammedinan/invertory-service-api
It is the service used to filter information about the car faster.
we use mongorepository for data access
I used modelmapper infrastructure in this service
I used kafka, a message queue system, to consume requests from the inventoryservice service.
To the filterservice application class for eureka server connection We need to add @EnableDiscoveryClient annotation
We need to add the spring cloud config client package to the pom.xml file
To communicate with eureka server, it is necessary to install the spring-cloud-starter-netflix-eureka-client package.
For the message queue system, we need to install the spring-kafka package.
To monitor our applications, we need to install the micrometer-registry-prometheus package.
I used mongodb as database. for this we need to install spring-boot-starter-data-mongodb package
Filter Service Development application.yml https://github.com/mhmmedinan/configServer/blob/master/filter-service-dev.yml
Filter Service Production application.yml https://github.com/mhmmedinan/configServer/blob/master/filter-service-prod.yml
If you want to run it on Docker, you can install it with the docker pull muhammedinan/filter-service-api command from https://hub.docker.com/r/muhammedinan/filter-service-api
You can run it as a container on docker with the command docker run -d -p muhammedinan/filter-service-api
It is the service where payment transactions are made.
adapter design pattern used
we are using JpaRepository for data access.
I applied the request response design pattern in this service.
I wrote the global error exception method in this service
I used modelmapper infrastructure in this service
To the paymentservice application class for eureka server connection We need to add @EnableDiscoveryClient annotation
To use global exceptino methods, we add @RestControllerAdvice annotation to the paymentservice startup class
We need to add the spring cloud config client package to the pom.xml file
To communicate with eureka server, it is necessary to install the spring-cloud-starter-netflix-eureka-client package.
To use jparepository we need to install spring-boot-starter-data-jpa package
we need to install lombok and postgresql packages
To monitor our applications, we need to install the micrometer-registry-prometheus package.
we install the spring-boot-starter-validaton package to perform validation operations.
we install spring-boot-starter-web package to develop web application
Payment Service Development application.yml https://github.com/mhmmedinan/configServer/blob/master/payment-service-dev.yml
Payment Service Production application.yml https://github.com/mhmmedinan/configServer/blob/master/payment-service-prod.yml
If you want to run it on Docker, you can install it with the docker pull muhammedinan/payment-service-api command from https://hub.docker.com/r/muhammedinan/payment-service-api
You can run it as a container on docker with the command docker run -d -p muhammedinan/payment-service-api
It is the service where rental transactions are made.
We communicate synchronously with the invertoryservice. We use the openfeign client infrastructure of this
We communicate synchronously with the paymentservice. We use the openfeign client infrastructure of this
We use kafka, the message queue system, for asynchronous communication with the inventoryservice.
We use kafka, the message queue system, for asynchronous communication with the invoiceservice.
I applied the request response design pattern in this service.
I wrote the global error exception method in this service
I used modelmapper infrastructure in this service
To the rentalservice application class for eureka server connection We need to add @EnableDiscoveryClient annotation
To use global exceptino methods, we add @RestControllerAdvice annotation to the rentalservice startup class
We create configuration class for kafka usage
We need to add the spring cloud config client package to the pom.xml file
To communicate with eureka server, it is necessary to install the spring-cloud-starter-netflix-eureka-client package.
To use jparepository we need to install spring-boot-starter-data-jpa package
For the message queue system, we need to install the spring-kafka package.
we need to install lombok and postgresql packages
To monitor our applications, we need to install the micrometer-registry-prometheus package.
we install the spring-boot-starter-validaton package to perform validation operations.
we install spring-boot-starter-web package to develop web application
Rental Service Development application.yml https://github.com/mhmmedinan/configServer/blob/master/rental-service-dev.yml
Rental Service Production application.yml https://github.com/mhmmedinan/configServer/blob/master/rental-service-prod.yml
If you want to run it on Docker, you can install it with the docker pull muhammedinan/rental-service-api command from https://hub.docker.com/r/muhammedinan/rental-service-api
You can run it as a container on docker with the command docker run -d -p muhammedinan/rental-service-api
It is a service with invoice transactions.
We communicate synchronously with the invertoryservice. We use the openfeign client infrastructure of this
I applied the request response design pattern in this service.
I wrote the global error exception method in this service
I used modelmapper infrastructure in this service
To the invoiceservice application class for eureka server connection We need to add @EnableDiscoveryClient annotation
To use global exceptino methods, we add @RestControllerAdvice annotation to the invoiceservice startup class
kafka, which is a message queue system, was used for the consumption transactions from the rental service.
We need to add the spring cloud config client package to the pom.xml file
To communicate with eureka server, it is necessary to install the spring-cloud-starter-netflix-eureka-client package.
To use jparepository we need to install spring-boot-starter-data-jpa package
For the message queue system, we need to install the spring-kafka package.
we need to install lombok and postgresql packages
To monitor our applications, we need to install the micrometer-registry-prometheus package.
we install the spring-boot-starter-validaton package to perform validation operations.
we install spring-boot-starter-web package to develop web application
Invoice Service Development application.yml https://github.com/mhmmedinan/configServer/blob/master/invoice-service-dev.yml
Invoice Service Production application.yml https://github.com/mhmmedinan/configServer/blob/master/invoice-service-prod.yml
If you want to run it on Docker, you can install it with the docker pull muhammedinan/invoice-service-api command from https://hub.docker.com/r/muhammedinan/invoice-service-api
You can run it as a container on docker with the command docker run -d -p muhammedinan/invoice-service-api
It is a package in which common operations are used in Microservice architecture.
It contains operations such as caching, logging, exceptions, mapping and we use these operations within services.
I extracted this package from the microservice architecture package and uploaded it to the maven repository.
We can install and use the pom.xml file of the related services
You can install your pom.xml file according to the template you want from the address. https://mvnrepository.com/artifact/io.github.mhmmedinan/common/1.2.8
You can install it by writing the package name in your pom.xml file like this