Skip to content

Implement EUR support, fallback exchange-rate provider, caching, and currency usage tracking#1

Open
olmelikov wants to merge 1 commit intoCorpEdward:mainfrom
olmelikov:feature/oles-melikov-eur-fallback
Open

Implement EUR support, fallback exchange-rate provider, caching, and currency usage tracking#1
olmelikov wants to merge 1 commit intoCorpEdward:mainfrom
olmelikov:feature/oles-melikov-eur-fallback

Conversation

@olmelikov
Copy link

Summary

This PR implements the requested currency enhancements for the Smartphone Catalog API.

Implemented

  • Added EUR support

    • GET /api/catalog/EUR
    • GET /api/exchangeRate/EUR
  • Added a second exchange-rate provider as fallback

    • Primary provider: NBU
    • Fallback provider: Open ER API
  • Added config-driven provider selection via config/currency.php

  • Added exchange-rate caching

    • 10-minute TTL
    • automatic fresh fetch on a new calendar day
  • Added catalog currency usage tracking

    • every catalog request dispatches a queued job
    • job stores currency and request timestamp in the database
  • Added unit and feature tests

    • conversion logic
    • fallback provider behavior
    • cache behavior
    • EUR endpoints
    • usage tracking flow

Architecture notes

The solution uses a modular DDD-style structure for the Currency module.

Patterns used

  • Strategy — interchangeable exchange-rate providers via ExchangeRateProviderInterface
  • DecoratorCachedExchangeRateProvider and FailoverExchangeRateProvider
  • Dependency Injection — application layer depends on abstractions
  • Config-driven composition — providers are resolved from config/currency.php

Design decisions

  • exchange-rate retrieval is isolated from catalog retrieval
  • fallback and caching are separated from concrete provider implementations
  • catalog currency tracking is handled asynchronously via queue

Test Plan

Automated

Run:

php artisan test

…urrency usage tracking

- add EUR support for catalog and exchange endpoints
- implement exchange-rate provider abstraction
- add fallback provider
- add exchange rate caching
- track catalog currency usage via queued job
- add unit and feature tests
- update README
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.

2 participants