The service is written in Java 15 and based on spring-boot 2 framework. Maven is using for building the project. The service is following to hexagonal architecture and contains 4 modules:
application
: middleman between REST API and domain. Also, it initializes all needed resources and starts the servicedomain
: contains all business logicinfra
: knows about persistence layer and has connections to database and external pokemon api servicedto
: keeps dto objects needed for api (having them separately later we can create a java client for the service)
Note 1: The service uses an embedded database for storing data hence it is not necessary to install something else.
Note 2: During the startup the service will initialize pokemons by requesting external pokemon api. To speedup the process it requests first 100 pokemons. In case if all data needed when simply set the param pokemons-api.initializer.first-batch-only
to false
.
- Clone or download the repository
- Open the project in your favorite IDE (e.q. Intellij Idea)
- Run spring-boot
Application
class ofapplication
module - The service will be running on the port
8080
- Clone or download the repository
- Go to the root of the project
- Build the project using
mvn clean package
- Start the service:
java -jar application/target/application-1.0-SNAPSHOT.jar
- The service will be running on the port
8080
- Clone or download the repository
- Go to the root of the project
- Build the project using
mvn clean package
- Run the app using the command:
docker-compose up --build
- The service will be running on the port
8080
- Using swagger. Open swagger ui:
http://localhost:8080/swagger-ui.html
. Here you can see all available endpoints and models and try to execute examples - Using browser/curl. Here are available endpoints to get pokemons (Note: it's possible to request different size or/and version by passing the parameters
?size=5&version=red
):http://localhost:8080/v1/pokemons/most-experienced
- to get 5 most experienced red pokemonshttp://localhost:8080/v1/pokemons/most-heaviest
- to get 5 most heaviest red pokemonshttp://localhost:8080/v1/pokemons/most-highest
- to get 5 most highest red pokemons
- Pokemon versions stored in DB as separated string but it's not flexible. For example, it would be tricky to filter if we want to find entities by multiple versions. To fix that create a separate table for versions to normalize the structure
- Handle possible errors, e.q. external api errors, json mapping errors
- Add validation, e.q. requested size must be positive