fworks / algorithms-spring-boot

An implementation of the basics algorithms and data structures on micro services / spring boot applications. (WIP)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Algorithms Microservices Spring Boot Application

CircleCI Build Status codecov

This project is a test bed for microservices applications running on the latest technologies around Java + Spring + Containers.

Keys focus

  1. all microservices
  2. all containerized
  3. latest versions
  4. multiple databases
  5. code coverage > 90%
  6. clear code
  7. build always passing
  8. always a work in progress

Techs

  • Java 11
  • Spring Boot 2.1.0
  • Spring Web (using tomcat at moment, thinking about moving to undertow -because of that)
  • Spring Cloud (eureka, zuul, etc.)
  • Spring DevTool / Actuator (for speeding up the development/restart, etc)
  • Spring Admin (for monitoring)
  • Spring Security / Oauth2 (for authentication)
  • Lombok (for avoiding boilerplate code)
  • Swagger-ui / OpenApi (for exposing the rest services in an easy/user-friendly web page)
  • Log4j2 (for logging)
  • jUnit5 (for testing)
  • Docker (generate docker image for the microservices, run the application, etc)
  • Kubernetes (run in a k8s cluster)
  • MongoDB
  • Mysql
  • Postgresql

Subject

For avoiding having a poor example of data, the subject of the microservices will be around Algorithms and Data Structures. So, the microservices will implement a few of the basic algorithms (search, sorting, common problems, etc.). I'm using the book Algorithms, 4th Edition by Robert Sedgewick and Kevin Wayne, as a base for the algorithms and data structures.

Implementation Notes

  1. I know that most of the implementation of the algorithms could be done in static methods, utility classes, etc. However, I will use spring services just to show how that works.
  2. I could copy and paste the code from the book and use them. But I will be testing myself to create them and code them in a way which they will be easier to understand (code style, comments, etc).

Code Structure / Subprojects

For making things easier, all microservices projects are subproject/modules from this maven project. That will make things easier than have separated git repositories for each one.

I've also added some module prefix for a better understanding:

  • ms- : for microservices
  • lib- : for library/jar
  • server- : for servers
  • app-: for app gateway

Subprojects

app-algorithms > Subproject for the app gateway microservice project.

lib-core > Subproject with few reusable codes for the microservices implementation. Just a library.

lib-data-structures > Subproject with data structures implementation. Just a library.

ms-problems-service > Subproject for the problems microservice.

ms-searching-service > Subproject for the searching microservice.

ms-sorting-service > Subproject for the sorting microservice.

server-admin > Subproject for the server admin.

server-eureka > Subproject for the service discovery - eureka server/service.

See it running

The apps are deployed as containers on the cloud. Please feel free to test it.

Eureka Server: Website

Admin Server: Website

App Algorithms: Website

Searching Service: Website

Sorting Service: Website

Problems Service: Website

Running

Option A)

The faster way, running using the docker images that the last successful build generated.

Step 1) Download the file docker-compose.yml
Step 2) Open a terminal/powershell, go to the directory of the docker-compose.yml file and run:
docker-compose up

It should start up all the services. That is it. Play around and have fun! :)

Option B)

Getting the code and compiling and running it.

Step 1) Clone the code
Step 2) Open a terminal/powershell, go to project root directory and run maven to generate the jars
.\mvnw install docker:build -D maven.test.skip=true

Note: skipping the testing for speeding up

Step 3) Run docker compose to start up all the services
docker-compose up

About

An implementation of the basics algorithms and data structures on micro services / spring boot applications. (WIP)

License:MIT License


Languages

Language:Java 99.5%Language:Dockerfile 0.5%Language:Shell 0.1%