Python backend for a Slack's kudos plugin.
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Python 98.3%
Makefile 0.8%
Dockerfile 0.4%
Mako 0.4%
Shell 0.1%
Other 0.1%
287 1 0

Clone this repository

https://tangled.org/mgabarda.com/kefi-backend https://tangled.org/did:plc:leadkratzafsoun4byj6rp6s/kefi-backend
git@tangled.org:mgabarda.com/kefi-backend git@tangled.org:did:plc:leadkratzafsoun4byj6rp6s/kefi-backend

For self-hosted knots, clone URLs may differ based on your setup.

Download tar.gz
README.md

Traefik


Build Status

Welcome to Kefi community!#

Basic setup#

To be able to run Kefi in you own computer, for development proposes, first, you'll need the following software installed and configured:

  • Python 3.10 (we recommend pyenv to handle several Python versions)
  • poetry
  • Docker and docker-compose

This project uses environment variables to handle the configuration, following the twelve-factor config recommendation, and we recommend to use direnv to handle project's local environment variables.

Clone the repository#

First, just clone this repository in your machine.

Create environment variables#

Assuming you are using direnv, on the root of the project, creates a file named .envrc:

    $ echo "dotenv" > .envrc

Then create an .env file with the environment variables. An example:

    # PostgreSQL
    # ------------------------------------------------------------------------------
    POSTGRES_HOST=localhost
    POSTGRES_PORT=5432
    POSTGRES_DB=kefi
    POSTGRES_USER=pyqF6iHnFi3LjiFV
    POSTGRES_PASSWORD=HGt9nkXNv6F9xkzN

    # Database connection
    # ------------------------------------------------------------------------------
    DATABASE_URL=postgresql://pyqF6iHnFi3LjiFV:HGt9nkXNv6F9xkzN@localhost:5432/kefi

    # Redis
    # ------------------------------------------------------------------------------
    REDIS_HOST=localhost

    # Slack
    # ------------------------------------------------------------------------------
    SLACK_BOT_TOKEN=<put here your bot token>
    SLACK_TEAM_ID=<put here your team ID>

    # General
    # ------------------------------------------------------------------------------
    KEFI_SETTINGS_MODULE=kefi.config.local

Launch the external services#

To launch the database an Redis server, you can launch them using docker-compose:

    $ docker-compose up --build

Install the dependencies#

You can install the dependencies of the project using poetry, in a local virtual environment, using the following command:

    $ poetry install

Running tests#

Now, to test that everything is working, you can launch the tests using this command:

    $ poetry run pytest .

Running local server#

Database migrations#

First, we have to run the migrations in order to get the last version of the database:

    $ poetry run alembic upgrade head

Run server#

Then, we launch the local server with uvicorn:

    $ poetry run uvicorn kefi.main:app --reload

Force load Kefis#

    $ poetry run ./manage.py
        from kefi.models.helpers import reset_wallets
        reset_wallets(session)
        session.commit()