- This project demonstrates a Spring Boot application for managing foreign exchange operations. It allows users to convert currencies, retrieve current exchange rates, and view conversion history.
- The application integrates with an external service provider for fetching exchange rates and performing currency conversion calculations.
- The application includes three main endpoints:
- Exchange Rate Endpoint: Fetches the current exchange rate between two currencies.
- Currency Conversion Endpoint: Converts a given amount from one currency to another and returns a unique transaction identifier.
- Conversion History Endpoint: Retrieves the history of currency conversions based on transaction identifiers or dates.
Endpoints Summary
Method | Url | Description | Request Body | Path Variable | Response |
---|---|---|---|---|---|
POST | /api/v1/exchange-rate | Fetches the current exchange rate between two currencies. | ExchangeRateRequest | None | ExchangeRateResponse |
POST | /api/v1/convert | Converts currency based on the provided ConvertRequest. | ConvertRequest | None | ConvertResponse |
POST | /api/v1/history | Retrieves the conversion history based on the provided ConversionHistoryFilterRequest. | ConversionHistoryFilterRequest | None | CustomPage<ConvertHistoryResponse> |
- Java 21
- Spring Boot 3.0
- Restful API
- Mapstruct
- Open Api (Swagger)
- Maven
- Junit5
- Mockito
- Integration Tests
- Docker
- Docker Compose
- CI/CD (Github Actions)
- Postman
- H2 Database (In-Memory)
- Spring Boot Actuator
- Spring Cache
- Resilience4j (Rate Limiter)
Import postman collection under postman_collection folder
Define Variable in .env file for http://api.currencylayer.com/
EXCHANGE_API_API_KEY={EXCHANGE_API_API_KEY}
http://localhost:1331/swagger-ui/index.html
- Maven or Docker
The 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 foreignexchangeexample
$ docker-compose up -d
If you change anything in the project and run it on Docker, you can also use this command shown below
$ cd foreignexchangeexample
$ docker-compose up --build
To build and run the application with Maven
, please follow the directions shown below;
$ cd foreignexchangeexample
$ mvn clean install
$ mvn spring-boot:run
https://hub.docker.com/repository/docker/noyandocker/foreignexchangeexample/general