Console application that downloads daily exchange rates from the Bank of Russia, stores them in PostgreSQL, shows rates for a selected date, and converts amounts between currencies.
- Java 21
- Spring Boot 4
- Spring Shell
- PostgreSQL 17
- Flyway
- Maven Wrapper
- Testcontainers
- Java 21
- Docker with Docker Compose
Maven does not have to be installed because the project includes Maven Wrapper.
For VS Code, the recommended extensions are Extension Pack for Java and Docker.
-
Open a terminal in the project directory.
-
Start PostgreSQL:
docker compose up -d
-
Check that the database is running and healthy:
docker compose ps
-
Start the application:
./mvnw spring-boot:run
On Windows PowerShell without WSL, use:
.\mvnw.cmd spring-boot:run
Flyway creates the required database tables automatically. When the Spring Shell prompt appears, the application is ready to accept commands.
Download and save rates for a date:
rates import --date 2026-08-26
Show all stored rates for a date:
rates show --date 2026-08-26
Convert 100 Japanese yen to Belarusian rubles using the stored rates:
currency convert --amount 100 --from JPY --to BYN --date 2026-08-26
The conversion command requires rates for the selected date to be imported first. Currency codes are case-insensitive and must contain three letters.
Use help to list all commands and exit to stop the application.
The application imports rates for the current date every day at 02:00 in the
Europe/Moscow time zone. The schedule uses a six-field Spring cron expression.
The default settings are:
app.import.cron=0 0 2 * * *
app.import.zone=Europe/MoscowIf a scheduled request fails, the error is logged and existing rates remain in
the database. A failed import can be repeated manually with rates import.
The default configuration works with PostgreSQL from compose.yaml. It can be
overridden with environment variables:
| Environment variable | Default value |
|---|---|
DB_URL |
jdbc:postgresql://localhost:5432/currency_parser |
DB_USER |
currency_parser |
DB_PASSWORD |
currency_parser |
APP_CBR_BASE_URL |
https://www.cbr.ru/scripts/XML_daily.asp |
APP_CBR_CONNECT_TIMEOUT |
5s |
APP_CBR_REQUEST_TIMEOUT |
10s |
APP_IMPORT_CRON |
0 0 2 * * * |
APP_IMPORT_ZONE |
Europe/Moscow |
Example with a different database URL:
DB_URL=jdbc:postgresql://localhost:5433/currency_parser \
DB_USER=currency_parser \
DB_PASSWORD=currency_parser \
./mvnw spring-boot:runDo not store production database passwords in the repository.
Make sure Docker is running, then execute:
./mvnw testIntegration tests start temporary PostgreSQL containers automatically and do not
use the database from compose.yaml. The CBR API is replaced with a local test
server, so the tests do not depend on internet access.
./mvnw clean package
java -jar target/currency-parser-0.0.1-SNAPSHOT.jarPostgreSQL must be running before the JAR is started.
Exit Spring Shell with:
exit
Then stop PostgreSQL:
docker compose downThe postgres_data volume keeps the imported rates between restarts. To remove
the database together with all stored rates, explicitly run:
docker compose down -v