The Music Store API is an API for inquiries and disco sales,
your database will be powered by the Spotify API at system startup,
each disc has a random value between 10 and 100 and is associated with
one of the four pre-defined categories in the system (POP, MPB, CLASSIC and ROCK),
on the sale of the disk a cashback will be created according to the day of the week and the genre
of each disc, these values are also pre-defined according to the system specifications.
The app should provide a REST API containing the following operations::
-
Consult the disc catalog in paginated way, filtering by the genre and shorting in an increasing order by the name of the disc;
-
Consult the disc by its identifier;
-
Consult all sales made in paginated way, filtering by the range of dates (initial and final) of the sale and ordering in decreasing order by the date of the sale;
-
Consult a sale by its identifier;
-
Register a new disc sale with the total cashback value considering the table;
-
The app will be powered by the
Spotifydatabase:web-api -
Each sale may have one or more discs selected, the cashback must be calculated and stored individually for each disc as well as the total cashback of the sale;
-
When registering a sale, the
APImust send a message to a messaging service passing the unique number of the sale
Java/OpenJDK 13- Java Development Kit 13Spring boot- Framework base for the APIFlyway- Version control and migration for databaseMySQL- DatabaseH2- Database for testsSwagger- Dynamics API documentationJPA/Hibernate- Framework for data persistence / ORMDocker- Run and manage applications inside containers called containersRabbitMQ- RabbitMQ messaging servicejUnit5 e Mockito- Tests execution
The following steps have been documented to performed on a Linux platform,
but the commands with the Windows system can be similar, but, the operation isn't
fully guaranteed. Make sure you have installed in your environment the Java
(with the $JAVA_HOME in your classpath properly configured) and the Maven.
- Clone the project
$ git clone https://github.com/gbzarelli/music-store-api.git- Access the project folder to start compiling and running the app
$ cd ./music-store-api- The following instruction will be executed via
Maventhecleanof the project, right after thepackage, which will perform the unit tests to guarantee the integrity of the project and to generate our.jar, lastly buildDockerfilewill be generated an image in the local repository calledhelpdev/music-store-api. To build the plugindockerfile-maven-pluginhas been configured in thepom.xml;
$ mvn clean package dockerfile:build- Configure the following ENVs to
Spotifyaccess:
| ENV | Description |
|---|---|
| SPOTFY_ID | The Spotify credentials ID |
| SPOTFY_SECRET | The Spotify credential secret key |
- After the image will be generated through the
dockerfile:buildwe will mount the containers bydocker-compose. The prepared compose will go up to theAPI;
$ docker-compose up-
Home page
GET http://{address}:8080
-
Genre List
GET http://{address}:8080/genre
-
Search disc by ID
GET http://{address}:8080/disc/{id} -
Search discs (with pagination)
GET http://{address}:8080/disc{?page=1&limit=50} -
Search disc by a genre (with pagination)
GET http://{address}:8080/disc/genre/{genre}{?page=1&limit=50} -
Note:
Pagination parameters
-
New Sale
POST http://{address}::8080/saleBODY:
{ "discsIds":[1,2,3] } -
Search sale by purchase number
GET http://{address}:8080/sale/{orderNumber} -
Search sales by date
GET http://{address}:8080/sale/start_date/{startDate}/end_date/{endDate}{?page=1&limit=50}
Note: Accepted data format: 'yyyy-MM-dd' ex: 2019-05-23
The Swagger UI provide a display structure who is able to interpret
project endpoints and generate an interactive documentation site;
- http://{address}:8080/swagger-ui.html
