Coder Social home page Coder Social logo

pokemons's Introduction

Pokemons service

Structure of the service

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 service
  • domain: contains all business logic
  • infra: knows about persistence layer and has connections to database and external pokemon api service
  • dto: keeps dto objects needed for api (having them separately later we can create a java client for the service)

How to build and run 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.

Using an IDE

  1. Clone or download the repository
  2. Open the project in your favorite IDE (e.q. Intellij Idea)
  3. Run spring-boot Application class of application module
  4. The service will be running on the port 8080

Using command line

  1. Clone or download the repository
  2. Go to the root of the project
  3. Build the project using mvn clean package
  4. Start the service: java -jar application/target/application-1.0-SNAPSHOT.jar
  5. The service will be running on the port 8080

Using Docker

  1. Clone or download the repository
  2. Go to the root of the project
  3. Build the project using mvn clean package
  4. Run the app using the command: docker-compose up --build
  5. The service will be running on the port 8080

How to use the service

  1. 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
  2. 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 pokemons
    • http://localhost:8080/v1/pokemons/most-heaviest - to get 5 most heaviest red pokemons
    • http://localhost:8080/v1/pokemons/most-highest - to get 5 most highest red pokemons

TODO list

  • 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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.