Design and implement a RESTful API (including data model and the backing implementation) for money transfers between accounts. Any framework could be used except Spring; the code should be workable and testable and with proper UT.
Asked in the take-home assignment stage. one week to submit.
For grading, implement transfer(accounts, source_account, destination_account, amount, idempotency_key, processed_keys). accounts maps account IDs to {balance: integer} objects. Return {status: integer, body: object} and mutate balances only for successful transfers. Reusing an idempotency key with the same request returns the saved response; reusing it with different parameters returns 409.
Example: transferring 250 from Alice with 1,000 to Bob with 500 returns status 201 and balances 750 and 750. Insufficient funds return 409 without mutation.
def transfer(accounts, source_account, destination_account, amount, idempotency_key, processed_keys):