Skip to main content

A Kafka Chat application as a TUI

Project description

Chat With Kafka

This is a simple chat application that uses Kafka as a message broker. The application is written in Python and uses the confluent-kafka library to interact with Kafka and the textual framework to create the chat interface in the terminal.

It was written as demonstration of how to use Kafka to create a chat application for a project course at Karlstad University.

Installation

To install the application you type

pip install chatwithkafka

It can also be installed from the source code by cloning the repository and running

pip install .

in the root directory of the repository.

Usage

Configuration file

The application uses a configuration file to specify the Kafka broker and the topic to use, as well as the optional Fernet symmetric key to use for encrypting the data. The configuration file is a JSON with this structure:

{
  "kafkaconf" : {
    "bootstrap.servers": "abc.swedencentral.azure.confluent.cloud:9092",
    "security.protocol": "SASL_SSL",
    "sasl.mechanisms": "PLAIN",
    "sasl.username": "TRNHSNRJS5342HSKF",
    "sasl.password": "DwQpxSDPnjvtc54mv6C4TBzmLfcfyA8EzAYgMjfRQTvmcUCZ7thnCpGV4jE622vd"
  },
  "topic": "chat",
  "symmetric_key": "9gWFwrEng_gmYTz1uN_PlnlGs4te0MqIOObQFcsns3E="
}

Running the application

Start the application by typing

chatwithkafka /path/to/config.json

You can also see options by typing

chatwithkafka --help
usage: chatwithkafka.exe [-h] [-u USER] [-t TOPIC] [--key KEY] config_file

Chat Terminal User Interface (TUI) with Kafka

positional arguments:
config_file              Path to the JSON configuration file

options:
-h, --help               Show this help message and exit
-u USER, --user USER     User name to use in chat. If none is provided, the currently logged in user's name will be used
-t TOPIC, --topic TOPIC  Topic to use for chat. Overrides the topic in the configuration file
--key KEY                Symmetric Fernet key to use encrypting and decrypting messages. Overrides the key in the configuration file

Exiting the application

Press Esc to exit the chat application.

Secured Communication

Using the cryptography library, the application can encrypt the message it sends as well as decrypt the messages it receives. The symmetric key used for encryption and decryption is specified in the configuration file or sent in as a command line argument (--key). If no key is provided, then the messages are sent in plain text.

There is a key generation tool also installed with the application. To generate a key, type

chatwithkafka-keygen

and it will provide a key (e.g. h1-lkBmvVizjEKpEAmirtvaWUmrwhNhe0xtgCeGe5FU=) that can be shared with the other users of the chat, in some other way of communicating than the chat itself.

Note that the encryption here is symmetric for simlicity's sake, so all users who want to communicate needs to have the same key as input to the program.

License

This project is licensed under the MIT License - see the LICENSE file for details.

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

chatwithkafka-0.1.2.tar.gz (6.6 kB view details)

Uploaded Source

Built Distribution

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

chatwithkafka-0.1.2-py3-none-any.whl (7.9 kB view details)

Uploaded Python 3

File details

Details for the file chatwithkafka-0.1.2.tar.gz.

File metadata

  • Download URL: chatwithkafka-0.1.2.tar.gz
  • Upload date:
  • Size: 6.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for chatwithkafka-0.1.2.tar.gz
Algorithm Hash digest
SHA256 e14a42204da5f8061cffeba5cc1815462dce437dbacff68777144aa71d4a0fc6
MD5 2984f467513c2aefb6bd53d54d72bec3
BLAKE2b-256 9190eb5f2876cbc7ac0315417ca5c41ac6db830b00d41e1d0536e95490af0e7a

See more details on using hashes here.

Provenance

The following attestation bundles were made for chatwithkafka-0.1.2.tar.gz:

Publisher: python-publish.yml on swedwise/Swedwise.ChatWithKafka

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file chatwithkafka-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: chatwithkafka-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 7.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for chatwithkafka-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 3c25c156eba7cb479ed38672b732cf2e038b1990190f69f04c4f082940ae115f
MD5 0e7b7037d758099bfc13af53be62c0f1
BLAKE2b-256 8094ef493bce2c764e3c47c82d36793dd112239014302ab0b76740ec6fd4a975

See more details on using hashes here.

Provenance

The following attestation bundles were made for chatwithkafka-0.1.2-py3-none-any.whl:

Publisher: python-publish.yml on swedwise/Swedwise.ChatWithKafka

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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