This is a solution for the practice test for Genesis Engineering School 2022. This repository contains a Spring Boot API with the following capabilities:
- Request current BTC rate using CoinMarketCap's API.
- Send e-mail with the current course using gmail SMTP to a list of subscribed e-mails.
- Add e-mails to the above-mentioned list. Detailed requirements are listed here.
The api keys provided in the application.properties are example data. To use the application, you'll have to provide your own.
- JDK 8 or higher
- Spring Boot (v.2.6.2)
- Docker
- Build the image from the Dockerfile
docker build -t <image name> <path to Dockerfile>
- Run the application from the image in the Dockerfile directory
docker run -p<your port>:8080 <image name>
The autogenerated Swagger API will be available at http://localhost:<your port>/swagger-ui/index.html
The main components of the project are:
- controller - used to get requests and send back responses via defined endpoints;
- service - classes that contain business logic;
- model - classes that are used for CoinMarketCap's API's response validation and could be used for data persistence in the future;
- exception - custom business logic exceptions
- advice - classes, used for exception handling.
Spring WebClient is used to send requests and get responses in synchronous mode from CoinMarketCap's API. The API's response is then validated and parsed for the requested currency's price. The emails are stored in Emails.txt file and are accessed via Java's IO package classes.