APIGatway microservice

In this microservice, we can develop the microservice and it can be used to API Gateway and establish the routing the client requests of the system.

Create the spring project using Spring STS IDE on creating the spring project add the below dependencies into the project.

Dependencies:

  • Spring Web
  • Spring Netflix Eureka Client Server
  • Spring Routing Gateway
  • Spring Actuator
  • Zipkin Server

Once completed the creation of the project then its file structure looks like the below image:

Open the application.properties file and renamed into the application.yml file and put the below into it.


server:
port: 8090
spring:
application:
name: API-GATEWAY-SERVER
zipkin:
base-url: http://localhost:9411
sleuth:
sampler:
probability: 1.0
cloud:
gateway:
routes:
- id: USER-SERVICE
uri: lb://USER-SERVICE
predicates:
- Path=/auth/**, /users/**, /api/users/**, /
- id: TASK-SERVICE
uri: lb://TASK-SERVICE
predicates:
- Path=/api/tasks/**, /tasks/**
- id: TASK-SUBMISSION
uri: lb://TASK-SUBMISSION
predicates:
- Path=/api/submissions/**, /submissions
default-filters:
- DedupeResponseHeader=Access-Control-Allow-Credentials Access-Control-Allow-Origin
globalcors:
cors-configurations:
'[/**]':
allowedOrigins: "*"
allowedMethods: "*"
allowedHeaders: "*"
eureka:
instance:
prefer-ip-address: true
client:
fetch-registry: true
register-with-eureka: true
service-url:
defaultZone: http://localhost:8085/eureka

In this project there is no changes into the project once configure the application.yml then run the project.

Java




package in.mahesh.tasks;
  
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
  
  
@SpringBootApplication
public class ApiGateWayApplication {
  
    public static void main(String[] args) {
        SpringApplication.run(ApiGateWayApplication.class, args);
    }
  
}


Once complete the project run the project as spring boot application once runs the application successful it will run on the port 8090. Refer the below image for the better understanding.

Now all the microservice are run the single port 8090 after then routing the request using loadbalancer on the API Gateway.

Final Endpoints of the Application:

SI.NO

Method

Endpoints

1

POST

http://localhost:8090/auth/signUp

2

POST

http://localhost:8090/auth/signin

3

GET

http://localhost:8090/api/users/profile

4

GET

http://localhost:8090/api/users/{UserId}

5

GET

http://localhost:8090/users

6

POST

http://localhost:8090/api/tasks

7

GET

http://localhost:8090/api/tasks/{id}

8

GET

http://localhost:8090/api/tasks/user

9

PUT

http://localhost:8090/api/tasks/{id}

10

GET

http://localhost:8082/api/tasks

11

PUT

http://localhost:8090/api/tasks/{id}/user/{userId}/assigned

12

PUT

http://localhost:8090/api/tasks/{id}/complete

13

DELETE

http://localhost:8090/api/tasks/{id}

14

GET

http://localhost:8090/submissions

15

GET

http://localhost:8090/api/submissions/{submissionId}

16

GET

http://localhost:8090/api/submissions

17

GET

http://localhost:8090/api/submissions/task/{taskId}

18

PUT

http://localhost:8090/api/submissions/{id}

Refer the below images for better understanding for working functionalities of the endpoints of the task management system.

Set the token as Global Environment Variables:

SignIn:

SignIn:

SignIn response:

Profile:

GET ALL Users:

Create the Task:

Get ALL Task:

Assign Tasks:

Delete Task:

Submission API:



Create a Backend Task Management System using Microservices

Microservices is an architectural pattern, and its approach can be used in software development where the large applications are built as a collection of loosely coupled and independent deployable services. All microservices communicate with each other using a well-defined API, typically using lightweight protocols using HTTP.

Developing the backend task management system using microservices involves breaking down the smaller functionalities into independent services that can communicate with each other using the eureka server and implementing the API Gateway for routing client requests.

In this project, we can develop the 5 individual microservices and communicate with each other.

  • Task User Service
  • Task Creation Service
  • Task Submission Service
  • Eureka Server configuration
  • API Gateway

TaskUserService:

In this microservice, we can develop the microservice for responsible for managing the user-related operations such as user authentication, authorization and user profile management. In this service we can develop the USER and ADMIN role then admin can be able to create the tasks and approve the tasks of the user.

TaskCreationService:

In this microservice, we can develop the microservice for creating the task and modification of the tasks and assigning the users and one more thing only admin can create the tasks and user unable to create the tasks.

TaskSubmissionService:

In this microservice, we can develop the microservice can be manages the submission of the tasks by users and handles the related functionalities such as validation and processing.

EurekaServerConfiguration:

In this microservice, we can develop the microservice and it can be used to establish the communication of the microservices using eureka server using discovery client and server with communicates with each dynamically.

APIGatway:

In this microservice, we can develop the microservice and it can be used to API Gateway and establish the routing the client requests of the system.

Similar Reads

TaskUserService Microservice:

In this microservice, we can develop the microservice for responsible for managing the user-related operations such as user authentication, authorization and user profile management. In this service we can develop the USER and ADMIN role then admin can able to create the tasks and approve the tasks of the user....

TaskService Microservice

...

TaskSubmissionService Microservice:

...

EurekaServerConfiguration microservice:

...

APIGatway microservice:

...

Contact Us