Giter Club home page Giter Club logo

apisw's Introduction

Star Wars API

Test all branches

Simple REST service which returns details of Star Wars characters.

Service works as a transient API forwarding to swapi.dev.
Implementation may produce n+1 alike problem since Star Wars characters tends to have many starships
and swapi.dev search query does not support searching by any ranges (especially id range),
so HATEOAS resources may be fetched only in 'request per single resource' mode.

Build

  • Clone repo and navigate to project root directory.
  • Generate gradle wrapper gradle wrapper

a) Run app from sources

  • Run ./gradlew bootRun

b) Run app on Docker container

  • Build JAR ./gradlew clean build
  • Build docker image docker build -t fraczekgo/apisw-app .
  • Start container docker run -p 8080:8080 fraczekgo/apisw-app

c) App and Prometheus

  • Create image as before
  • Run docker-compse up
  • Prometheus container is mapped to port 9090 and graphs can be examined at http://localhost:9090/graph

Swagger (OpenApi 3.0)

Swagger resources generated from OpenApi 3.0 spec are available at:
http://localhost:8080/swagger-ui/index.html?configUrl=/v3/api-docs/swagger-config#/

Exercise:

Zadanie polega na przygotowaniu usługi REST która zwróci:

  • stronicowaną listę bohaterów Gwiezdnych Wojen
  • szczegóły poszczególnych bohaterów. API powinno wystawiać dwie końcówki:

GET /characters?page=x

{
  "count": 82,
  "pages": 9,
  "elements": [
    {
      "id": 1,
      "name": "Luke Skywalker",
      "height": "172",
      "mass": "77",
      "hairColor": "blond",
      "skinColor": "fair",
      "eyeColor": "blue",
      "birthYear": "19BBY",
      "gender": "male",
      "homeworld": {
        "name": "Tatooine",
        "rotationPeriod": "23",
        "orbitalPeriod": "304",
        "diameter": "10465",
        "climate": "arid",
        "gravity": "1 standard",
        "terrain": "desert",
        "surfaceWater": "1",
        "population": "200000"
      },
      "starships": [
        {
          "name": "X-wing",
          "model": "T-65 X-wing",
          "manufacturer": "Incom Corporation",
          "costInCredits": "149999",
          "length": "12.5",
          "maxAtmosphericSpeed": "1050",
          "crew": "1",
          "passengers": "0",
          "cargoCapacity": "110",
          "consumables": "1 week",
          "hyperdriveRating": "1.0",
          "mglt": "100",
          "starshipClass": "Starfighter"
        },
        {
          "name": "Imperial shuttle",
          "model": "Lambda-class T-4a shuttle",
          "manufacturer": "Sienar Fleet Systems",
          "costInCredits": "240000",
          "length": "20",
          "maxAtmosphericSpeed": "850",
          "crew": "6",
          "passengers": "20",
          "cargoCapacity": "80000",
          "consumables": "2 months",
          "hyperdriveRating": "1.0",
          "mglt": "50",
          "starshipClass": "Armed government transport"
        }
      ]
    }
  ]
}

GET /characters/{id}

{
  "id": 1,
  "name": "Luke Skywalker",
  "height": "172",
  "mass": "77",
  "hairColor": "blond",
  "skinColor": "fair",
  "eyeColor": "blue",
  "birthYear": "19BBY",
  "gender": "male",
  "homeworld": {
    "name": "Tatooine",
    "rotationPeriod": "23",
    "orbitalPeriod": "304",
    "diameter": "10465",
    "climate": "arid",
    "gravity": "1 standard",
    "terrain": "desert",
    "surfaceWater": "1",
    "population": "200000"
  },
  "starships": [
    {
      "name": "X-wing",
      "model": "T-65 X-wing",
      "manufacturer": "Incom Corporation",
      "costInCredits": "149999",
      "length": "12.5",
      "maxAtmosphericSpeed": "1050",
      "crew": "1",
      "passengers": "0",
      "cargoCapacity": "110",
      "consumables": "1 week",
      "hyperdriveRating": "1.0",
      "mglt": "100",
      "starshipClass": "Starfighter"
    },
    {
      "name": "Imperial shuttle",
      "model": "Lambda-class T-4a shuttle",
      "manufacturer": "Sienar Fleet Systems",
      "costInCredits": "240000",
      "length": "20",
      "maxAtmosphericSpeed": "850",
      "crew": "6",
      "passengers": "20",
      "cargoCapacity": "80000",
      "consumables": "2 months",
      "hyperdriveRating": "1.0",
      "mglt": "50",
      "starshipClass": "Armed government transport"
    }
  ]
}

Wymagania

Wymagania poza funkcjonalne

  • powinna być w stanie obsłużyć 20 zapytań na sekundę (nie powinna zawierać oczywistych wąskich gardeł)
  • pełny zestaw testów uruchamiany wraz z narzędziem budującym (Maven lub Gradle)
  • dobry projekt i jakość kodu

Dodatkowe wymagania- obsługa i logowanie błędów

  • konfiguracja Swagger UI
  • dokeryzacja aplikacji
  • przygotowanie do monitorowania przy pomocy Prometheus

Technologie

Wymagane technologie

  • Java 11

Zalecane technologie:

  • Spring
  • Spock

apisw's People

Contributors

patrolfr avatar

Watchers

 avatar

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.