This solution provides a set of applications for fetching, storing, and displaying currency exchange rates using the Fixer.io API. It consists of the following projects:
- ExchangeRateCalculator: A .NET class library that provides the core logic for calculating currency exchange rates using the Fixer.io API. It also includes a console application for interactive use.
- CurrencyRateUpdater: A .NET console application that runs as a background service to periodically fetch and store the latest exchange rates in a PostgreSQL database.
- CurrencyApi: A .NET Minimal API that exposes endpoints for retrieving the latest and historical exchange rates from the database or Fixer.io API.
- Web: An ASP.NET Core MVC application that provides a simple web UI for interacting with the CurrencyApi, displaying exchange rates, and visualizing historical trends with a chart.
- .NET 9
- PostgreSQL database server
- A Fixer.io API key
- Clone the repository:
git clone https://github.com/saadatzi/Riverty
- Database:
- Create a PostgreSQL database (e.g., named
Riverty
). - Update the
PostgreSQLConnection
connection string in theappsettings.json
files ofExchangeRateCalculator
andCurrencyApi
with your database credentials.
- Create a PostgreSQL database (e.g., named
- API Key:
- Obtain a Fixer.io API key from https://fixer.io/.
- Set the
FixerApiKey
in theappsettings.json
files ofCurrencyRateUpdater
,ExchangeRateCalculator
, andCurrencyApi
.
- API URL (WebUI):
- Update the
ApiSettings:BaseUrl
inWeb/appsettings.json
to point to the URL where yourCurrencyApi
is running (default:http://localhost:5000
).
- Update the
s
-
Build the solution:
dotnet build
-
Run EF Core Migrations (CurrencyRateUpdater):
cd CurrencyRateUpdater dotnet ef database update
-
Run the projects:
- Start the
CurrencyApi
project first. - Then, start the
CurrencyRateUpdater
project (it will run in the background). - Finally, start the
Web
project.
You can run each project using
dotnet run
from their respective project directories or use an IDE like Visual Studio or VS Code to start them. - Start the
- CurrencyApi: Access the Swagger UI at
http://localhost:5000/swagger
(or your configured URL) to explore and test the API endpoints. - Web:
- Currency Conversion: Fill out the form on the home page to perform currency conversions using the latest or historical rates.
- Historical Rates: Navigate to the "Historical Rates" page (you might need to add a link in the navigation) to view a chart of historical exchange rate trends. Enter a currency code, start date, and end date, then click "Get Rates."