Saved searches

Use saved searches to filter your results more quickly

Cancel Create saved search Sign up Reseting focus

You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.

rshtishi / payroll Public

payroll is an application that manages employees built with microservice architecture.

Notifications You must be signed in to change notification settings

rshtishi/payroll

This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Go to file

Folders and files

Last commit message Last commit date

Latest commit

History

View all files

Repository files navigation

payroll

payroll is an application that manages employees built with microservice architecture.

Business Case

A company needs web application for managing employees and the departments in which they are organized. The application must be are geared toward reusability and needs to be highly resilient and scalable.

Technology

Architecture

Below is the overall representation of payroll architecture:

Payroll-Architecture

Services

Payroll is composed of services:

Configuration Server

In microservice architecture our business logic is separated in small services. Each service has its configuration files. As the services number continues to grow, the harder becomes to manage each service configuration information. We have solved this problem by centralizing the configuration information of all services in a single repository. We use the Configuration Server service to access the configuration information of the centralized repository. Thus, we are relieved from the chore to write code for accessing the configuration information from the repository. Below is the link where you can find more detailed information about:

Eureka Server

Microservices architecture is made of smaller independent services deployed in different machines. Eureka Server is used from services consumers for discovering the IP address of the service. Every instance of service that starts, will register their IP in Eureka Server. Netflix Ribbon library provides client-slide load balancing. Periodically, the Netflix Ribbon library will ping the Eureka service and refresh its local cache of service locations. When service will call another service it will use the Netflix Ribbon to retrieve the service location of the service that will be called. In the link below you can find more detailed information about:

Gateway Server

In a distributed architecture like a microservices one, you need to implement the security, logging and tracking of the users across multiple service calls. To solve this problems, we need to abstract these cross-cutting concerns into a gateway server that can sit independently and act as a filter and router for all the microservice calls in your application. Your service clients no longer directly call a service. Instead, all calls are routed through the gateway server, which acts as a single Policy Enforcement Point (PEP), and then routed to a final destination. In the link below you can find more detailed information about:

OAuth2 Server

In this example of microservice architecture, we have used the OAUTH2 specification for securing our services. OAuth2 is a token-based security framework that allows a user to authenticate themselves with a third-party authentication server. If the user successfully authenticates, they will be presented with a token that must be sent with every request. The token can then be validated back to the OAuth2 Server. The OAuth2 Server is the intermediary between the application and the services being consumed. The OAuth2 Server allows the user to authenticate themselves without having to pass their user credentials down to every service the application is going to call on behalf of the user. In the link below you can find more detailed information about:

Employee

Employee service implements the business logic for managing employees. The configuration information for Employee is accessed through Configuration Server. Whenever a new instance of the Employee service is started it automatically registers itself in Eureka Server. Thus making the service discoverable by other applications. Employee service is a protected resource. A user needs to include in authentication HTTP header containing OAUTH2 access token to access the service. To enable distributed tracing we have used spring cloud sleuth to link together transactions across multiple services. We have used Zipkin to understand the flow of transactions. We have used Zipkin for visualization of the flow of a transaction across multiple services.

Department

Department service implements the business logic for managing the departments. It implements the same technology as the employee service for separation of configuration from service code, service discovery, security, and distributed tracing. Department Service makes calls to Employee service to retrieve the number of employees for each department. We have used client resiliency software patterns (circuit breakers, fallbacks, and bulkheads) on protecting department service from crashing because the employee service is throwing an error or behaving poorly. We have used Redis to cache the number of employees returned from Employee service. Also, we have implemented event-driven architecture with Kafka. Every time a new employee is created or deleted in employee service it publishes a message to the queue. Department service monitors the queue for any messages published and updates the cache for each message published from Employee service.

WebApp

WebApp is an angular application that provides the user interface for payroll microservice. It provides UI for managing employees, departments. Also, it has a dashboard with a chart displaying the number of employees for each department.

ELK

We are going to use Elasticsearch, Logstash, Kibana (ELK) to aggregate logs from different services. Elasticsearch is the repository where the logs will be stored from multiple services. All services place all the log files in a central directory. We use logstash to send the logs to elasticsearch. Finally, we use kibana interface for visualization Elasticsearch data and navigating through information.

Setup

Prerequisite needed before setup:

Build the project:

- mvn clean install (execute the command in payroll directory)

Start the applications as below:

To access configuration information for a specific service:

Example: localhost:8888/employee/default [Http method: GET] (retrieving the configuration information for the employee service)

To see the information about service instances that are up and where are they deployed:

To access the routes mapped in Gateway Server:

Link: https://localhost:5555/actuator/routes [Http method: GET] (retrieves the routing information)

To authenticate with postman:

Access information about department endpoints:

Access information employee endpoints:

About

payroll is an application that manages employees built with microservice architecture.