Leetcord

June 2022

Github Link
Python
Django
AzureSQL
GraphQL
PYODBC
Heroku

Project Overview

Leetcord is a project designed to make programming interview problems more accessible and interactive for students. It consists of a Discors bot that tracks the progress of users and a website that displays the progress of users and allows them to compete with each other. This website also hosts writeups so that users can learn from each other by leaving hints and explanations for each other. The application's main focus was to be as cost-effective as possible, so it is hosted on a free Heroku dyno and uses a free AzureSQL cluster. The project may no longer be deployable for free due to changes in the Heroku pricing model.

Background

As I was preparing for CSCI 4041: Algorithms and Data Structures, a good friend of mine, Alan Hagedorn, encouraged me to use Leetcode more seriously in order to prepare. Throughout the first month of summer we did our best trying to solve problems and keep track using a Notion document. However, we found that not always being able to meet daily to test one another while also losing motivation to solve problems made it difficult to keep up with the schedule we had set for ourselves. Not only that, but the Notion document was becoming difficult to manage and query from as we added more and more problems to it. Hence, the idea for Leetcord came about.

Leetcord Notion

Our Notion document that Alan and I used to track our progress.

Development

When designing this application our first priority was to split tasks properly. Our first priority was creating endpoints for users to submit solutions and view them as well. Our second priority was to ensure that the Discord bot would also be able to give random questions based on difficulty and if it was premium or not. Lastly, we emphasized the cost-effectiveness of this project since we wanted other students to be able to use it as well.

Web application

The web application was built using Django and Bootstrap. Django's built in ORM was incredibly useful for interacting with the database and allowed us to quickly build pages up to scale with the data we had. Bootstrap was used to make the website responsive and to make it look more professional. The website acted as the main coordinator for data.

Discord bot

The discord bot was configured with SQLAlchemy to interact with the database. This did not use API calls to the website since we wanted to keep the bot operational even if the website was inactive. The bot also used quite a few tricks to generate a random row from a database table in order to provide users with a random question. The bot was also configured to generate a leeterboard for the top contributors to the server.

Deployment Configuration

The discord bot and web application needed information in order to boot up as shown below. The Discord Token and Secret Key were values generated by discord and django respectively. The Database information was provided by AzureSQL. The admin IDs were used to allow specific users the permission to add and remove users to a whitelist that would allow them to use the bot.

{ "DISCORD_TOKEN" : "YOUR DISCORD TOKEN", "SECRET_KEY" : "YOUR DJANGO SECRET KEY", "DBNAME" : "YOUR DB NAME", "DBUSER" : "YOUR DB USER", "DBPASS" : "YOUR DB PASS", "DBHOST" : "YOUR DB ENDPOINT", "ADMIN_IDS" : "DISCORD_ADMIN_1_ID,DISCORD_ADMIN_2_ID,..." }

Outcome

Overall this project was a success. Alan and I used it throughout the summer and were able to make significant progress on our Leetcode journey. While it initially was not incredibly popular, as the school year started up there were many student organizations which expressed interest in using it.

Leetcord Discord

The Leetcord Bot being used in a discord server.