This is a backend system example in Java that supports the sales of discs with cashback. The main features of the system are about people, disc categories, disc artists, discs, cashback for discs and sale orders. It has integration with the Spotify API to get some information about categories, artists and discs.
- Java 10
- Gradle 5.2.1 (project has wrapper version)
- Database mariadb
- Spotify account
It is needed to configure a client and secret from spotify in the properties file
To install the database is needed to change the database information in two files:
- Gradle file - flyway item
- Properties file - data base information
With the database information configured it is needed to run the migration files to create the database structure with the gradle command:
gradlew.bat flywayMigrate -i
To build the system using the gradle wrapper configured, it is needed to run the gradle command:
gradlew.bat clean build
To run the system using the gradle wrapper configured, it is needed to run the gradle command:
gradlew.bat bootRun
The system runs in port 9000 (http://localhost:9000).
The current project coverage is around 98% of classes and 81% of lines, it have two type of tests configured:
- UnitTests - run with the command
gradlew.bat test
- ApplicationTests - - run with the command
gradlew.bat testApplication
For the project we have the following todo list:
- Configure swagger
- Configure cache server (memcached or redis)
- Implement the methods annotated with
@Deprecated
and throwingMethodNotImplementedException
- Improve the endpoint validations
- Improve the system validations
- Configure and Implement oauth2 authentication/authorization for the endpoints access
- Improve the quality of the exception handling and the
ControllerExceptionHandler
- Configure a docker file to generate a docker image
- Configure a jenkins file to runs and public on a docker or similar with an automated pipeline
For the tests of the project we have the following todo list:
- Configure the mock for the spotify API
- Create new unit tests
- Create new application tests
- Create integration tests
- Improve the test coverage (mainly in unit tests)
To check if the system is up use the endpoint /actuator/health
The person module is a simple CRUD that supports the create, read, update and delete actions.
The basic actions runs on the endpoints:
- POST
/person
- create a new person - GET
/person?page=0&size=10&sort=id,DESC
- get all people with pagination - GET
/person/{id}
- get a specific person - PUT
/person
- update a specific person - DELETE
/person/{id}
- delete a specific person
The basic json to use the POST|PUT endpoint is:
{
"id": 2,
"name": "teste"
}
The category module supports the read of categories from spotify, the import these categories into the system and get the categories registered in the system.
The basic actions runs on the endpoints:
- GET
/category/spotify?size=10&offset=0
- get the the categories on the spotify API based on the size and offset - POST
/category/spotify/import
- import categories from spotify to the system - GET
/category?page=0&size=10&sort=id,DESC
- get the categories that are registered on the system with pagination
The cashback module is a simple CRUD that supports the create, read, update and delete actions.
The basic actions runs on the endpoints:
- POST
/cashback
- create a new cashback - GET
/cashback?page=0&size=10&sort=id,DESC
- get all cashback with pagination - GET
/cashback/{id}
- get a specific cashback - PUT
/cashback
- update a specific cashback - DELETE
/cashback/{id}
- delete a specific cashback
The basic json to use the POST|PUT endpoint is:
{
"id": 1,
"category": {
"id": 1,
"spotifyId": "pop",
"name": "Pop"
},
"weekday": "SUNDAY",
"cashback": 25
}
The artist module only supports the get of all artists registered on the system and the get of a specific one.
The basic actions runs on the endpoints:
- GET
/artist?page=0&size=10&sort=id,DESC
- get all artist with pagination - GET
/artist/{id}
- get a specific artist
The disc module supports the read of discs by category from spotify, the import these disc into the system by category and get the discs registered in the system.
Note: Search a way of how to find albums by category, the currently implementation use a simple search for the albums with the category in the name. The correct way to use is search by the real category of the album, but i could't find this option.
The basic actions runs on the endpoints:
- GET
/disc/spotify?size=10&offset=0&genre={spotifyCategoryID}
- get the the discs on the spotify API based on the size, offset and genre - POST
/disc/spotify/import
- import discs from spotify to the system - GET
/disc?page=0&size=10&sort=id,DESC
- get the discs that are registered on the system with pagination - GET
/disc/{spotifyCategoryID}?page=0&size=10&sort=id,DESC
- get the discs that are registered on the system by category with pagination - GET
/disc/{id}
- get a specific disc - GET
/disc/{spotifyId}
- get a specific disc
The order module is a simple CRUD that supports the create, read, and delete actions.
The basic actions runs on the endpoints:
- POST
/order
- create a new order - GET
/order?page=0&size=10&sort=id,DESC
- get all order with pagination - GET
/order/{initDate}/{finalDate}?page=0&size=10&sort=id,DESC
- get all order with pagination between two dates- date format is "dd-MM-yyyy"
- GET
/order/{id}
- get a specific order - DELETE
/order/{id}
- delete a specific order
The basic json to use the POST endpoint is:
{
"person": {
"id": 1
},
"items": [
{
"disc": {
"spotifyId": "2kiDkXNxuQME25DEUWiNkw"
},
"qtd": 2
}
],
"creationDate": "15-02-2019"
}