Dummy foreign exchange trades web application, based on Django 2.1
NOTES:
- Two decimal precision for trade amounts
- Four decimal precision for trade rate
- MAX trade amount: 99,999,999.99
The standalone deployment uses a local database from SQLite and a lightweight server, and it is not meant for production.
Requirements python 3.7 and pipenv.
WARNING: DO NOT USE THIS SERVER IN A PRODUCTION SETTING
- Navigate to fetrades folder
- Copy fetrades/settings.ini.example to fetrades/settings.ini and edit the latter:
- Set
WEBNAME
to the title of the website - Set
SECRET_KEY
to an alphanumeric random string - Set
DEBUG=False
for production-like environments - Set the list of allowed hosts in
ALLOWED_HOSTS
, separated by comma. - Set
FIXER_API_KEY
to the appropiate fixer.io api key. Get one for free at https://fixer.io/.
- Set
- Run
./setup.sh
. The script will ask the information to create a new admin user. - Run
./up.sh
to run the application on http://localhost:8000.
A production environment with PostgreSQL, Gunicorn and Nginx.
Requirements Docker and Docker Compose.
- Navigate to docker folder
- Copy example.env to .env and edit the latter:
- Set
WEBNAME
to the title of the website - Set
SECRET_KEY
to an alphanumeric random string - Set
DEBUG=False
for production-like environments - Set the list of allowed hosts in
ALLOWED_HOSTS
, separated by comma. - Set
FIXER_API_KEY
to the appropiate fixer.io api key. Get one for free at https://fixer.io/. - Change
PORT
to serve the website in a port different from 1337. - Change
SQL_DATABASE
to use a different database name. - Change
SQL_USER
to use a different user name to access the database. - Change
SQL_PASSWORD
to use a different password to access the database.
- Set
- Run
sudo docker-compose build
to build the container - Run
sudo docker-compose up -d
to run the application on http://localhost:[PORT].
In a standalone deployment, use ./test.sh
to run all the tests available. Internally it uses django.test module, a wrapper of unittest module.
The source code follows the pep8 style guide, using flake8 and pylint as linters.
To make modifications, the standalone deployment is the right one. Use /setup-dev.sh
instead of ./setup.sh
to install autopep8, flake8 and pylint.
Suggestions to improve:
- Validate data again on the server against Fixer.io, before creating the trade.
- Ensure uniqueness in trade Id generation, by checking if the generated id exists in the system.
- Make django image able to run independently from docker-compose/postgres
- Build the docker image automatically by cloning the repository inside the container