# Getting Started

This project is a small Swing-based currency converter that pulls live exchange rates from ExchangeRate-API and lets users convert between currencies in a desktop UI. The app starts from a single launcher class, loads API credentials from a properties file, and uses a simple API wrapper plus background UI workers to keep the interface responsive.

## What This Project Does

- Launches a desktop currency converter UI.
- Fetches available currency codes and live conversion results from an external rate API.
- Keeps the UI responsive by loading currency lists asynchronously.

## Recommended Reading Order

1. [`src/main/java/com/github/blaxk3/converter/CurrencyConverter.java`](../src/main/java/com/github/blaxk3/converter/CurrencyConverter.java) — start here to see how the application boots.
2. [`src/main/java/com/github/blaxk3/ui/UI.java`](../src/main/java/com/github/blaxk3/ui/UI.java) — this contains the full user interface, event handlers, and background loading logic.
3. [`src/main/java/com/github/blaxk3/api/CurrencyRateAPI.java`](../src/main/java/com/github/blaxk3/api/CurrencyRateAPI.java) — read this to understand how API requests are built and parsed.
4. [`src/main/resources/config.properties`](../src/main/resources/config.properties) — check this after the code so you know where the API key comes from.

## Key Entry Points

The codebase is small, so there are only a few classes to know well:

- [`com.github.blaxk3.converter.CurrencyConverter`](../src/main/java/com/github/blaxk3/converter/CurrencyConverter.java) — application entry point with `main`.
- [`com.github.blaxk3.ui.UI`](../src/main/java/com/github/blaxk3/ui/UI.java) — main window, buttons, inputs, and asynchronous currency loading.
- [`com.github.blaxk3.api.CurrencyRateAPI`](../src/main/java/com/github/blaxk3/api/CurrencyRateAPI.java) — service class for loading API keys, fetching currency lists, and performing conversions.

## Project Structure

The repository follows a straightforward Maven layout:

- `pom.xml` — build definition, Java version, and dependencies.
- `src/main/java/com/github/blaxk3/converter/` — startup code.
- `src/main/java/com/github/blaxk3/ui/` — Swing UI and UI-specific helpers.
- `src/main/java/com/github/blaxk3/api/` — external API integration.
- `src/main/resources/` — runtime configuration and bundled resources.

There are no deeply nested modules or layered packages beyond these three functional areas, so navigation is mostly by responsibility rather than by framework.

## Configuration

- [`pom.xml`](../pom.xml) controls the build.
  - Java source/target level: 23
  - Dependencies: Gson, SLF4J API, and SLF4J Simple
- [`src/main/resources/config.properties`](../src/main/resources/config.properties) stores the API key used by `CurrencyRateAPI`.
  - `API_KEY` must be set before the app can retrieve rates.
  - The file currently includes a placeholder value, so replace it with a valid key from ExchangeRate-API.

## Common Patterns

- **Single responsibility by class**: launcher, UI, and API access are separated cleanly.
- **Swing on the EDT**: the app starts the UI with `SwingUtilities.invokeLater(...)`.
- **Background loading with `SwingWorker`**: currency codes are fetched off the UI thread so the window stays responsive.
- **Simple resource loading**: configuration is read from the classpath with `getResourceAsStream(...)`.
- **Basic validation at the input boundary**: the amount field uses a `DocumentFilter` to limit input to numeric values and one decimal point.
- **Direct API response parsing**: JSON is handled with Gson and converted immediately into values the UI can use.

## Suggested Next Steps

- Read the launcher, then the UI, then the API client.
- Set a real `API_KEY` in [`config.properties`](../src/main/resources/config.properties).
- Run the app and trace one conversion end-to-end from button click to HTTP request to rendered result.
