gRPC service that fetches currency exchange rates from exchangerate-api.com and converts amounts between currencies. Rates are cached in memory using the API's own update schedule as TTL, so you're not paying for the same request twice.
- Docker + Docker Compose
- Make
- Postman or grpcurl (for testing)
Add your API key to .env:
EXCHANGE_RATE_HOST=https://v6.exchangerate-api.com/v6
EXCHANGE_RATE_TOKEN=your_key_here
Then start the server:
make upServer listens on :50051.
make up # build image and start container
make down # stop container
make proto # regenerate Go code from .proto files
make buf-lint # lint proto files
make buf-breaking # check for breaking changes vs main
make build # compile binary
make lint # run golangci-lint
make tidy # go mod tidyTwo RPCs defined in proto/exchange/v1/exchange.proto.
GetExchangeRate — get the rate between two currencies
// request
{ "from_currency": "EUR", "to_currency": "GBP" }
// response
{ "from_currency": "EUR", "to_currency": "GBP", "rate": 0.8652 }ConvertCurrency — convert an amount
// request
{ "from_currency": "EUR", "to_currency": "GBP", "amount": 100 }
// response
{
"from_currency": "EUR",
"to_currency": "GBP",
"amount": 100,
"converted_amount": 86.52,
"rate": 0.8652
}Currency codes must be valid ISO 4217 (3 uppercase letters). Anything else gets rejected before hitting the API.