Getting Started

Employee Management System

This is a system meant to illustrate the microservice architecture under the Employee Management System.

Currently the microservices comprises of :

  • Employee Service for Employee CRUD Operations. You can find it here.

The services to be added later :

  • API Gateway Service
  • Authentication Service to handle authentication and authorization operations
  • Notification Service for sending Emails and SMS
  • Reports Engine Service for generating reports
  • Calendar Service for scheduling and creating calendar events

This is an Employee Management REST Micro Service created using:

  • Spring Webflux Application (Spring Reactive) - Flux vs Mono
  • Spring Data Reactive Mongodb
  • Mongodb Database

It is an improvement on the previous project.In this new project, I have added service discovery using Spring Cloud Eureka.

This employee service is part of collection of micro-services (Notification Service, Calendar Service, Gateway Service, Administration Service, Configuration Service, Report Service etc) that are meant to communicate with each other. Using service discovery, these services are able to communicate to each other without having to hard-code their names and port numbers. With Netflix Eureka, a client( a microservice) is able to fetch a list of all connected services from a service registry. From there, the microservice makes requests to the other connected services.You can read more on this here.

This project implements the following concepts:

Reactive programming is a design paradigm that allows development of event-driven web applications which are responsiive and scalable. It is based on Reactive Streams which handles streams of data which are asynchronous.

Why Spring Webflux? Well, reactive programming is achieved in Spring Webflux through the use of Mono and Flux classes which represent a single or multiple values over time respectively.

Reactive programming helps to improve application performance by reducing thread blocking and minimal resource usage. For example:

public Flux<EmployeeDto> findAll() { return employeeRepository .findAll() .map(EmployeeMapper::mapToEmployeeDto) .switchIfEmpty(Flux.empty()); }

This is a sample service method within this project that fetches all employees from our database.Here we are returning a Flux of Employees from Employees repository. This means that the method will stream employees as they become available rather than waiting for all employee data to be loaded before returning them.

Run Application

Prerequisite: Ensure you have Mongodb installed on your machine. Can change the database and port details for your Mongodb instance in application.properties file located within the resources folder.

Instructions: Clone this project and run the application either using Eclipse or Intellij, the default port has been set to port 8081

Sample Endpoints:

  1. Searching an employee by Name:

    img.png

  2. Find an employee by their Id:

    Image showing display employee by id

Note: For my tests, I have generated test data using Instancio Library as shown below: img_2.png

Kindly import the postman collection to view and test the apis using:

\employee-mgt-micro-services\employee-service\src\main\resources\Employee Management System.postman_collection.json

Reference Documentation

For further reference, please consider the following sections:

Guides

The following guides illustrate how to use some features concretely: