The Athlete Performance Tracking API is a RESTful service built with Laravel to manage and track athletes' performance records in various movements. The API allows CRUD operations for athletes, movements, and personal records, providing an efficient way to record and retrieve performance data. Additionally, it includes endpoints with a ranking system, retrieving ranking of athletes based on their performance in specific movements. It was built as a test case.
This api was built using Docker compose running a nginx image and a mysql image for development enviroment and Laravel sail, a command-line interface for interacting with laravel's default docker development environment. Postman was used for testing the endpoint.
Read more about Laravel Sail here:
https://laravel.com/docs/11.x/sail
Access Here the complete documentation on Wiki
For detailed information about how to use the Endpoints, access this page of the project wiki
For examples of use, access here
You can simply run the project on your machine, if you have docker environment:
1- Installation :
Clone this repository:
git clone https://github.com/juliazschwartz/ranking-api.git
cd ranking-api
2 - Setup:
If you are in Linux OS, and docker compose is already installed, execute this command:
docker context use default
Since none of the application's Composer dependencies, including Sail, will be installed after you clone the application's repository to your local computer,
run the following command to install application's dependencies.
This command uses a small Docker container containing PHP and Composer to install the application's dependencies:
docker run --rm \
-u "$(id -u):$(id -g)" \
-v $(pwd):/var/www/html \
-w /var/www/html \
laravelsail/php82-composer:latest \
composer install --ignore-platform-reqs
Now, Paste the content of .env.example file, present in the root directory to .env to have the correct database configuration (command for Linux OS, replace with equivalent if you are using another OS).
cp .env.example .env
3 - Run it:
Now, lets execute the container with sail up command (equivalent to compose up)
./vendor/bin/sail up -d
4 - Migrations and Seeders:
Laravel sail already manages volumes to store data, but there are stored in local machine, and are not presented here in this repository, so you should run the migration and seeders presented in this repository to populate the database.
For that, just execute:
./vendor/bin/sail artisan migrate
./vendor/bin/sail artisan db:seed --class=AthleteSeeder
./vendor/bin/sail artisan db:seed --class=MovementSeeder
./vendor/bin/sail artisan db:seed --class=PersonalRecordSeeder
5 - Test it
To test it, you can just run :
./vendor/bin/sail artisan test
should appear like this (all tests passing):
6- Use it
For detailed information about how to use the endpoints of this project, access here
Now you are ready to make the CRUD operations in API. I recommend using Postman for it (link for download in the references section).
For that, type "http://localhost/api/" in the URL field ("localhost" can be replaced by your local IP ), followed by the URL parameters for your request.
It will look like this:
7- External References