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.0.tar.gz (6.5 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.0-py3-none-any.whl (7.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: chatwithkafka-0.1.0.tar.gz
  • Upload date:
  • Size: 6.5 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.0.tar.gz
Algorithm Hash digest
SHA256 874e362e29f8086361fa480eaaac0ad90e1f9bb5b556ca30a0a834608bae12df
MD5 98241b2b4ed0eb6d411234d2c2bfb327
BLAKE2b-256 6dbfd56083960a5d6d0f96117e9bae42905a3d7ab56429cab77fb8945a4b57e9

See more details on using hashes here.

Provenance

The following attestation bundles were made for chatwithkafka-0.1.0.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.0-py3-none-any.whl.

File metadata

  • Download URL: chatwithkafka-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 7.5 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 69f86f515e7c28bbccf601a39d8e7678ebb4c9aab7376431298840683c19e280
MD5 47a6d3516f726d64b5aad5c71a6e9594
BLAKE2b-256 944377338162c8049832182226239dcba7b4af9e5df34f3a18b95f8641207ff4

See more details on using hashes here.

Provenance

The following attestation bundles were made for chatwithkafka-0.1.0-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