This is a simple application to serve sportsbook players with data about seasons from certain football leagues. It is intended to provide only simple overviews around the seasons without any potential action from the user.
When starting the application, it will run a seeds file that will read from a seeds csv file all data that there is about matches and will consolidate that info into the database.
After this, any user can access that info through the public API. Since most data is simply read-only, there are not any data trickery (except on the season overview).
FOOTBALL_DATABASE_USERNAME
- optional - Sets the Database usernameFOOTBALL_DATABASE_PASSWORD
- optional - Sets the Database user passwordFOOTBALL_DATABASE_HOSTNAME
- optional - Sets the Database hostnameFOOTBALL_DATABASE_URL
- optional - Sets the Database connection url (if set, the connection will ignore the username, password and hostname passed before)
This step is needed before executing any of the other actions (start server, test, document, ...)
Build the image using the following command
sudo docker-compose -f "automation/docker/docker-compose.yml" build
If you don't want to use Docker, ensure that PostgreSQL is running then execute:
mix do deps.get, ecto.setup
Note that starting the project on docker will start three instances of the server and a loadbalancer.
sudo docker-compose -f "automation/docker/docker-compose.yml" up
If this is the first time starting the server, with the containers up, run the seeds builder: TODO: Make this smarter or idempotent
sudo docker exec docker_football_1 mix ecto.setup
Access the server through http://localhost/api/leagues
mix phx.server
Access the server through http://localhost:4000/api/leagues
sudo docker exec docker_football_1 mix test
mix test
This command will generate the application documentation on the application /doc
folder.
TODO
mix docs
- Fetch all leagues
/api/leagues
- Fetch all season within a league
/api/leagues/<league_code>/seasons
- Fetch all data from a season (includes matches and season overview)
/api/leagues/<league_code>/seasons/<season_code>
Note that resources returns links to related resources.
In this project, the same service (football
) was specified three times to show load balancing with HAProxy without the need of more than one node or the use of an automation tool like Ansible.
If this was an application for the real world, it would have only a single definition of the football
container to be deployed across several nodes and with the network data fed to the HAProxy node allowing it to balance load between them.
Since this project provides only a read-only RESTful API, it didn't need a database (data could be loaded from a file and kept in-memory), but a database was used to make it easier to include more data, provide more resource endpoints and to allow filtering data in the future.
Some features could not be implemented due to time constraints. Those are:
- Protocol Buffer
- Automatic API Documentation
- Loging instrumentation
- Metrics instrumentation
Copyright (c) 2018 Charlotte Lorelei Oliveira. This source code is released under GPL 3.