This project was developed to offer a new perspective at the world of Pokemon.
- Fun Pokedex Api
Required: Docker must be installed
You can run the application using the docker image in my public repository:
docker run -i --rm -p 8080:8080 public.ecr.aws/d8b6h6u8/federicogualdi/pokedex:latest
if there is already the ':latest' image in the local docker registry, remember to delete it to make sure you start the latest version of the project
docker rmi public.ecr.aws/d8b6h6u8/federicogualdi/pokedex:latest
If you fork this project, you can use my script to simplify the build and publishing tasks.
sh build-and-copy.sh $AWS_PROFILE $AWS_ECR_URL $DOCKER_TAG
After clone the repository You can run application in dev mode, that also enables live coding, using:
./mvnw compile quarkus:dev
The application can be packaged using:
./mvnw package -Dquarkus.package.type=uber-jar
The application, packaged as a über-jar, is now runnable using java -jar target/*-runner.jar
.
While the project is running (follow the relevant section in this file) two endpoints are available.
GET pokemon with the property required by the project:
http://localhost:8080/api/v1/pokemon/<POKEMON_NAME>
GET pokemon with the property required by the project and a funny description:
http://localhost:8080/api/v1/pokemon/translated/<POKEMON_NAME>
Swagger-UI is available for testing project endpoints, just go to:
http://localhost:8080/q/swagger-ui
You can also download OpenAPI endpoints specification in json format:
http://localhost:8080/q/openapi
If you want to use Docker and you haven't installed it yet, just go to: https://docs.docker.com/get-docker/
If you want to build and run the project, and you haven't installed java yet, just go to: https://www.java.com/en/download/help/download_options.html
Before a production implementation there are a few things to set up. First, it is necessary to understand how many requests per second we expect, based on that we can proceed differently.
- Improve Code Performance
If we want to increase the maximum number of concurrent requests, we need to refactor PokedexRest to handle the blocking request for event-loops thread.
- Horizontal Scaling
If we want to run multiple instances of 'Pokedex Api' to serve more users - with the same code base - it will be sufficient to deploy several instances of 'Pokedex Api' backed by LoadBalancer that will dispatch requests among all instances. NB: this solution preclude local-cache and requires the use of a distributed-cache such as Redis.
- Add Metrics
Add metrics to analyze execution-time and call-occurrences to track most expensive methods
- Add logs you need
Add logs you need to track program execution and detect new bugs.
- Map all known Exceptions
Add mapper for known useful Exception to improve business logic.
- Swagger-UI and OpenAPI
If the project will not be public, it will be necessary to remove Swagger-UI and OpenAPI from distribution in production.