- Java 11
- IntelliJ (or any other IDE of your choice)
- Application will run at port:8080 - please make sure the port is not in use.
- Extract/Download the contents of the codebase to your local system by git zip download or clone.
- Using any command line tool, navigate to the directory where you have extracted/downloaded the codebase.
- Use the following command to run the application: 'docker-compose up --build'. Make sure port 8080 is available.
- Extract/Download the contents of the codebase to your local system.
- Using any command line tool, navigate to the directory where you have extracted/downloaded the codebase.
- Use the following command to rebuild the application: 'gradle build'
- Wait till the application is rebuilt
- The command will create a JAR file inside a folder named 'build' present in the codebase.
- You can copy paste this command to run the JAR file: java -jar build/libs/smart-playlist-0.0.1-SNAPSHOT.jar
- Once the server is started, you can use a get request to get the data curl -i -H "Accept: application/json" -H "Content-Type: application/json" -X POST localhost:8080/api/v1/playlists?searchString="love is in air" e.g. localhost:8080/api/v1/playlists?searchString= All other URL patterns are 404 not found json response
- Execute
gradle bootRun
from inside of root folder of extracted zipped file
The service contains two APIs
- First one allows creating a new playlist based on a search term
- Second API allows to fetch next song based on lyrics of the current song for a given playlist
Service maintains a cache of played songs against a playlist Service also maintains a cache of Track ID and lyrics to avoid remote calls
These caches can be moved to an external cache like Redis.
One of the challenge faced was designing an logic to fetch Random words from current lyrics. The current track lyrics needed cleansing due presence of unwanted texts and characters
- The response will be returned with correct response code (can be checked Postman)
- A sample successfull API response looks like this. { "trackId": 48058449, "title": "Nobody Could Care Less About Your Private Lives", "artist": "McCarthy", "lyrics": "The well-to-do family, the rich\nIn a life they talk about themselves\nAll the time but if they do\nIt's because they can afford to\nNobody could care less about your private life\n\n...\n\n******* This Lyrics is NOT for Commercial use *******\n(1409622230991)", "playListId": "cab347f6-8642-4bd9-a9ac-c67986ba81c8" }
1. To run tests execute: grable build
3. Access swagger url here: localhost:8080/api-doc.html
- PlaylistController: A rest controller which takes the requests and directs them to underlying code.
- PlaylistService: Contains application logic. Runs orchestration with MusixMatch Service
- application.properties: Contains configuration like api baseurl, app id and measurement units
- build.gradle: Gradle file containing dependencies
- ExceptionControllerAdvice: handles REST API exception responses
- Swagger API documentation
- The API URL, KEY, number of random words are configurable in application.properties.
For further reference, please consider the following sections: