Skip to content

Become a Code Contributor 💻

If you are here, it means you are interested in helping build Mitup, thank you! Our goal is for Mitup to grow and suit the needs of as many users as possible. However, as our time is limited, community contributions are greatly appreciated to assist with bug fixes and new features.

Follow the guides below to become a contributor.

Contributor Requirements

Mitup is built in Python, deployed in containers on AWS and managed using Hatch environments. Contributors must have:

  • A Docker installation (install it from here if you don't have it)
  • Knowledge of modern Python, including type annotations
  • A GitLab account

Setup

Hatch

If you do not have a working installation of Hatch, install it now. We recommend installing Hatch through pipx.

pipx install hatch

Since we run all commands as part of the Hatch dev environment, there's no need to install a specific Python distribution. Hatch manages this automatically when running any command. Mitup is configured to use a specific version of Python, and Hatch attempts to locate a compatible version on your system. If none is found, Hatch installs the required version for the virtual environment dev.

Pre-commit

We use pre-commit to handle validations for each commit to the repository. Make sure to install it before committing any code to be pushed to the GitLab repo.

pipx install pre-commit

Gettext and libpq

While most of the dependencies are handled by Hatch, there are two libraries that need to be installed on your system before you can run Mitup:

  • gettext is used to handle translation files. Follow the instructions on their site to install it.
  • psycopg2 is a Python library that handles PostgreSQL communication and is built as a wrapper around libpq, the PostgreSQL client library. It requires building parts of the library from source, which necessitates a C compiler and several additional libraries.
Installing Required Libraries

Simply install postgresql from Homebrew. It comes bundled with libpq. Installing PostgreSQL doesn't require running a server, but having it available can be useful during the development process in case you need it.

brew install postgresql

If you do not want to install PostgreSQL, you can just install the libpq client which comes with the necessary headers included.

brew install libpq

The libpq client library is supported in many Linux distributions. For a Debian-based system, you can run the following commands. You can find instructions online to install this library for any distribution.

apt update
apt install libpq-dev

We currently do not develop on Windows and lack instructions about how to install the required libraries. We cannot validate any found information as we lack a Windows system for testing. We welcome contributions with instructions for Windows users.

Setup Local Repository

Start by cloning the Mitup code from our public repo

git clone git@gitlab.com:meetupbot/mitup-telegram-bot.git
cd mitup-telegram-bot

Setup pre-commit:

pre-commit install
pre-commit run --all-files

Now let's run the validations. This command will trigger the creation of the dev Hatch environment, which is used for all development-related activities.

hatch run dev:validate

If you use VSCode

If you use VSCode, a setup script is included in the repo. This script provides the necessary VSCode configuration needed to run type checking and formatting correctly. Run:

hatch run dev:setup-vscode

Tip

For better IDE experience with type hints, you can use the ide environment (hatch shell ide) which includes boto3-stubs for enhanced autocompletion and type checking.

Configure Your Development Bot

To test your changes through Telegram, you need to link a bot to Mitup. Head to BotFather and register a new bot:

  • Run the /newbot command
  • Choose a name for the bot, e.g. Mitup-<yourname>-dev
  • Choose a username for the bot, e.g. mitup_yourname_dev_bot
  • Copy the token provided by BotFather

Next, run the following command:

hatch run dev:set-local-bot <token>

This creates a dev.toml configuration file used by Mitup when running the bot locally via Docker.

Setup Your Database

For local execution, we rely on a Docker instance of PostgreSQL. First, run all database migrations to ensure the database schema is correctly set up:

docker compose run migrations-upgrade

This command spins up a PostgreSQL database with a local volume in ./postgres_data that persists data between executions, and then runs the necessary migrations.

🚀 Launch Mitup

Once the setup is complete, you can start the bot using:

docker compose run mitup

and begin using it from Telegram by opening the bot you created through BotFather.