This project is a demo of a simple bank accounting system, it features the following actions:
- Create an account with an initial deposit amount
- Transfer between accounts
- Consult account balance
To achieve this, the project implements a simple Double Entry Bookkeeping (read more about it in the project wiki) system, that can be expanded upon. The design decisions, trade-offs and how to extend the system can be found on the CONTRIBUTING.md file.
- Bank Accounting
- Table of Contents
- Getting Started
- Running Tests
- Endpoints
- Contributing
- Design Decisions
These instructions will walk you through on how to run this project locally, for development and testing purposes. There are no production deployment instructions, as this project isn't being used in production.
To run this project, you can use Docker or install Elixir, Phoenix and PostgreSQL locally.
Install Docker via the official installation guide Install Docker Compose also via the official installation guide
After that, it should be as simple as running the following command
docker-compose up
You will still retain live reload functionalities using docker because it's mounting your project directory into the container.
The project image also installs PostgreSQL client, so if you need you can attach to the container and use psql there.
Elixir has a great installation guide that should cover your needs. After installing Elixir, follow the Phoenix installation guide. And finally, install PostgreSQL 12 following this installation guide.
Finally, you can run the project. First, change the database hostname, user and password at config/dev.exs
to what you configured during the PostgreSQL installation.
After that, create the database with the command below.
mix ecto.create
Run the migrations with
mix ecto.migrate
With the database created, create the seed data with
mix run priv/repo/seeds.exs
This should leave you with a properly configured development environment. After that, run the following command
iex -S mix phx.server
Run the following command to run the database:
docker-compose up db
Then run the following command to run the test suite:
docker-compose run web mix test
First change the db hostname at config/test.exs
, as it assumes the Docker environment is being used.
To run the test suite, run the following command:
mix test
If you're testing manually without Docker, be sure to run the seed.exs
script found at priv/repo/seeds.exs
with the following command:
mix run priv/repo/seeds.exs
The project has 4 endpoints:
auth_path POST /api/login BankAccountingWeb.AuthController :login
auth_path POST /api/signup BankAccountingWeb.AuthController :signup
ledger_path POST /api/transfer/:from/:to BankAccountingWeb.LedgerController :transfer
ledger_path GET /api/balance/:account_id BankAccountingWeb.LedgerController :balance
The POST endpoints expect a JSON object as body.
/api/login
expects:
{
"email": "email_address",
"password": "password"
}
/api/signup
expects:
{
"email": "email_address",
"password": "password",
"initial_deposit": 42
}
/api/transfer/:from/:to
expects:
{
"amount": 42
}
Please read CONTRIBUTING.md
Please read Design Decisions section found at CONTRIBUTING.md