exchange-rate-calculator

module
v0.0.0-...-28981a6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 30, 2024 License: MIT

README

Exchange Rate Calculator API

Description

This project is an Exchange Rate Calculator API designed to provide real-time conversion rates between cryptocurrency and fiat currencies. The API accepts a source and target currency along with an amount, and returns the converted amount using the latest exchange rates. The exchange rates are updated every minute through a background task.

Features

  • Real-Time Conversion: Converts between specified source and target currencies in real-time.
  • Background Rate Updates: Exchange rates are updated every minute in the background.
  • Database-Driven: Exchange rates are fetched from a PostgreSQL database.
  • Currency Availability: The API only processes conversions for available currencies. Unavailable currencies will return an error.
  • Supported Currencies: EUR, USD, CNY, USDT, USDC, ETH.

Technical Requirements

  • Language: Go 1.20 or higher
  • Logging: Using zerolog
  • Data Structures: Go data structures for storing currency pairs
  • Framework: Go Fiber for the API
  • Performance: API response time should not exceed 100ms
  • Exchange Rates API: Using FastForex for obtaining exchange rates
  • Database: PostgreSQL for storing exchange rates

Clean Architecture

Project was completed via the Clean Architecture practises

The Clean Architecture

Relations between Clean Architecture layers and project folders:

Template path Clean Architecture Layer Color
internal/entity Yellow (Enterprise Business Rules)
internal/usecase Red (Application Business Rules)
internal/adapter Green (Interface Adapters)
internal/infrastructure Blue (Frameworks & Drivers)

Open API Spec

Dependencies

Infrastructure:

  • Postgres 12
  • Fast Forex API

Start

  • Add FAST_FOREX_API_KEY to the .env file (See: .env.example file)
make start
  • Wait for the "INFO Server started on: ${...}" message
make logs-httpapi
make start-swagger

Update currency pairs

If you want to update currency pairs then update - internal/infrastructure/config/currency-pairs.json file

It is an embedded file that processed when app inited

Directories

Path Synopsis
cmd
internal
usecase/currency/mock
Package mock is a generated GoMock package.
Package mock is a generated GoMock package.
pkg
third_party

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL