Skip to content

feat: real-time currency conversion with external API integration and fallback strategy#204

Open
wellnerds wants to merge 3 commits intoApiki:masterfrom
wellnerds:wellington-ferreira
Open

feat: real-time currency conversion with external API integration and fallback strategy#204
wellnerds wants to merge 3 commits intoApiki:masterfrom
wellnerds:wellington-ferreira

Conversation

@wellnerds
Copy link

Description
This PR enhances the currency conversion API by introducing real-time exchange rate retrieval via external API integration, along with a robust fallback mechanism to ensure reliability.

Key Improvements
🔄 Real-time currency conversion using external API
🛡️ Fallback strategy to handle API failures gracefully
🧱 Clean architecture with separation of concerns (Controller, Service)
📦 PSR-4 autoloading via Composer
🧪 Unit tests updated to support fallback and ensure reliability
🌐 RESTful endpoint design:
GET /exchange/{amount}/{from}/{to}
🧠 Technical Decisions
Implemented a dedicated service layer to isolate business logic and external API consumption.
Applied fallback rates to guarantee consistent responses even in case of external API downtime.
Ensured code readability, maintainability, and scalability following SOLID principles.
🔍 How to Test
composer install
php -S localhost:8000 src/index.php

Example:

http://localhost:8000/exchange/10/BRL/USD

This implementation focuses on production-ready patterns, including resilience, maintainability, and clear separation of responsibilities.

🙋‍♂️ Final Considerations

I’m available for any feedback or code review discussions.

Thank you for the opportunity — I’m ready to contribute and start immediately.

All requirements were implemented and validated locally (tests and lint passing).

I’m available for further improvements and feedback.

Looking forward to contributing to the team.

…allback strategy

- Removed manual rate parameter from endpoint
- Integrated external exchange rate provider (exchangerate.host)
- Added ExchangeRateService to handle API communication
- Implemented fallback mechanism for API failure scenarios
- Refactored ExchangeService to ensure resilience and reliability
- Updated routing to support dynamic rate resolution
- Adjusted unit tests to remove dependency on external services

This enhancement improves realism, reliability and aligns the application with production-ready standards.
@wellnerds
Copy link
Author

Ready for review. All requirements implemented and tested locally.

@wellnerds
Copy link
Author

wellnerds commented Mar 24, 2026

🚀 Improvements: Real-Time Currency Conversion + CI Fix

This PR enhances the application by introducing a real-time currency conversion mechanism using an external API, along with a robust fallback strategy.

🔧 What was done

  • Implemented external exchange rate provider
  • Removed hardcoded rate dependency
  • Added fallback mechanism for resilience
  • Refactored service layer for better separation of concerns
  • Fixed merge conflicts in composer.json
  • Regenerated composer.lock to ensure dependency consistency

✅ Why this matters

  • Improves realism with live exchange rates
  • Increases reliability with fallback handling
  • Aligns project with production-ready standards
  • Restores CI pipeline integrity

🧪 Tests

  • Existing tests updated and passing
  • Application tested via endpoint:
    /exchange/{amount}/{from}/{to}

This implementation focuses on maintainability, resilience, and clean architecture principles.

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