A Spring Boot service that converts an amount from one cryptocurrency to another using CoinMarketCap (CMC), persists each conversion as a history record, and exposes pageable search & discovery endpoints. All responses are wrapped in CustomResponse<T>; paged payloads use CustomPagingResponse<T>.
- Client sends
POST /api/convertwithConvertRequest:{ from, to, amount }(e.g.,BTC→ARB,amount=100). - Service fetches the conversion rate from CMC, computes
convertedAmount, and persists a record:transactionId(UUID)createdAt(ISO-8601)from,to,amount,convertedAmount
- Returns
201 CreatedwithCustomResponse<CryptoConvert>containing the saved record.
POST /api/convert/history accepts FilterServicePagingRequest and returns CustomPagingResponse<CryptoConvertResponse>. Filtering supports:
from,to(symbols)- amount range:
minAmount..maxAmount - convertedAmount range:
minConvertedAmount..maxConvertedAmount - createdAt range:
createdAtFrom..createdAtTo transactionIdContains(substring)
Pagination & sorting are provided in the request (e.g., pageNumber, pageSize, sortBy, sortDirection).
-
GET /api/convert/mapreturns a paged list of cryptocurrencies (name & symbol) via CMC/v1/cryptocurrency/map. - Query params:
page(1-based, default1, min1)size(default20, range1..5000)
- Response:
CustomPagingResponse<CryptoNameSymbolResponse>with standard paging metadata.
201 Created— Successful conversion persisted (/api/convert)200 OK— Successful paged responses (/history,/map)400 Bad Request— Validation errors (invalid symbols, amounts, or paging inputs)502 Bad Gateway— Upstream CMC call failed or unavailable (convert/map)
CMC results are cached to reduce latency and request volume. Cache eviction runs on a fixed schedule configured via cmc.cache-ttl and a lifecycle hook (@PostConstruct) to ensure fresh state on startup.
The controller is annotated with detailed @Operation and @ApiResponse metadata. Explore at: http://localhost:1927/swagger-ui/index.html (port configurable).
Endpoints Summary
| Method | URL | Description | Request Body | Headers/Path | Response | Status Codes |
|---|---|---|---|---|---|---|
| POST | /api/convert | Convert an amount from one crypto to another and persist the result | ConvertRequest | — | CustomResponse<CryptoConvert> | 201, 400, 502 |
| POST | /api/convert/history | Paged search of conversion history with filters, pagination and sorting | FilterServicePagingRequest | — | CustomResponse<CustomPagingResponse<CryptoConvertResponse>> | 200, 400 |
| GET | /api/convert/map | List cryptocurrencies (name + symbol) with pagination | — | Query: page (default 1), size (default 20, max 5000) | CustomResponse<CustomPagingResponse<CryptoNameSymbolResponse>> | 200, 502 |
- Java 25
- Spring Boot 3.0
- Restful API
- Open Api (Swagger)
- Maven
- Junit5
- Mockito
- Integration Tests
- Mapstruct
- Resilience4j
- Resilience4j Rate Limiter
- Resilience4j Retry
- Resilience4j Circuit Breaker
- Spring Cache
- Docker
- Docker Compose
- CI/CD (Github Actions)
- Postman
- Prometheus
- Grafana
- Kubernetes
- JaCoCo (Test Report)
- AOP
- Jenkins
Import postman collection under postman_collection folder MONGO_DB_HOST=localhost MONGO_DB_PORT=27017 MONGO_DB_NAME=cryptoexchangedatabase COIN_MARKET_CAP_API_KEY={YOUR_COIN_MARKET_CAP_API_KEY} http://localhost:1927/swagger-ui/index.html After the command named mvn clean install completes, the JaCoCo report will be available at:
target/site/jacoco/index.html Navigate to the target/site/jacoco/ directory.
Open the index.html file in your browser to view the detailed coverage report.
To build and run the application with Maven, please follow the directions shown below;
$ git clone https://github.com/Rapter1990/cryptoexchangeapi.git $ cd cryptoexchangeapi $ mvn clean install $ mvn spring-boot:runThe application can be built and run by the Docker engine. The Dockerfile has multistage build, so you do not need to build and run separately.
Please follow directions shown below in order to build and run the application with Docker Compose file;
$ cd cryptoexchangeapi $ docker-compose up -dIf you change anything in the project and run it on Docker, you can also use this command shown below
$ cd cryptoexchangeapi $ docker-compose up --buildTo monitor the application, you can use the following tools:
-
Prometheus:
Open in your browser at http://localhost:9090
Prometheus collects and stores application metrics. -
Grafana:
Open in your browser at http://localhost:3000
Grafana provides a dashboard for visualizing the metrics.
Default credentials:- Username:
admin - Password:
admin
- Username:
Define prometheus data source url, use this link shown below
http://prometheus:9090 To run the application, please follow the directions shown below;
- Start Minikube
$ minikube start- Open Minikube Dashboard
$ minikube dashboard-
Revise
CMC_API_KEYincryptoexchangeapi-secrets.ymlaccording to your usage -
To deploy the application on Kubernetes, apply the Kubernetes configuration file underneath k8s folder
$ kubectl apply -f k8s- To open Prometheus, click tunnel url link provided by the command shown below to reach out Prometheus
minikube service prometheus-service- To open Grafana, click tunnel url link provided by the command shown below to reach out Prometheus
minikube service grafana-service- Define prometheus data source url, use this link shown below
http://prometheus-service.default.svc.cluster.local:9090 https://hub.docker.com/repository/docker/noyandocker/cryptoexchangeapi/general https://hub.docker.com/repository/docker/noyandocker/cryptoexchangeapi-jenkins/general - Go to
jenkinsfolder - Run
docker-compose up -d - Open Jenkins in the browser via
localhost:8080 - Define
credentialsforGithub General tokenused byGIT_REPO_IDanddocker-hub-credentialsforDockerUsernameandPassword - Go to pipeline named
cryptoexchangeapi - Run Pipeline
- Show
Pipeline Stepto verify if it succeeded or failed
