Welcome to MatchDB

Suggesting people to connect with based on shared interests

This is a light wrapper around deta.space’s serverless database, Base.

MatchDB is a database of people and their interests. Use it to manage profiles and connect people who share interests.

The main motivation was to help to connect people in large Slack/Discord servers in the remote working community.

Install

pip install matchdb
# to get the latest version
pip install git+https://github.com/batmanscode/MatchDB.git
# install from source
git clone https://github.com/batmanscode/MatchDB.git

How to use

Here’s a brief quickstart guide. Please read the complete documentation to see everything you can do!

First, let’s create a new project on deta.space and save your project key to the environment variable "DETA_PROJECT_KEY"

I’ve already created an environment variable but you can add it like this if you haven’t:

# import os

# os.environ["DETA_PROJECT_KEY"] = "..."
from matchdb.matchdb import *

Next, create a name for your database. This will be visible in your project on deta.space.

I’ll define it globally here since I’ll be using just one database but you can create as many as you like!

DATABASE = "users"

Adding users

Let’s add two users

add_interests(user_id=1111,
              group_id=2222,
              interests=['MMA', 'memes', 'Uk', 'tea'],
              database_name=DATABASE
             )
find_user(1111, DATABASE)
[{'date': '14-02-2023 06:00',
  'group_id': 2222,
  'interests': ['uk', 'memes', 'tea', 'mma'],
  'key': '01GS7ASNBN7BMKCFPTCV45VWBT',
  'user_id': 1111}]
add_interests(user_id=3333,
              group_id=2222,
              interests=['anime', 'memes', 'ireland', 'coffee'],
              database_name=DATABASE
             )
find_user(3333, DATABASE)
[{'date': '14-02-2023 06:00',
  'group_id': 2222,
  'interests': ['ireland', 'anime', 'memes', 'coffee'],
  'key': '01GS7ASNGBHHPK4YMBEHN1REEZ',
  'user_id': 3333}]

Match

match_list = match_interests(1111, DATABASE)

This will show evreyone who has common interests with useer 1111, including themselves!

match_list
[{'group_id': 2222,
  'user_id': 1111,
  'common interests': ['uk', 'memes', 'tea', 'mma'],
  'common interests count': 4},
 {'group_id': 2222,
  'user_id': 3333,
  'common interests': ['memes'],
  'common interests count': 1}]

You can exclude the user you are finding matches for like this:

user = 1111

match_list = match_interests(1111, DATABASE)
# for other ways to do this see here:
# https://www.geeksforgeeks.org/python-removing-dictionary-from-list-of-dictionaries/
match_list = [item for item in match_list if not (item["user_id"]==user)]
match_list
[{'group_id': 2222,
  'user_id': 3333,
  'common interests': ['memes'],
  'common interests count': 1}]

Get your whole database

database_to_dataframe(DATABASE)
date group_id interests key user_id
0 14-02-2023 06:00 2222 [uk, memes, tea, mma] 01GS7ASNBN7BMKCFPTCV45VWBT 1111
1 14-02-2023 06:00 2222 [ireland, anime, memes, coffee] 01GS7ASNGBHHPK4YMBEHN1REEZ 3333

Count unique interests

interestcount_to_dataframe(DATABASE)
interests count
0 memes 2
1 ireland 1
2 anime 1
3 tea 1
4 coffee 1
5 uk 1
6 mma 1

How to contribute

  1. Fork
  2. Install (more on this below)
  3. Make changes in ./notebooks

In the terminal:

  1. nbdev_preview to preview docs
  2. nbdev_prepare (very important)

And finally:

  1. Pull request!

Please go though nbdev docs. Their end-to-end tutorial will show you most of what you need to know.

Installing for development

Codespaces/VSCode

Everything you need will be installed when you open Codespaces/VSCode; specified in .devcontainer/

Notes for Codespaces:

  • Currently Jupyter notebook doesn’t work on Codespaces for an unknown reason, or at least I can’t, so you’ll have to use JupyterLab
  • Open with jupyter lab --NotebookApp.allow_origin='*' --NotebookApp.ip='0.0.0.0'
  • For more info on using see https://code.visualstudio.com/docs/datascience/notebooks-web

Local

You’ll need to install Jupyter and nbdev at minimum. You can do that with the following terminal commands:

pip install notebook
pip install nbdev
nbdev_install_quarto
nbdev_install_hooks

For convenience, you can install all these and optional Jupyter extensions with:

cd MatchDB
bash ./.devcontainer/postCreateCommand.sh

Then install MatchDB in editable mode with pip install MatchDB/requirements.txt