An app to search musics suggestion based in a given location.
This project is splitted in two repositories:
Birds migrate acording to the temperature also they can change their pattern of singing in different stages of live, such as during the reproductive period that also has to do with the temperature (when is hotter).
Credits for the name to @anakrdo
The Web API application of the Birdy project, created with Quarkus.
This API provide music suggestions for a given city name or a coordinate. Based in the current weather of this location is determinate a music genre, then it will search by music suggestions associate to this genre.
This application access the Open Weather Rest API to found the current weather temperature. The musics suggestions are obtained from the Spotify Rest API.
To access the Open Weather's current weather API is necessary create an API key, follow the below steps to create one:
- Access https://home.openweathermap.org/api_keys;
- Type a name in the
API key nameinput; - Click in the
Generatebutton; - Copy and paste the generated key in the
OPENWEATHER_APPIDenvironment variable.
To access the Spotify's recommendation API is necessary create an app client, follow the below steps to create one:
- Access https://developer.spotify.com/dashboard;
- Click in the
Create an appbutton; - Type a name and description;
- Read and check the spotify terms;
- Click in the
Createbutton; - Copy and paste the generated
Client IDin theSPOTIFY_AUTH_CLIENT_IDenvironment variable; - Click in the
Show client secretbutton; - Copy and paste the generated
Client Secretin theSPOTIFY_AUTH_CLIENT_SECRETenvironment variable.
Note: The application will create an access token automatically to access the recommendations API.
This application can be develop in any IDE and any environment with java and maven, but with VSCode + VSCode Dev Container all the dev environment already is configured and ready to use inside a Docker container.
- VSCode - Recommended IDE
- VSCode Dev Container - Recommended to develop inside a container
- Docker - Recommended to run the java inside a container
- Java 11 - Only install it if you will not be use Docker
- Maven 3.6.3+ - Only install it if you will not be use Docker
Create a .env file in the root project folder, with the below environments:
# GIT CONFIG ##########################################################################################################
GIT_USER_EMAIL="your@email"
GIT_USER_NAME="Your name"
#
# SPOTIFY CONFIG ######################################################################################################
SPOTIFY_AUTH_CLIENT_ID=29qrmm4z715pr7me5ncj8nuijpfmxnl0
SPOTIFY_AUTH_CLIENT_SECRET=t4997oda2qarzs5konlht4tz3xlhh8av
#
# OPEN WEATHER CONFIG #################################################################################################
OPENWEATHER_APPID=vdakpvfep7m7tn7c4dfgw1g84jmi16wb
#Notes:
- The above environment variable values are only examples. Replace it by correct value.
- The
GIT_*environment variables are used to config the git inside a docker container (Only necessary it if you will use the git inside a VSCode Dev Container).
mvn quarkus:dev- start the Quarkus in development mode, then open http://localhost:8080/swagger-ui from your browser;mvn test- run the JUnit tests;mvn clean package- clean, compile and package the application for production usage;mvn clean compile- compile the application;mvn clean- clean the application;mvn formatter:format- format the code using the Seudev's Style Guide (Used automatically in the build and VSCode Dev Container);mvn formatter:validate- validate the format the code using the Seudev's Style Guide;mvn quarkus-bootstrap:build-tree- show the dependency tree;
Note: All this scripts are configured as VSCode tasks and bash alias to facilitate development.
- Java 11 - Only install it if you will not be use Docker
To run this application is required define the below settings. This settings and many others are defined with Eclipse MicroProfile Config, then is possible override the setting value in runtime without rebuild the application.
The below settings are store sensitive data, then we decide define it out of the code instead in the src/main/resources/application.properties file.
It can be defined using environment variables or Java System properties. Use the mode that is most convenient.
SPOTIFY_AUTH_CLIENT_ID=29qrmm4z715pr7me5ncj8nuijpfmxnl0
SPOTIFY_AUTH_CLIENT_SECRET=t4997oda2qarzs5konlht4tz3xlhh8av
OPENWEATHER_APPID=vdakpvfep7m7tn7c4dfgw1g84jmi16wb-Dspotify.auth.client.id=29qrmm4z715pr7me5ncj8nuijpfmxnl0
-Dspotify.auth.client.secret=t4997oda2qarzs5konlht4tz3xlhh8av
-Dopenweather.appId=vdakpvfep7m7tn7c4dfgw1g84jmi16wbNotes:
- The above environment variable values are only examples. Replace it by correct value.
- See how to create these API keys
This application can be packaged in different ways. The main ways are detailed below, choose one.
Note: If you want debug a containerized app expose the debug port (-p 5005:5005) and set true in the JAVA_ENABLE_DEBUG environment variable (-e JAVA_ENABLE_DEBUG=true).
Generate a more performant version than the default jar type.
Execute the below command to build the Docker image:
docker build -f src/main/docker/Dockerfile.fast-jar -t seudev/birdy-web-api-fast-jar .Execute the below command to run the application:
docker run -i --rm -p 8080:8080 seudev/birdy-web-api-fast-jarExecute the below command to build the application:
mvn package -Dquarkus.package.type=fast-jarIt will be generate a target/quarkus-app folder. Copy all internal files and folders from that folder to the desire folder,
then execute the below command to run the application:
java -jar quarkus-run.jarGenerate the default jar type with the dependency libraries separated in a folder.
Execute the below command to build the Docker image:
docker build -f src/main/docker/Dockerfile.jvm -t seudev/birdy-web-api-jvm .Execute the below command to run the application:
docker run -i --rm -p 8080:8080 seudev/birdy-web-api-jvmExecute the below command to build the application:
mvn package -Dquarkus.package.type=jarIt will be generate a target/*-runner.jar file and a target/lib folder. Copy it to the desire folder,
then execute the below command to run the application:
java -jar *-runner.jarGenerate a single jar file with all necessary dependencies.
Execute the below command to build the application:
mvn package -Dquarkus.package.type=uber-jarIt will be generate a target/*-runner.jar file. Copy it to the desire folder,
then execute the below command to run the application:
java -jar *-runner.jarUse GraalVM to generate a single binary file with all necessary dependencies.
Execute the below command to build the Docker image:
docker build -f src/main/docker/Dockerfile.native -t seudev/birdy-web-api-native .Execute the below command to run the application:
docker run -i --rm -p 8080:8080 seudev/birdy-web-api-nativeUse the below endpoints to get the API documentation:
Notes:
- This endpoints are based in the OpenAPI specification.
- This documentation is defined using the Eclipse MicroProfile OpenAPI.
Use the below endpoints to monitor this application:
-
The below endpoints are based in the Eclipse MicroProfile Health specification:
-
The below endpoints are based in the Eclipse MicroProfile Metrics specification:
seudev/birdy-web-api is provided and distributed under the Apache Software License 2.0.
Refer to LICENSE for more information.
