Currency Rate Service

Autonomous gRPC Microservice for Exchange Rate Management

Personal Project by Igor Kudinov

Standalone Go microservice that autonomously collects, stores, and serves live and historical currency exchange rates to applications within the Expense Tracker ecosystem via gRPC. Addresses multi-currency visibility requirements and establishes the first inter-service communication pattern in the evolving microservice architecture.

Key Features

  • Autonomous polling engine with per-pair goroutines and configurable intervals
  • Primary + backup provider failover with automatic staleness flagging
  • gRPC API on :50052 — GetRate, GetRates (batch), ListSupportedPairs
  • Historical rate accumulation from day one (full insert history)
  • Exact decimal rate — rate_decimal returns the stored NUMERIC(20,10) digit for digit; no float between provider JSON and database
  • Database-driven config — pairs, providers, intervals reloaded from the DB every 60 s, no restart
  • Generic JSON adapter — new REST providers added via config only (no code changes)
  • HTTP health endpoints on :8090 — liveness (/healthz) and readiness (/readyz)
  • Structured JSON logging (slog), gRPC reflection, graceful shutdown
Project Status

v0.2.0 (2026-10-05): core implementation (Stages 1–6) plus the package for Crypto Account Service. The service polls three external providers (fawazahmed0, ExchangeRate-API, Frankfurter) with a primary and a backup per pair, stores rates in PostgreSQL, serves them via gRPC, and exposes health endpoints — all components verified manually. Five fiat pairs, each served only in its stored direction: RSD→EUR, RSD→USD, EUR→USD, GBP→USD, CHF→USD. Every rate comes as rate (double) and as the exact decimal string rate_decimal; pairs and providers reload from the database without a restart. Consumers: Expense Tracker and Crypto Account Service. gRPC methods GetRate, GetRates, ListSupportedPairs tested with grpcurl. CRS has run locally only. Next: E2E testing and Docker deployment (planned).

Repository Structure

currency-rate-service — standalone microservice repository with independent deployment lifecycle.

/cmd/server — service entrypoint: config loading, DB connection, component wiring, graceful shutdown.

/internal/adapter — RateProvider interface, generic JSON adapter (URL templates + JSONPath), adapter registry.

/internal/polling — scheduler with per-pair goroutines, failover logic, config reload loop, pgx type converters.

/internal/grpc — gRPC server handlers + protoc-generated pb files (GetRate, GetRates, ListSupportedPairs).

/internal/health — HTTP health handler: /healthz (liveness) and /readyz (readiness + JSON status).

/internal/repository — sqlc-generated type-safe queries for all 5 tables.

/migrations — 6 golang-migrate migrations with seed data (pairs, providers, assignments, rates, health; 006 adds GBP→USD and CHF→USD).

/proto — protobuf definition for CurrencyRateService.

/Documentation — BRD, BRD Amendment 1 and SRS.

Tech Stack

Go gRPC protobuf PostgreSQL sqlc pgx/v5 golang-migrate slog Docker (planned) buf / protoc HTTP/REST clients