Skip to content

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

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

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

Conversation

@wellnerds
Copy link
Copy Markdown

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
Copy Markdown
Author

Ready for review. All requirements implemented and tested locally.

@wellnerds
Copy link
Copy Markdown
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.

@wellnerds wellnerds marked this pull request as draft March 24, 2026 13:04
@wellnerds wellnerds marked this pull request as ready for review March 24, 2026 13:04
@wellnerds
Copy link
Copy Markdown
Author

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.

@wellnerds wellnerds closed this Mar 24, 2026
@wellnerds wellnerds reopened this Mar 24, 2026
@wellnerds
Copy link
Copy Markdown
Author

Hi team,

It looks like the CI workflows are awaiting maintainer approval to run.

All changes were validated locally:

  • composer validate ✅
  • tests executed successfully ✅
  • lint checks passed ✅

Please let me know if any adjustments are needed. Happy to iterate quickly.

Thanks!

@wellnerds
Copy link
Copy Markdown
Author

Added PHPStan dependency and validated locally.

All checks should now pass once CI is approved to run.

Please let me know if any further adjustments are needed.

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