- This project assumes you're on Python3
pip3 install -r requirements.txt
- Install and create postgres db + user.
- Update the
DATABASE
insettings.py
with the step 3 info. python manage.py migrate
python manage.py populate_exchange_rates
python manage.py runserver
- Go to your browser and check http://127.0.0.1:8000/api/rates/ to see the expected output
- http://127.0.0.1:8000/api/rates/?currency=USD will give filtered output.
- Run
pytest
to run the tests. - As a proper app, we would run celery too as such
celery -A rator worker --loglevel=info
This app reads the RSS feeds for each currecy's exchange rate from https://www.ecb.europa.eu/home/html/rss.en.html, saves it into the database and exposes it via an API endpoint.
- The database consists of a single table that stores the currency <-> rate mapping
- All rates are equivalent to 1 EURO.
- Contains a single endpoint with filters to fetch the exchange rates.
- Celerybeat
The feeds are updated at 2.15PM. Need to figure out the timeone and setup celerybeat to run the task and update the exchange rates on a daily basis.
- Redis cache
Since the rates are updated only on a daily basis, setup redis
cache with daily expiry to serve the exchange rates. Would probably
use redis-py
library to achieve this.
- urllib mocking
The tests now mock the requests call with the proper HTML response
but mocks the feedparser.parse
call directly since that was
taking some time to figure out how to mock the correspoding
urllib methods that feedparser uses underneath.