A simple and clean console-based currency converter built in Java, using real-time exchange rates provided by the ExchangeRate API.
This project was designed with a backend-oriented mindset, following industry best practices such as clean architecture, separation of concerns, external API integration, and secure configuration management.
- Convert between any two supported currencies
- Uses ISO 4217 currency codes (3-letter standard: USD, BRL, EUR, etc.)
- Real-time exchange rates via external API
- Interactive console menu
- API key securely externalized using environment variables (
.env)
The application follows a layered backend architecture, commonly used in Java enterprise applications:
dev.leo.currencyflow
├── client # HTTP client responsible for external API communication
├── dto # Data Transfer Objects (API response mapping)
├── service # Business logic and currency conversion rules
├── controller # Console-based input/output handling
├── exception # Custom exception classes
└── Main.java # Application entry point
This structure improves:
- Maintainability
- Testability
- Readability
- Separation of responsibilities
- Java 17+ — Core language
- Maven — Dependency and build management
- OkHttp — HTTP client for external API calls
- Jackson — JSON serialization/deserialization
- ExchangeRate API — Real-time currency exchange data
- java-dotenv — Environment variable management
For security reasons, the API key is not hardcoded.
EXCHANGE_API_KEY=YOUR_API_KEY_HERE
.env
- ExchangeRate API website
- Java 17+ (recommended)
- Maven
Run the Main class from your IDE.
━━━━━ Currency Converter ━━━━━
1 - Convert from USD ($) to another currency
2 - Convert another currency to USD ($)
3 - Convert from EUR (€) to another currency
4 - Convert another currency to EUR (€)
5 - Convert from GBP (£) to another currency
6 - Convert another currency to GBP (£)
7 - Convert between any currencies
0 - Exit
The user is prompted to enter:
- Source currency
- Target currency
- Amount
The converted value is displayed immediately.
This project is licensed under the MIT License.
Developed by Leonardo. Feel free to explore, fork, and improve this project 🚀