Skip to main content

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.

Metadata

Release files for chatwithkafka 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for chatwithkafka 0.1.2
File Size Uploaded
chatwithkafka-0.1.2.tar.gz 6.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for chatwithkafka 0.1.2
File Interpreter ABI Platform
chatwithkafka-0.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 14.5 kB

Release files / chatwithkafka-0.1.2.tar.gz

Download URL chatwithkafka-0.1.2.tar.gz
Size 6.6 kB
Tags Source
SHA-256 checksum
How to use checksums
e14a42204da5f8061cffeba5cc1815462dce437dbacff68777144aa71d4a0fc6
BLAKE2b-256 checksum
How to use checksums
9190eb5f2876cbc7ac0315417ca5c41ac6db830b00d41e1d0536e95490af0e7a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.0.1 CPython/3.12.8

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 16, 2024.

Transparency log

Release files / chatwithkafka-0.1.2-py3-none-any.whl

Download URL chatwithkafka-0.1.2-py3-none-any.whl
Size 7.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3c25c156eba7cb479ed38672b732cf2e038b1990190f69f04c4f082940ae115f
BLAKE2b-256 checksum
How to use checksums
8094ef493bce2c764e3c47c82d36793dd112239014302ab0b76740ec6fd4a975
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.0.1 CPython/3.12.8

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 16, 2024.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.2 This release

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page