Due today is 4th of May ( btw, May the force be with you) I have created a web app which makes easier for all of us to search star wars data when we need to without going into the Jedi Archives.
It's a simple web app which uses the latest technology in microservices to request and expose data from Star Wars. The technologies used are Java 11, Gradle, Micronaut, ReactJs, Node.Js and JavaScript. It is divided in two main parts:
- FRONT - exposes a web app.
- BACK - expose a microservice in Java.
In order to make it more reliable , scalable and easier to use it's dockerized and automatized to be found in docker hub, gitlab and github:
- In gitlab we will find the CI/CD, along with the Unit tests: https://gitlab.com/Jor-G-ete/StarWars-HyperService.
- In docker hub we will find the builds and the images of the dockers: https://hub.docker.com/repository/docker/frankieem/starwars-hyperservice In gitlab we will find the main project, packages, releases and source code: https://github.com/Jor-G-ete/StarWars-HyperService .
Everyone is invited to contribute!
With one single command we will be able to build the images and run the containers in docker:
docker-compose up --build
The expected output will be:
Just open you favorite browser and type:
localhost:3000
And check how this bad boy is displayed!
Now it's the fun part, play as much as you want 😉 ❤️
Easy peachy: Just use Ctrl + C or docker-compose down. Here it's an image of the expected output:
No prob! Inside each folder ( FRONT and BACK ) you will find a Readme explaining in deep how the services work in stand-alone and how can be invoked separately
Of course! In the folder KUBE there are two files (kube-cluster-FRONT.yml and kube-cluster-BACK.yml) which allows you to run this whole application in a Kubernetes cluster, for those who doesn't know who to do it, these are the steps to follow:
-
Have Kubernetes activated in your docker desktop.
-
Create the namespaces back and front:
kubectl create namespace front && kubctl namespace back
-
Then create the pods:
kubectl apply -f ./KUBE/kube-cluster-BACK.yml -n back kubectl apply -f ./KUBE/kube-cluster-FRONT.yml -n front
-
When they are created, we can check if they are ready and their names with the following command:
kubectl get pods -n front kubectl get pods -n back
-
Finally we can check the logs of the pods with the following command:
kubectl logs BackEndPodName -n back kubectl logs FrontEndPodName -n front
It's deployed and running!! YAAAAAS!!! :happy:
By now only the microservice contains Unit test. This unit test can be improved a lot for now it consist in 4 assertions but could be more and more complex. In case of the Web app, I personally believe it's unnecessary to create unit test to a component which receives data and displays it. In other words it doesn't return nothing. In case a bigger complexity is developed in this component it will be necessary to create unit test. Also in the web app would be a good idea to create a unit test for the Api.js, due to it's the principal file which make request to the microservice.
The very first improvement of this project would be to give support to every one in the star wars universe, and for that it's mandatory to include the format Wookie in app. As simple as adding &format=wookiee in the query we would improve the data returned. Try: https://swapi.dev/api/planets/1/?format=wookiee