Skip to content

feat: Add Frankfurter API integration using WebClient, Strategy Pattern, and In-Memory Store#157

Open
luthfiyyah-a wants to merge 6 commits intoallobankdev:mainfrom
luthfiyyah-a:luthfi
Open

feat: Add Frankfurter API integration using WebClient, Strategy Pattern, and In-Memory Store#157
luthfiyyah-a wants to merge 6 commits intoallobankdev:mainfrom
luthfiyyah-a:luthfi

Conversation

@luthfiyyah-a
Copy link
Copy Markdown

Overview

This PR implements a financial data aggregator that integrates with the Frankfurter Exchange Rate API. The system is designed to fetch, transform, and serve Indonesian Rupiah (IDR) focused financial data with custom business logic.

Key Technical Implementations

  • Strategy Design Pattern: Centralized controller logic by delegating resource-specific transformations to dedicated strategy classes (IDRDataFetcher).
  • WebClient Integration: Implemented a reactive WebClient via a custom FactoryBean for efficient and configurable external API communication.
  • Immutable Data Store: Created a thread-safe, in-memory storage using UnmodifiableMap to ensure data integrity after preloading.
  • ApplicationRunner: Automated data preloading during application startup to ensure immediate availability of financial data.
  • ASCII-Based Spread Calculation: Implemented a custom personalization logic for USD buy spread based on specific string ASCII values.

Testing Coverage

  • Unit Tests: Verified controller logic using standalone MockMvc and validated individual strategy transformation rules.
  • Integration Tests: Performed end-to-end verification using MockWebServer to simulate the Frankfurter API and confirm successful data preloading.
  • Global Exception Handling: Implemented @RestControllerAdvice to ensure standardized JSON error responses.

Preview

Endpoint Description
GET /api/finance/data/latest_idr_rates Latest rates with custom spread
GET /api/finance/data/historical_idr_usd Historical IDR to USD data
GET /api/finance/data/supported_currencies List of available currencies

More Information

See the readme for more information

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.

1 participant