Thank you for your interest in contributing to MIT-Tab! This document provides guidelines and information for developers looking to contribute to the project.
- Code of Conduct
- Getting Started
- Development Setup
- Development Guidelines
- Submitting Changes
- Getting Help
We are committed to providing a welcoming and inclusive environment for all contributors. Please be respectful and professional in all interactions.
MIT-Tab is a web application built with Django and used to manage APDA debate tournaments. Before contributing:
- Familiarize yourself with the user documentation to understand how the application works
- Set up your development environment following the Development Setup guide below
- Check the issues page for tasks that need help
This guide will help you set up a local development environment for MIT-Tab. The setup process varies by operating system - expand the section for your platform below.
Before you begin, ensure you have:
- Git installed
- A text editor or IDE
- Basic familiarity with terminal/command line
macOS Setup
If you don't already have a package manager, Homebrew is recommended for macOS. See https://brew.sh/ for installation instructions.
git clone https://github.com/MIT-Tab/mit-tab.git
cd mit-tabOpen the mit-tab directory in your IDE.
Install MySQL using Homebrew:
brew install mysql
brew services start mysql
mysql_secure_installationThe mysql_secure_installation command will prompt you to set a root password and configure security settings.
Log into MySQL and create the database:
mysql -u root -pRun these SQL commands to create the database and user for the application:
CREATE DATABASE mittab;
CREATE USER 'django'@'%' IDENTIFIED BY 'your_password';
GRANT ALL PRIVILEGES ON *.* TO 'django'@'%' WITH GRANT OPTION;
FLUSH PRIVILEGES;
\quit;Copy the example environment file and update it with your MySQL credentials:
cp .env.example .envEdit .env and update the MySQL settings to match what you set in Step 3.
Install NVM (Node Version Manager) to manage Node.js versions. This allows you to easily switch between Node versions for different projects. Installation instructions are available at the NVM repository.
Once NVM is installed, use it to install Node.js. The project may specify a required version in .nvmrc:
nvm install
nvm useIf there's no .nvmrc file, check package.json for the required Node version.
Install pyenv to manage Python versions. This is similar to NVM but for Python - it lets you install and switch between different Python versions. Installation instructions are available in the pyenv documentation.
Once pyenv is installed, install the Python version required by the project (check the Pipfile for the required version):
pyenv install <version>
pyenv local <version>The local command sets the Python version for this project directory.
Install pipenv and the project dependencies:
pip install pipenv
pipenv installIf the install fails, try running it a second time.
npm installRun migrations and load test data:
pipenv run python manage.py migrate
pipenv run python manage.py loaddata testing_dbpipenv run ./bin/dev-serverThe application should now be running at http://0.0.0.0:8001
Default login credentials:
- Username:
tab - Password:
password
Windows Setup (WSL)
It is strongly recommended to use Windows Subsystem for Linux (WSL) for development on Windows. Install it by running this command in PowerShell or Command Prompt:
wsl --installThis will install Ubuntu by default. Once installed, create a username and password when prompted.
If using VS Code, install the "Remote - WSL" extension, then click the blue button in the bottom-left corner, select WSL, choose Ubuntu, and follow the prompts. This allows you to develop directly in the Linux environment.
Now that you have a Linux environment through WSL, follow the Linux Setup (Debian/Ubuntu) instructions below.
Linux Setup (Debian/Ubuntu)
git clone https://github.com/MIT-Tab/mit-tab.git
cd mit-tabOpen the mit-tab directory in your IDE.
Update your package list and install MySQL:
sudo apt update
sudo apt install mysql-server libmysqlclient-devThe libmysqlclient-dev package is needed to build the Python MySQL client.
Log into MySQL and create the database:
sudo mysql -u root -pRun these SQL commands to create the database and user for the application:
CREATE DATABASE mittab;
CREATE USER 'django'@'%' IDENTIFIED BY 'your_password';
GRANT ALL PRIVILEGES ON *.* TO 'django'@'%' WITH GRANT OPTION;
FLUSH PRIVILEGES;
\quit;Copy the example environment file and update it with your MySQL credentials:
cp .env.example .envEdit .env and update the MySQL settings to match what you set in Step 2.
Install NVM (Node Version Manager) to manage Node.js versions. This allows you to easily switch between Node versions for different projects. Installation instructions are available at the NVM repository.
Once NVM is installed, use it to install Node.js. The project may specify a required version in .nvmrc:
nvm install
nvm useIf there's no .nvmrc file, check package.json for the required Node version.
First, install dependencies needed to build Python:
sudo apt-get install libffi-dev python3-venv python3-pipInstall pyenv to manage Python versions. This is similar to NVM but for Python - it lets you install and switch between different Python versions. Installation instructions are available in the pyenv documentation.
Once pyenv is installed, install the Python version required by the project (check the Pipfile for the required version):
pyenv install <version>
pyenv local <version>The local command sets the Python version for this project directory.
Install pipenv and the project dependencies:
pip install pipenv
pipenv installIf the install fails, try running it a second time.
npm installRun migrations and load test data:
pipenv run python manage.py migrate
pipenv run python manage.py loaddata testing_dbpipenv run ./bin/dev-serverThe application should now be running at http://0.0.0.0:8001
Default login credentials:
- Username:
tab - Password:
password
If you prefer to use Docker:
docker-compose build
docker-compose up
docker-compose run --rm web ./bin/setup passwordAccess the application at http://localhost.
Note: Docker simulates the production environment, which can be less convenient for active development compared to the local setup above.
The project uses PyLint for linting. Before submitting a PR, format and check your code:
pip install black pylint
black .
pylint your_changed_files.pyThe CI pipeline automatically runs PyLint checks on all PRs.
Before submitting a PR:
- Run tests to ensure existing functionality still works
- Add tests for new features you implement
- Chrome's headless driver is required for testing (installation info)
Some libraries in this project may be several years behind their current versions. When searching for documentation:
- Pay careful attention to version numbers
- Check the
Pipfileandpackage.jsonfor exact versions - Older documentation may be more relevant than the latest guides
Django abstracts database operations through its Object-Relational Mapper (ORM). While convenient, it's easy to accidentally create performance issues:
Avoid the N+1 Problem:
- Use
prefetch_related()andselect_related()to optimize queries - Read this guide on N+1 problems in Django
Profile Your Code:
- Enable Django Silk to monitor database queries
- Verify you're only making the queries you intend to make
- Aim to minimize the number of database queries per request
- Follow PEP 8 guidelines for Python code
- Use meaningful variable and function names
- Add comments for complex logic
- Write docstrings for public functions and classes
-
Create a feature branch:
git checkout -b feature/your-feature-name
-
Make your changes:
- Write clean, well-documented code
- Add or update tests as needed
- Ensure all tests pass
- Run linting tools
-
Commit your changes:
git add . git commit -m "Description of your changes"
-
Push to your fork:
git push origin feature/your-feature-name
-
Open a Pull Request:
- Provide a clear description of the changes
- Reference any related issues
- Ensure CI checks pass
- Keep PRs focused on a single feature or fix
- Include tests for new functionality
- Update documentation if needed
- Respond to review feedback promptly
- Ensure your code passes all CI checks
- Issues: Post questions or report bugs on the GitHub Issues page
- APDA Tech Committee: Contact the APDA tech committee for project-specific questions
- Documentation: Check the user documentation for tournament-related questions
Thank you for contributing to MIT-Tab! Your efforts help make debate tournaments run more smoothly.