Skip to content

Task/forex assignment#77

Open
tarun-star wants to merge 3 commits intopaidy:masterfrom
tarun-star:task/forex_assignement
Open

Task/forex assignment#77
tarun-star wants to merge 3 commits intopaidy:masterfrom
tarun-star:task/forex_assignement

Conversation

@tarun-star
Copy link

This PR implements a production-ready local Forex rates proxy backed by the One-Frame service.

The solution is designed to meet the functional and non-functional requirements of the assignment, including scalability, freshness guarantees, and resilience against third-party limitations.

What’s included

Live One-Frame integration

Implemented a real HTTP interpreter to fetch exchange rates from the One-Frame API

Added robust JSON parsing and error handling for malformed or empty responses

Caching layer with TTL

Introduced an in-memory rate cache with configurable TTL

Ensures rates are no older than the configured threshold

Allows the service to scale beyond One-Frame’s 1,000 requests/day limit

Service & program wiring

Integrated cache and One-Frame interpreter into the rates service

Preserved separation of concerns using algebras and interpreters

Updated HTTP routes to return descriptive, user-friendly errors

Unit tests

Added focused unit tests covering:

Cached rate reuse

Cache TTL expiration

Error propagation from the upstream provider

Tests isolate external dependencies and validate business behavior

Design considerations

External API calls are isolated behind an algebra to simplify testing and future extensions

Cache-first strategy minimizes reliance on the third-party provider

Tests focus on high-risk, high-value behavior rather than framework internals

Code follows a production mindset with readability, safety, and maintainability in mind

Start One-Frame locally

docker run -p 8080:8080 paidyinc/one-frame

Run the application

sbt run

Example request

curl "http://localhost:8081/rates?from=USD&to=JPY"

Tarun added 3 commits January 25, 2026 12:06
- Added live One-Frame HTTP interpreter
- Integrated in-memory rate cache with TTL to bypass provider limits
- Wired service, program, and HTTP routes end-to-end
- Added proper error handling for invalid pairs and upstream failures
- Configured application for external One-Frame provider
- Added tests for cached rate reuse
- Verified cache TTL expiration behavior
- Covered error propagation from One-Frame provider
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