Backend Documentation (backend) - DSGT-DLP/Deep-Learning-Playground GitHub Wiki

About

This page contains documentation for the files in the /backend directory of the Github repo. This page is regularly updated when new changes are added to these files.

Sub-directories

/aws_helpers/dynamo_db_utils
/common
/dl
/ml

Driver (driver.py)

This file is a very important file in the backend. It essentially acts as the point of entry into the backend

Functions

  • ml_drive(): Function that trains classical ML model based on user specifications
  • dl_drive(): Function that trains classical DL model based on user specifications
  • root(): Flask Route to send files from one directory to another
  • train_and_output(): Flask-SocketIO event handler that receives data regarding the user's DL/ML model, and calls dl_drive or ml_drive to train the model (frontend will send the event using socket.io-client and the event name runTraining). It sends back the results to the frontend in the form of an Event.
  • send_email_route(): Flask-SocketIO event handler to send an email notification to the user about their model + training result attachments. This function acts as a wrapper to an AWS API Gateway endpoint that invokes a lambda to send email notification (via AWS SES) through the send_email() function. TLDR, the flow is send_email_route() -> send_email() -> API Gateway -> AWS Lambda -> AWS SES
  • frontend_log(): Flask-SocketIO event handler that logs any log message sent from the frontend onto the Flask Debug panel in the console.
  • update_user_settings(): Flask-SocketIO event creator that sends an Event containing the result of updating an authenticated user's data (TODO).
  • send_progress(): Flask-SocketIO event creator that sends an Event containing the model's real-time training progress to the frontend.
  • getUserProgressData(): Flask-SocketIO event handler that, given a userID, fetches the corresponding user progress data (consisting of points earned for each question in each module/section) from the userProgress DynamoDB table and returns it to the frontend
  • updateUserProgressData(): Flask-SocketIO event handler that, given a userID, moduleID, sectionID, and questionID, updates the DynamoDB table entry for the user by incrementing the respective point value.

socket.io

Refer to Frontend-Backend Communication Documentation for the usage of socket.io for this dual asynchronous communication between backend and frontend.

Running the backend

Make sure that your terminal is at ~/Deep-Learning-Playground and run python -m backend.driver. The -m is a tag to "run as module"

Note that we run the app on host 0.0.0.0 to allow for backend and frontend to be served on the same port. It's crucial for our app to work properly in production.