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.1.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.1-py3-none-any.whl (7.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: chatwithkafka-0.1.1.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.1.tar.gz
Algorithm Hash digest
SHA256 8fff5e2a4c64759c3827f69e57ca0fa1bcf8215ab786d5db644e4fbec98136cc
MD5 277c9d761085d6d48086e6e9f486b204
BLAKE2b-256 3033260493f61f0a6bd20fdf01558b6a5d997ecd9a7d8657cb8ea4520135c50b

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: chatwithkafka-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 7.8 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 0147dd3fc843e12b47187ade9d9dc5e74043f058c8626646796b4b51e7e5ccfa
MD5 7bae50bc80b5627c9e9e5962edae9f74
BLAKE2b-256 2720a6fc42f4ddd8159f4af592bffb1ebd1435f07fc116a7f8f4995cf3ebb5f9

See more details on using hashes here.

Provenance

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