Skip to main content

Suggesting people to connect with based on shared interests

Project description

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

matchdb-0.1.0.tar.gz (14.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

matchdb-0.1.0-py3-none-any.whl (11.5 kB view details)

Uploaded Python 3

File details

Details for the file matchdb-0.1.0.tar.gz.

File metadata

  • Download URL: matchdb-0.1.0.tar.gz
  • Upload date:
  • Size: 14.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.2

File hashes

Hashes for matchdb-0.1.0.tar.gz
Algorithm Hash digest
SHA256 e3f37ef75c4593cb0faa7a1cdb0a0f3aa914d81243d2b32871b5264166644f62
MD5 c6858877e6333ac20364f98ea39d8e82
BLAKE2b-256 d869dc6aa0c8959e108f027e89c42f92abf44877b69b226e0fb2844ee4c65c9a

See more details on using hashes here.

File details

Details for the file matchdb-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: matchdb-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 11.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.2

File hashes

Hashes for matchdb-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b41773a1c705a531b6b42cf90dff0c5d24cb81a85c97f039a6dcc25dfc8380f1
MD5 91c08d8a1b873e7c6551fa8177b6e165
BLAKE2b-256 0821dc30cc88ecba87666ea6d7b1a14e8e78b858995b4765fffc19c6db5983a8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page