Giter Club home page Giter Club logo

payments-engine's Introduction

Payments engine

A payments engine which holds account and transaction ledgers and execute operations like deposits, withdrawals, disputes for previous deposits, resolving and chargebacks for disputes.

Overall system characteristics

Efficiency

Transactions are read/processed from a CSV input as a stream through an asynchronous multi-threaded runtime, by using tokio, csv-async and serde.

Safety and robustness

All operations over numbers with decimals are done by using BigDecimal struct from bigdecimal crate. We shouldn't be concerned with overflow because of this, but underflow can be possible, so we defend against it by emitting an error and gracefully handling it so that we don't error out and stop the stream processing because of an invalid transaction.

Maintainability

The code base relies on a few abstractions:

  • AccountsDal - a data access layer which provides an interface over all clients' accounts by not being concerned with the underlying storage solution.
  • TxsDal - a data access layer similar to the AccountsDal but for transactions storage.
  • The Engine::handle_txs method which processes TXs by consuming them from a stream received as a parameter, that an implementation for AsyncRead + Send + Unpin. This is the basis for consuming TXs from both a tokio::io::File and tokio::io::TcpStream, so the business logic should be usable inside an asynchronous multi-threaded web server.

Correctness

The payments engine main logic is tested through unit tests for every transaction and the majority of corner cases worth testing.

payments-engine's People

Contributors

iulianbarbu avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.