Skip to content

feat: Add Currency Exchange API and React UI#140

Open
devin-ai-integration[bot] wants to merge 3 commits into
mainfrom
devin/1777549270-currency-exchange
Open

feat: Add Currency Exchange API and React UI#140
devin-ai-integration[bot] wants to merge 3 commits into
mainfrom
devin/1777549270-currency-exchange

Conversation

@devin-ai-integration

@devin-ai-integration devin-ai-integration Bot commented Apr 30, 2026

Copy link
Copy Markdown

Summary

Implements a full-stack currency exchange feature:

Backend (Spring Boot)

  • Database: Flyway migration V2 creates currency and currency_rate tables with seed data (6 currencies, 6 exchange rate pairs)
  • GET /currency: Returns all currencies keyed by currency code with country name, currency code, and currency name
  • GET /exchange-rate/{fromCur}/{toCur}: Returns the exchange rate between two currencies (404 if pair not found)
  • Domain entities: Currency and CurrencyRate in io.spring.core.currency
  • MyBatis mapper: CurrencyMapper with XML mappings for database queries
  • Service layer: CurrencyService with business logic
  • Security: Both endpoints are publicly accessible (no auth required)

Backend Tests (JUnit 5)

  • CurrencyApiTest — 3 tests: list all currencies, get exchange rate, 404 for unknown pair
  • CurrencyServiceTest — 3 tests: service returns currency map, exchange rate, null for unknown pair

Frontend (React/Next.js)

  • Currency List: Table displaying all currencies with code, name, and country
  • Exchange Rate Calculator: Dropdown selectors + button to calculate exchange rates between any two currencies
  • Page: /currency route integrating both components

Frontend Tests (Jest + React Testing Library)

  • CurrencyList.test.tsx — 4 tests: renders table, headers, empty state, correct row count
  • ExchangeRateCalculator.test.tsx — 5 tests: form rendering, validation errors, successful rate display, API error handling

UI Screenshot

Currency Exchange UI

Migration Ordering

  • V1: Core schema tables (users, articles, etc.)
  • V2: Currency tables + seed data (currency, currency_rate)
  • V3: Application seed data (sample users, articles, tags)
  • Test profile uses spring.flyway.target=2 to skip V3 seed data

Review & Testing Checklist for Human

  • Start the backend (./gradlew bootRun) and verify GET /currency returns all 6 currencies
  • Verify GET /exchange-rate/USD/INR returns {"fromCurrencyCode":"USD","toCurrencyCode":"INR","exchangeRate":"80.08"}
  • Start the frontend (cd frontend && NODE_OPTIONS=--openssl-legacy-provider npm run dev) and visit http://localhost:3000/currency
  • Test the exchange rate calculator by selecting USD -> INR and clicking "Get Exchange Rate"

Notes

  • gradle.properties was added with JVM args to fix Spotless/google-java-format compatibility with Java 17
  • Frontend babel config is scoped to Jest only (babel.jest.config.js) so it doesn't interfere with Next.js
  • Addressed Devin Review findings: cleared stale results on validation errors, fixed Flyway migration ordering

Link to Devin session: https://partner-workshops.devinenterprise.com/sessions/994d158e00714fad9f07f37b78f0297a


Open in Devin Review

- Create currency and currency_rate database tables with seed data (Flyway V3)
- Add GET /currency endpoint listing all currencies
- Add GET /exchange-rate/{fromCur}/{toCur} endpoint for exchange rates
- Add JUnit tests for CurrencyApi and CurrencyService (6 tests)
- Create React UI with currency list table and exchange rate calculator
- Add Jest/RTL tests for CurrencyList and ExchangeRateCalculator (9 tests)
- Configure Jest with Babel for frontend testing
@devin-ai-integration

Copy link
Copy Markdown
Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

devin-ai-integration[bot]

This comment was marked as resolved.

- Clear stale exchange rate result when validation errors occur
- Renumber Flyway migrations: currency tables are now V2, seed data is V3
  so that spring.flyway.target=2 correctly skips seed data in tests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants