A Levi9 cloud hackathon.
This application aggregates the match data of basketball players and calculates their statistics.
-
ASP.NET 7 + Entity Framework 7 for the application
-
NUnit for testing
Docker for containerization
- The easiest way to get started is using the provided Docker image.
- Alternatively, you can run the app using the
dotnetCLI. You can download and install the dotnet SDK 7.0 for your operating system here. In case you already have it installed but are not sure of the version, run thedotnet --list-sdkscommand in your terminal to check.
git clone https://github.com/davidivkovic/cloud5.gitcd cloud5
- Build and tag the provided image:
docker build . -t davidivkovic/cloud5 - Run the container on port 5180:
docker run -p 5180:8080 davidivkovic/cloud5
(Optional) To set your own CSV file containing player data, mount it as a volume at /Data/Players.csv on startup. For example:
docker run -v ~/Downloads/MyPlayerData.csv:/Data/Players.csv -p 5180:8080 davidivkovic/cloud5
Note: If you are using Windows adjust the source path accordingly (eg. C:/Downloads/MyPlayerData.csv)
- Run the app on port 5180:
dotnet run
(Optional) To set your own CSV file containing player data, simply replace the contents of the /Data/Players.csv file with your own.
(Optional) Another way to do this is by setting the CSV_PLAYER_DATA environment variable to the path of
your file. For example:
- Linux Bash:
export CSV_PLAYER_DATA=~/Downloads/MyPlayerData.csv; dotnet run - Windows Powershell:
$env:CSV_PLAYER_DATA='C:/Downloads/MyPlayerData.csv'; dotnet run
The format of the data to provide in the CSV files is given in the following example:
PLAYER,POSITION,FTM,FTA,2PM,2PA,3PM,3PA,REB,BLK,AST,STL,TOV
Luyanda Yohance,PG,6,6,0,4,4,4,1,1,4,2,2
Jaysee Nkrumah,PF,0,4,2,2,2,4,2,1,2,0,1
Nkosinathi Cyprian,SF,2,6,3,9,0,4,4,2,1,0,2
The application will be available on http://localhost:5180 with a single endpoint /stats/player/{playerFullName} that supports the GET HTTP method.
An example request for the player Sifiso Abdalla, using the provided CSV data loaded on application startup:
GET http://localhost:5180/stats/player/Sifiso AbdallaHTTP/1.1 200 OK
Content-Type: application/json
{
"playerName": "Sifiso Abdalla",
"gamesPlayed": 3,
"traditional": {
"freeThrows": {
"attempts": 4.7,
"made": 3.3,
"shootingPercentage": 71.4
},
"twoPoints": {
"attempts": 4.7,
"made": 3,
"shootingPercentage": 64.3
},
"threePoints": {
"attempts": 6.3,
"made": 1,
"shootingPercentage": 15.8
},
"points": 12.3,
"rebounds": 5.7,
"blocks": 1.7,
"assists": 0.7,
"steals": 1,
"turnovers": 1.3
},
"advanced": {
"valorization": 11.7,
"effectiveFieldGoalPercentage": 40.9,
"trueShootingPercentage": 46.7,
"hollingerAssistRatio": 4.4
}
}An example request for a player that doesn't exist, returning HTTP 404:
GET http://localhost:5180/stats/player/Random NameHTTP/1.1 404 Not Found
Content-Type: text/plain
"Player not found"The tests were included in the application project itself for the sake of simplicity. The dotnet CLI is required in order to run the unit tests.
Run the dotnet test command in your terminal to get the test report:
Passed! - Failed: 0, Passed: 5, Skipped: 0, Total: 1, Duration: 19 ms - Cloud5.dll (net7.0)
The docker container image runs on the dotnet/aspnet:7.0-jammy-chiseled base image, which is based on Ubuntu 22.04.
To learn more about chiseled images and the size optimizations they provide, check out this microsoft blog post.