weni-ai / chats-engine

Backend for the chats application

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

BLACK LIVES MATTER

BLACK LIVES MATTER

Black Lives Matter · Supporting the cause ·


CHATS-ENGINE

This project provides REST and WEBSOCKETS APIs for the new customer service module @weni.ai weni chats

Python Version Conventional Commits License GPL-3.0

Requirements

  • Python (3.8)
  • Poetry
  • Docker
  • Docker-compose

DEVELOPMENT

Define a .env file with the required environment variables bellow

Command Description
make install Install all dependencies, enter the virtual environment, start databases, run migrations, add initial data to the database and run the project at localhost:8000. Use this if it's your first time cloning the project.
poetry install Install dependencies and create virtual environment
poetry shell Enter virtual enviroment
pre-commit install Install pre-commit to check the code before commiting any changes
make dev_up Run postgres and redis on docker compose
python manage.py makemigrations Make migrations when changing models
python manage.py migrate Run migrations when changing models
python manage.py runserver Run the project at localhost:8000
make test Run tests and show the coverage report
make lint Run all linters(black, flake8 and isort)
make help Explains make commands

We use swagger to document the REST api, access localhost:8000 to get the api documentation. The Websockets api still need to be documented.

ENVIRONMENT VARIABLES

You can set environment variables in your OS or write on .env file.

Name Type Required Default Description
DEBUG Bool False False If True, debug actions are made and shown in stdout.
SECRET_KEY String True None Secret key used on django security.
ALLOWED_HOSTS List False [] List of urls that can host this project.
DATABASE_URL String True sqlite:///db.sqlite3 Default database url.
CHANNEL_LAYERS_REDIS String True redis://127.0.0.1:6379/1 Url for the redis used for django channels.
ADMIN_USER_EMAIL String False admin@weni.ai Email that will receive emails with logs when something happens in the api.
REST_PAGINATION_SIZE Int False 20 Limit the number of objects returned when using pagination on an endpoint.
OLD_MESSAGES_LIMIT Int False 10 Limit the messages returned when a chat is opened.
OIDC_ENABLED bool False False Enable using OIDC.
OIDC_RP_CLIENT_ID string False None OpenID Connect client ID provided by your OP.
OIDC_RP_CLIENT_SECRET string False None OpenID Connect client secret provided by your OP.
OIDC_OP_AUTHORIZATION_ENDPOINT string False None URL of your OpenID Connect provider authorization endpoint.
OIDC_OP_TOKEN_ENDPOINT string False None URL of your OpenID Connect provider token endpoint.
OIDC_OP_USER_ENDPOINT string False None URL of your OpenID Connect provider userinfo endpoint.
OIDC_OP_JWKS_ENDPOINT string False None URL of your OpenID Connect provider JWKS endpoint.
OIDC_RP_SIGN_ALGO string False RS256 Sets the algorithm the IdP uses to sign ID tokens.
OIDC_DRF_AUTH_BACKEND string False chats.apps.accounts.authentication.drf.backends.WeniOIDCAuthenticationBackend Define the authentication middleware for the django rest framework.
OIDC_RP_SCOPES string False openid email The OpenID Connect scopes to request during login.
USE_S3 Bool False False Boolean that defines if S3 should be used.
AWS_ACCESS_KEY_ID String False None Amazon S3 bucket Access Key.
AWS_SECRET_ACCESS_KEY String False None Amazon S3 bucket Secret Key.
AWS_STORAGE_BUCKET_NAME String False None Amazon S3 bucket name.
USE_SENTRY Bool False False Boolean that defines if Sentry should be initialized.
USE_SENTRY String False None Sentry's DSN URL.

CONTRIBUTING

Contributing

Guidelines

If you want to contribute with bothub's projects, we made a guideline to help you. See here contributing guidelines for the appropriate contribution.

License

About

Backend for the chats application

License:GNU General Public License v3.0


Languages

Language:Python 98.7%Language:Dockerfile 0.5%Language:Makefile 0.4%Language:Shell 0.4%