Skip to main content

Welcome to MatchDB

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)
<style scoped> .dataframe tbody tr th:only-of-type { vertical-align: middle; }
.dataframe tbody tr th {
    vertical-align: top;
}

.dataframe thead th {
    text-align: right;
}
</style>
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)
<style scoped> .dataframe tbody tr th:only-of-type { vertical-align: middle; }
.dataframe tbody tr th {
    vertical-align: top;
}

.dataframe thead th {
    text-align: right;
}
</style>
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

Metadata

Release files for matchdb 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for matchdb 0.1.0
File Size Uploaded
matchdb-0.1.0.tar.gz 14.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for matchdb 0.1.0
File Interpreter ABI Platform
matchdb-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 25.9 kB

Release files / matchdb-0.1.0.tar.gz

Download URL matchdb-0.1.0.tar.gz
Size 14.5 kB
Tags Source
SHA-256 checksum
How to use checksums
e3f37ef75c4593cb0faa7a1cdb0a0f3aa914d81243d2b32871b5264166644f62
BLAKE2b-256 checksum
How to use checksums
d869dc6aa0c8959e108f027e89c42f92abf44877b69b226e0fb2844ee4c65c9a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.2

Release files / matchdb-0.1.0-py3-none-any.whl

Download URL matchdb-0.1.0-py3-none-any.whl
Size 11.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b41773a1c705a531b6b42cf90dff0c5d24cb81a85c97f039a6dcc25dfc8380f1
BLAKE2b-256 checksum
How to use checksums
0821dc30cc88ecba87666ea6d7b1a14e8e78b858995b4765fffc19c6db5983a8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.2

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page