Assignment 2: Build your own backend system

In Assignment 1 you created an API that saved, edited, and deleted tasks. The tasks were saved on the memory of the local server. If your server were to be restarted all of the tasks would be deleted.

Note: Please see BCourses under the submission page for this assignment for the url to GitHub classroom to create your own repository for this assignment. Please use your new repository for all work on this project.

You have two main tasks to help expand your task application:

Persist your tasks inside a relational database

1) Move your assignment 1 server into it’s own docker container
2) Run a second docker container running a mysql database. Create your database and a single table named “tasks” with the following fields:

– id (integer autoincrement primary key)
– task (string)
– is_completed (boolean)

3) Modify your assignment 1 code to connect to your MySQL database docker container to persist task data. Your existing API should work as expected, but your tasks should not disappear when the server container or the database container is shut down. You should also be able to directly access your database container and query tasks that have been saved

Extra Credit 1: Send an email when a task is completed

1) Add a new column to tasks called “notify”. This is a string that will contain a single email address.
2) When a user completes a task (i.e. is_completed is set to True), you should send an email to that email address.
3) Please create an account at Mailgun.com, and check the docs here and here.
4) Send a POST request to Mailgun that sends a mail to the email specified in notify.

Extra Credit 2: Use an asynchronous queue

Instead of directly sending an email when is_completed is True, queue the message and set up an asynchronous task queue that listens to the queue and sends the POST request to Mailgun. Will need to set up two more containers: one with RQ installed, as well as another that is running Redis.