/payments-engine

Payments engine prototype in Rust

Primary LanguageRustApache License 2.0Apache-2.0

Payments Engine

Payments engine prototype processes transactions in a csv file and outputs account balances into stdout as csv.

Build and test

Unit tests cover de- and serialization, happy paths, exceptions.

cargo test

Usage

The CLI takes only one argument the csv file with transactions and outputs into stdout. Errors go into stderr.

cargo run -- transactions.csv > accounts.csv

Design

Domain entities:

  • Account can serialize into csv with care taken to round amounts, keeps a list of its transactions in memory and has logic to process transactions;
  • Transaction can deserialize from csv.

Engine takes its input from a Read, processes transactions and outputs accounts into a Write. This is done to accomodate different streams, for example, the same method input takes csv from a file as well as hardcoded in unit tests.