Feat/idr rate aggregator ians#161
Open
herdiansyah5197 wants to merge 9 commits intoallobankdev:mainfrom
Open
Conversation
added 9 commits
February 22, 2026 11:59
- Ensure aggregated finance data loads once at startup - Store data in in-memory storage - Remove improper initialization approach
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR implements the Allo Bank Backend Developer Take-Home Test requirements.
The application integrates with the public Frankfurter API and exposes a single polymorphic endpoint:
GET /api/finance/data/{resourceType}Supported resource types:
What Was Implemented
Created IDRDataFetcher interface.
Implemented three concrete strategies:
Controller selects strategy dynamically using Spring-injected Map<String, IDRDataFetcher>.
No if/else or switch logic in controller.
This makes the solution extensible and clean.
Implemented a custom FactoryBean for the external API client.
Base URL and timeout are externalized using @ConfigurationProperties.
Centralized client configuration and error handling.
Client is not defined as a simple @bean.
Used ApplicationRunner to fetch all three resources once at application startup.
Data is stored in an in-memory storage component.
Storage is thread-safe and immutable after initialization.
API endpoint serves data from memory (no external calls per request).
For latest_idr_rates, implemented unique spread calculation based on GitHub username:
Spread Factor = (Sum of ASCII values % 1000) / 100000.0
USD_BuySpread_IDR = (1 / Rate_USD) * (1 + Spread Factor)
The calculated value is included in the response.
Testing
Unit tests for all strategy implementations.
Mocked external API calls.
Verified spread calculation logic.
Verified startup data loading.
Architectural Rationale
Why Strategy Pattern?
Why FactoryBean?
Why ApplicationRunner?