A convenient web-application developed using Spring Boot 2.2.0 and H2 database that essentially exposes two REST services - one to register an employee and another to fetch the list of all employees.
While registering an employee, the Gender can be either MALE or FEMALE and Department can be either IT,HR or FINANCE.
The listing of employees API is pageable and can be sorted in ascending order by the first name and last name of employees. By default, it fetches the first page with max 10 records sorted by first name.
Git, JDK 1.8, Maven 3.6.3
- Download the codebase from github repository.
- Change to directory "employee-portal"
- Optional - Change to directory employee-portal/config and update the properties in application-local.properties, if required. Sensitive properties like username/password are jasypt encrypted and mentioned like ENC(XXXXXXXXX).
- Change to "employee-portal" directory and run the following command from terminal:
- mvn clean install (This will also run the test cases). This should ensure a jar file created in employee-portal/target/employee-portal-1.0.0.jar
- Command to execute the jar as background process from terminal:
- java -Dspring.config.location=[PATH-TO_CONFIG-DIRECTORY] -Dspring.profiles.active=local -Djasypt.encryptor.password=[JASYPT-ENCRYPTOR-PASSWORD] -Xmx1024m -jar employee-portal-1.0.0.jar > employee-portal.log &
E.g. PATH-TO-CONFIG-DIRECTORY=/opt/applications/employee-portal/config/
JASYPT-ENCRYPTOR-PASSWORD=samplestring
- java -Dspring.config.location=[PATH-TO_CONFIG-DIRECTORY] -Dspring.profiles.active=local -Djasypt.encryptor.password=[JASYPT-ENCRYPTOR-PASSWORD] -Xmx1024m -jar employee-portal-1.0.0.jar > employee-portal.log &
- Once the server starts in port 8080 (default), we can start testing the REST APIs. By default all APIs are secured with Basic Authentication and username/password is required to be provided while calling them.
- We need to go to the following link from browser to test the registration and listing of all employee REST APIs - http://localhost:8080/swagger-ui.html and provide the Basic Authentication username & password.
- We need to test the actuator endpoints from POSTMAN: E.g. GET http://localhost:8080/actuator/health and provide the Basic Authentication username & password while calling the APIs. Note: Actuator endpoints doesn't show up correctly in Swagger UI and therefore not exposed through the same.
- Dockerizing the application to make it cloud native and scaling instances easily.
- Moving to JWT based authentication instead of simple Basic authentication.
- Configuring nginx for reverse-proxy and load-balancing. Also TLS should be implemented in nginx to secure the communication.
- Configuring logback for logging in console/file and log rotation.