Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Graeme Hedges - Backend Task (Exchange Rate Updater .NET) #674

Open
wants to merge 35 commits into
base: master
Choose a base branch
from

Conversation

GraemeHedges
Copy link

Task

This PR addresses the requirement to implement an exchange rate provider for the Czech National Bank, using their publicly available APIs to source the exchange rate data for specifically requested currencies. The currencies are to be returned to the user in a console application.

Approach

I have approached this task with the idea of creating an MVP that satisfies the requirements. That means that I have retained the console application, and extended it's functionality to return the required data. My main focus was to keep the code clean, clear and SOLID so as to be easily maintainable and extensible. I had considered replacing this console application with a minimal API for example, but in the end decided that my focus here should be on delivering the requirements as written. I expect that this program would eventually service a number of front ends and at that point, adding an API would be more appropriate.

I have implemented logging and caching - these are simple implementations appropriate for a console application. For logging, I have kept log messages clear and simple, with only one log instance requiring structured logging. These logs are simple console logs. In a production app, I would expect to connect to a provider such as application insights. Similarly, for the caching that is a simple in memory cache - it would be preferable to implement a separate caching source running independently
from the main application, such as Redis for example, to increase the resilience of the cache. I have set a short time to live for the purposes of this test, but in a real world solution would probably look to refresh the cache inline with source API.

I have added unit tests for updated Provider and Service classes. For the sake of brevity I have used multiple asserts in each test scenario, as I believe that keeps test code clearer and easier to read, without sacrificing testing the classes logic. Although not always the most reliable of metrics, both of these classes do have 100% code coverage.

More generally, I have updated the project to .NET 8, and brought the program.cs file in line with modern coding approaches. I have used global usings to reduce 'noise' in files, and have used file scoped namespaces to make the code easier to read. I have used IHttpClientFactory to create the HttpClient and type it, as well as added standard resilience handling to deal with failed calls. In short, I have applied modern .NET coding practices where possible.

Improvements

  • Implement external services for logging and caching
  • Accept user input to search for specific currency or a list of currencies, for specific dates
  • Allow users to force the application to query the banks API and not use the cache
  • Provide an API endpoint for potential future frontends or other applications to utilise

…ary), added Hosting and HTTP to allow for IHttpClientFactory implementation
…ded interface, changed transient service registration to use interface
…ateService to use todays date, Removed temp ExchangeRateUpdater
…, fixed tests now that Provider is async again, added resiliance
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