Payments engine prototype processes transactions in a csv file and outputs account balances into stdout as csv.
Unit tests cover de- and serialization, happy paths, exceptions.
cargo test
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
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.