A simple API that simulates money transfers between different accounts. The project consists of two main models. The first, is for managing accounts (CRUD) while the other is for managing transactions between accounts. Next, I'll explain in detail the folder structure and how to run and test this project. The following diagram shows the relationship between an account and a transaction.
Notes: the application is only tested on Linux Ubuntu 18.04.
There are some points I want to make sure they are clear:
- I tried to keep simplicity as possible as I can so the objects are not complete.
- Only used the built-in libraries so I built my own mux to be able to add a parametered route.
- No database is used only memory to store objects.
- For thread-safe process I made a lock on balance change to make sure that no dirty-read operations.
api/Contains API methods separated by domain model.cmd/Here is the main package to start.internal/models/struct for domain modelsmultiplexer/instead of importing a third party library I stuck to only use built-in libraries and create my own mux.services/domain model services
Makefilecommands shortcutsTransfer Money.postman_collection.jsonexported Postman collection to facilitate API testing.
-
make runto run the API without the need to create an executable file. -
make buildcompiles the code and generates an executable file that will be located in bin directory. -
make testruns all tests. -
make curl-add-accountan example of using curl command to add a sample new account.