This server is a simple implementation of a bank's internal transfers system, allowing users to create accounts, and transfer funds betweeen them.
To run the server, you will need a .env
file, which isn't kept on git for security purposes.
To set it, rename or copy sample.env
to a file called .env
:
Shell command on Linux / MacOS:
cp ./sample.env ./.env
There are two ways to run the server locally:
The easiest way to run this project, including a database, is using docker-compose:
docker compose up
If you already have a PostgreSQL server up and .env confugred, you can run the server directly:
First, install the server's requirements locally:
pip install -r requirements.txt
Then run one of the following commands to run the server:
uvicorn src.main:app
fastapi dev src/main.py
Once started, regardless of method, the server should be available on http://localhost:8000
You can find the automatically generated Swagger documentation at http://localhost:8000/docs
- This server currently does not implement any security or authentication mechanisms, but adding a JWT-based auth system would be quite simple to implement, to stop things such as users sending requests to send funds from another user's account.
- Due to SQLAlchemy being sensitive to the load order of models, they are for now all defined in models.py.
In a production-ready environment, I would refactor it properly, so they would be in separate files under the
/src/models
module. - There are multiple API and unit tests that I would like to implement, but decided to cut for time.
- Only basic type input validation is currently implemented. e.g. validating a user's email, a transaction's amount being a positive number, etc are not currently supported.