A Django App. Meant as a display of some backend programming skills. A Frontend App is also available here. This is already deployed to Heroku for convenience. It can be found on banistmo-back.herokuapp.com
An index of the whole set of resources is available on banistmo-back.herokuapp.com
Make sure you have:
- Python 3.6 installed - see guides for OSX, Windows and Linux
- Pipenv installed locally. Accomplish this by running
pip install pipenv
. - Postgres installed locally.
$ git clone git@github.com:sansagara/banistmo.git
$ cd banistmo
$ pipenv --three
$ pipenv install
$ pipenv shell
$ createdb banistmo
$ python manage.py migrate
$ python manage.py collectstatic
$ python manage.py runserver
Your app should now be running on localhost:8000.
This project is already configured to be run on heroku easily. If you want to make your own deployment, follow these instructions:
- Create a free Heroku Account
- Install the Heroku Toolbelt for your system.
- Login using the account details you used then creating your Heroku account.
$ heroku login
- Prepare the app.
$ git clone git@github.com:sansagara/banistmo.git
$ cd banistmo
- Deploy the app
$ heroku create
$ git push heroku master
- Ensure that at least one instance of the app is running
heroku ps:scale web=1
- Install the postgresql addon for the app.
https://elements.heroku.com/addons/heroku-postgresql
- Migrate the database and open
$ heroku run python manage.py migrate
$ heroku open
or instead, click on this button to deploy automatically:
The Django Admin page can be used to make CRUD operations on Users and Transactions.
The superadmin username and password for the Live deployment is Banistmo:Banistmo123
This comes with a companion dataset. It can be inserted to your chosen database backend with the import_dummy_data
management command.
You can run it with python manage.py import_dummy_data
.
- The identifier of the rows is zero-indexed.
- The date may require parsing before being inserted into a DB engine.
- The UUID must be an integer.
- The TXN must be a signed decimal.
- Records with a missing date should be inserted, but considered in the results.
- The records with missing date must be shown to the end user in some way, without affecting aggregates or accounts.
For more info, view the R Notebook here
This is a RESTFul application made as the backend for a Single-page Application (SPA) or App. A companion app was also developed and is available here The API is done with [django-rest-framework] and [Djoser]. Each API endpoint is browsable, which means it can be checked on the browser to check its purpose and inspect results. Authentication is possible via Session (for the browsable API) and Token (For the SPA).
The API docs can be found on the /transactions/docs
route. On the already deployed application, it can be found here
A postman collection is provided for convenience.
One of the requirements for the challenge involved coming up with a solution for long-running API endpoints on an async manner. There are multiple ways to handle this scenario: task schedulers, threads, and queues. I went the queue route with Redis, as it is lightweight, open-source and easy to install and setup. This will allow to set a worker, who will dispatch API requests as server resources become available, using Redis queue system.
You can install redis on your local system.
However, a Redis Heroku addon is also available and you can use it even for your local installation.
The Redis URL for the Live deployment in case you want to use it is:
redis://h:pdd34a64d7788396ebae5316a9fad2c46e77c3bdca863b4706d3c8aa4a7119e31@ec2-34-239-85-133.compute-1.amazonaws.com:32939
The project's Procfile is set to automatically start workers on deployments.
Django-rq is used to simplify setup. Just specify the URL of the redis service on the RQ_QUEUES
on settings.py
RQ_QUEUES = {
'default': {
'URL': os.getenv('REDIS_URL', 'redis://localhost:6379/0'), # R
'DEFAULT_TIMEOUT': 500,
},
}
The queues information can be seen from the Django Admin page, specifically on /queues
. (Live).
- https://www.djangoproject.com/
- http://www.django-rest-framework.org/
- https://github.com/sunscrapers/djoser
- https://github.com/ui/django-rq
- https://redis.io/
- https://stackoverflow.com/questions/32681602/django-rest-framework-make-asynchronous-request-to-respond
- https://stackoverflow.com/questions/27881706/why-should-i-build-an-api-with-an-asynchronous-non-blocking-framework
1.0
Do What The F*ck You Want To Public License (wtfpl)