Git Product home page Git Product logo

be-challenge-arios's Introduction

Backend challenge by Ariel Gerardo Ríos (that's me!)

Start services with docker-compose

It is REQUIRED to change FOOTBALL_APIKEY environment variable value in docker-compose.yml file. Once started, it can take a few moments up be ready since it builds + tests + waits for database to be ready to accept connections.

docker-compose up

Example usage

# enqueues data import process for Premier League competition
curl -X POST --data '{"code":"PL"}' http://localhost:8080/importer

# Get players in Prime League that belongs to a Manches-like team (teamName optional)
curl -X GET "http://localhost:8080/competitions/pl/players?teamName=Manches"

# Get Manchester United team with players (showPlayers optional)
curl -X GET "http://localhost:8080/teams/MUN?showPlayers=true"

# Get Manchester United team persons (players and coaches if present)
curl -X GET "http://localhost:8080/teams/MUN/persons"

# Utility endpoints
curl -X GET "http://localhost:8080/status"

Swagger documentation

Served on http://localhost:8080/swagger/index.html

swagger screenshot

be-challenge-arios's People

Contributors

ariel17 avatar

Watchers

 avatar  avatar

be-challenge-arios's Issues

Implement backend services for importing leagues

This issue involves the backend side of the implementation to fulfill the required behavior.

Depends on #3 #8

Import League:
There should be an endpoint to import a league, named “import league”, that takes a “league code” as input.

The import league implementation must get data using the given league code, by making
requests to the http://www.football-data.org/ API, and import the data into a DB. Any SQL or
NoSQL DB can be used, as long as there are clear instructions on how to run the project
locally as well as an explanation for the decision in the README.

Information to retrieve:
Additionally, expose the following endpoints, that should rely exclusively on the data saved
inside the DB (it must not access the API football-data.org):
● players: takes league code as a parameter and returns the players that belong to all
teams participating in the given league. If the given league code is not present in the
DB, it should respond with an error message. Add an optional input to the endpoint to
filter players also by team name.
● team: takes a name and returns the corresponding team. Additionally, if requested in the
query, it should resolve the players for that team (or coaches, if players are not available
at the moment of implementation).
● players of a team: should resolve the players for the given team (or coaches, if players
are not available at the moment of implementation).

On the API access:
● Please notice that even though this is a paid API, you can get a free token and perform
your testing with some specific competitions (PD, CL, PL).
● It's important that the code handles in some way the limit frequency to the requests
performed with a free-token.

Create import endpoint

This issue involves only the API side of the implementation (docs, schemas, etc).


Import League:
There should be an endpoint to import a league, named “import league”, that takes a “league code” as input.

The import league implementation must get data using the given league code, by making
requests to the http://www.football-data.org/ API, and import the data into a DB. Any SQL or
NoSQL DB can be used, as long as there are clear instructions on how to run the project
locally as well as an explanation for the decision in the README.

Information to retrieve:
Additionally, expose the following endpoints, that should rely exclusively on the data saved
inside the DB (it must not access the API football-data.org):
● players: takes league code as a parameter and returns the players that belong to all
teams participating in the given league. If the given league code is not present in the
DB, it should respond with an error message. Add an optional input to the endpoint to
filter players also by team name.
● team: takes a name and returns the corresponding team. Additionally, if requested in the
query, it should resolve the players for that team (or coaches, if players are not available
at the moment of implementation).
● players of a team: should resolve the players for the given team (or coaches, if players
are not available at the moment of implementation).

Implement API client

We’ll be hitting http://www.football-data.org/ API (you can see the documentation in the site, use
the API v4) to populate the data locally and then expose it.

League code is given as input.

The data we’re importing is:
● Competition ("name", "code", "areaName")
● Team ("name", "tla", "shortName", "areaName", "address")
● Player ("name", "position", "dateOfBirth", "nationality")
● Coach(“name”, “dateOfBirth”, “nationality”) (import that data even if the values are null)

Retrieve data endpoints

Depends on #5

Information to retrieve:
Additionally, expose the following endpoints, that should rely exclusively on the data saved
inside the DB (it must not access the API football-data.org):
● players: takes league code as a parameter and returns the players that belong to all
teams participating in the given league. If the given league code is not present in the
DB, it should respond with an error message. Add an optional input to the endpoint to
filter players also by team name.
● team: takes a name and returns the corresponding team. Additionally, if requested in the
query, it should resolve the players for that team (or coaches, if players are not available
at the moment of implementation).
● players of a team: should resolve the players for the given team (or coaches, if players
are not available at the moment of implementation).

Create data models

Depends on #1

The data we’re importing is:
● Competition ("name", "code", "areaName")
● Team ("name", "tla", "shortName", "areaName", "address")
● Player ("name", "position", "dateOfBirth", "nationality")

Note: When making the implementation, if there is no data (no players) inside team squads,
then, instead of importing players, you should import only the coach:
● Coach(“name”, “dateOfBirth”, “nationality”) (import that data even if the values are null)

“league code” is an input.

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.