This repo contain a small and simple approach to a initial banking solution.
- Poetry dependency manager
- Python 3.9
brew install python
After getting poetry installed you should create a virtual environment and activate it
$ python3 -m venv env
$ source env/bin/activate
Then install dependencies using poetry:
$ poetry install
To execute the solution you have to provide a valid postgres connection:
$ DATABASE_URL="postgresql://user:password@localhost:5432/database"
$ uvicorn src.main:app --reload
After that you would be able to see following output:
INFO: Started server process [35568]
INFO: Waiting for application startup.
INFO: Application startup complete.
INFO: Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)
A mock data was created and pre-inserted using a proper orm mapper. Needed person data pre inserted can be viewed at http://127.0.0.1:8000/docs#/people/get_people_people__get
/openapi.json
especification is at http://127.0.0.1:8000/docs
Execute following commands:
cd ~/banking
docker build -t banking
docker run -p 80:80 -e DB_URL=postgresql://user:pw@host:5432/db banking
Now you can access docs at
pytest tests/routes/transaction.py
pytest tests/routes/account.py
- A basic layered design patter was used to keep dependency only for inner layer
- A much better approach would be use a complex messaging/events architecture as described here or at cosmic python.
- It's simple test relates a admin view where user who is getting and inserting data at resources has access to all data. Otherwise will be a huge security issue an user accessing other's data.
- I've used simple postgres dockerfile to support application. You can also ask me for already provisioned db url's.