/foreign-exchange-trades

Foreign exchange trades dummy web application, based on Django 2.1

Primary LanguageCSSThe UnlicenseUnlicense

foreign-exchange-trades

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

Deploy

Standalone

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

  1. Navigate to fetrades folder
  2. 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/.
  3. Run ./setup.sh. The script will ask the information to create a new admin user.
  4. Run ./up.sh to run the application on http://localhost:8000.

Production environment

A production environment with PostgreSQL, Gunicorn and Nginx.

Requirements Docker and Docker Compose.

  1. Navigate to docker folder
  2. 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.
  3. Run sudo docker-compose build to build the container
  4. Run sudo docker-compose up -d to run the application on http://localhost:[PORT].

Test

In a standalone deployment, use ./test.sh to run all the tests available. Internally it uses django.test module, a wrapper of unittest module.

Development

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