Gold Medal Metrics is an Olympics analytics web application built with Spring Boot and Spring Data JPA. This project is part of the Create REST APIs with Spring and Java course by Codecademy.
The application allows users to:
- View a list of countries along with their population, GDP, and number of Olympic gold medals.
- Sort the list by different attributes, including country name, population, GDP, and medal count.
- View detailed Olympic statistics for a selected country.
- Retrieve a list of Olympic gold medal wins for a country, including details like the year, season, athlete name, city, and event.
- Sort the list of Olympic wins by various attributes.
- Java 11
- Spring Boot 2.5.2
- Spring Data JPA
- H2 Database (for development and testing)
- Apache Commons Text (utility functions)
Ensure you have the following installed:
- Java 11 or higher
- Maven
- Clone the repository:
git clone https://github.com/Robson16/goldmedal.git cd goldmedal
- Build the project with Maven:
mvn clean install
- Run the application:
mvn spring-boot:run
- The API will be available at:
http://localhost:3001
curl --request GET "http://localhost:3001/countries?sort_by=name&ascending=y"
Response:
{
"countries": [
{"name":"Afghanistan","code":"AFG","gdp":594.32,"population":32526562,"medals":0},
...
]
}
curl --request GET "http://localhost:3001/countries/united%20states"
Response:
{
"name":"United States",
"gdp":56115.72,
"population":321418820,
"numberMedals":2477,
"numberSummerWins":2302,
"percentageTotalSummerWins":21.957,
"yearFirstSummerWin":1896,
"numberWinterWins":175,
"percentageTotalWinterWins":9.109,
"yearFirstWinterWin":1924,
"numberEventsWonByFemaleAthletes":747,
"numberEventsWonByMaleAthletes":1730
}
curl --request GET "http://localhost:3001/countries/united%20states/medals?sort_by=name&ascending=n"
Response:
{
"medals": [
{
"year":1968,
"city":"Mexico",
"season":"Summer",
"name":"ZORN, Zachary",
"country":"United States",
"gender":"Men",
"sport":"Aquatics",
"discipline":"Swimming",
"event":"4X100M Freestyle Relay"
},
...
]
}
The project uses the following dependencies, as defined in pom.xml
:
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-text</artifactId>
<version>1.8</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
- Add support for retrieving Olympic statistics by athlete.
- Implement authentication and authorization for API access.
- Migrate to a production-ready database like PostgreSQL or MySQL.
This project was developed as part of the Create REST APIs with Spring and Java course by Codecademy.
Happy Coding! 🚀