This task is implementation of a simple dummy payment engine that processes the payments accounts.
- Implemented with Python, using
csv
library for reading the input data. - CSV schema is checked with
csvvalidator
lib (to be replaced once more time available.) - Logging is generated in
./tmp
library usingstructlog
. In general current state of logging should be improved, but it is good for debugging. - Unit tests are implemented with
pytest
using monkeypatching technique to inject data.
- python >= 3.6
This solution is tested on macos 12.0.1 with python 3.8. But in general it should be cross platform solution
-
Install
virtualenv
:pip3 install virtualenv
-
Create virtual environment:
python3 -m venv venv
-
Activate virtual environment
source venv/bin/activate
-
Install dependencies:
pip3 install -r requirements.txt
Note: all the setup can be automated later
python -m pytest tests
Running the tests will generate the log under ./tmp/logs
.
python3 payment_engine.py <path_to_csv>
- deposit and withdrawal transactions follow the same dispute process and impact the balances the same.
- If dispute on the transaction id is over and account is not locked - another dispute can occur
- add more unit tests
- improve logging
- Solution is not tested with big amounts of data. Reading everything, and storing everything in memory might not be the best solution. For reading we might need to use generator to yield one row at a time. For storing the already processed transactions TBD.
- Replace
csvvalidator
with more supported library (or fork and patch existing one)