# 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`](https://textual.textualize.io/) 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
```powershell
pip install chatwithkafka
```
It can also be installed from the source code by cloning
the repository and running
```powershell
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:
```json
{
"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
```powershell
chatwithkafka /path/to/config.json
```
You can also see options by typing
```powershell
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`](https://cryptography.io/en/latest/) 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
```powershell
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](LICENSE) file for details.
Raw data
{
"_id": null,
"home_page": "https://github.com/swedwise/Swedwise.ChatWithKafka",
"name": "chatwithkafka",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": null,
"keywords": "kafka, chat, tui",
"author": "Henrik Blidh",
"author_email": "henrik.blidh@swedwise.se",
"download_url": "https://files.pythonhosted.org/packages/91/90/eb5f2876cbc7ac0315417ca5c41ac6db830b00d41e1d0536e95490af0e7a/chatwithkafka-0.1.2.tar.gz",
"platform": null,
"description": "# Chat With Kafka\n\nThis is a simple chat application that uses Kafka as a \nmessage broker. The application is written in Python and\nuses the `confluent-kafka` library to interact with Kafka\nand the [`textual`](https://textual.textualize.io/) framework \nto create the chat interface in the terminal.\n\nIt was written as demonstration of how to use Kafka to\ncreate a chat application for a project course at\nKarlstad University.\n\n## Installation\n\nTo install the application you type\n\n```powershell\npip install chatwithkafka\n```\n\nIt can also be installed from the source code by cloning\nthe repository and running\n\n```powershell\npip install .\n```\n\nin the root directory of the repository.\n\n## Usage\n\n### Configuration file\n\nThe application uses a configuration file to specify the\nKafka broker and the topic to use, as well as the optional\nFernet symmetric key to use for encrypting the data. The configuration file\nis a JSON with this structure:\n\n```json\n{\n \"kafkaconf\" : {\n \"bootstrap.servers\": \"abc.swedencentral.azure.confluent.cloud:9092\",\n \"security.protocol\": \"SASL_SSL\",\n \"sasl.mechanisms\": \"PLAIN\",\n \"sasl.username\": \"TRNHSNRJS5342HSKF\",\n \"sasl.password\": \"DwQpxSDPnjvtc54mv6C4TBzmLfcfyA8EzAYgMjfRQTvmcUCZ7thnCpGV4jE622vd\"\n },\n \"topic\": \"chat\",\n \"symmetric_key\": \"9gWFwrEng_gmYTz1uN_PlnlGs4te0MqIOObQFcsns3E=\"\n}\n```\n\n### Running the application\n\nStart the application by typing\n\n```powershell\nchatwithkafka /path/to/config.json\n```\n\nYou can also see options by typing\n\n```powershell\nchatwithkafka --help\nusage: chatwithkafka.exe [-h] [-u USER] [-t TOPIC] [--key KEY] config_file\n\nChat Terminal User Interface (TUI) with Kafka\n\npositional arguments:\nconfig_file Path to the JSON configuration file\n\noptions:\n-h, --help Show this help message and exit\n-u USER, --user USER User name to use in chat. If none is provided, the currently logged in user's name will be used\n-t TOPIC, --topic TOPIC Topic to use for chat. Overrides the topic in the configuration file\n--key KEY Symmetric Fernet key to use encrypting and decrypting messages. Overrides the key in the configuration file\n```\n\n### Exiting the application\n\nPress `Esc` to exit the chat application.\n\n### Secured Communication\n\nUsing the [`cryptography`](https://cryptography.io/en/latest/) library, the application can \nencrypt the message it sends as well as decrypt the messages it receives. The symmetric key\nused for encryption and decryption is specified in the configuration file or \nsent in as a command line argument (`--key`). If no key is provided, then the messages\nare sent in plain text.\n\nThere is a key generation tool also installed with the application. To generate a key, type\n\n```powershell\nchatwithkafka-keygen\n```\n\nand it will provide a key (e.g. `h1-lkBmvVizjEKpEAmirtvaWUmrwhNhe0xtgCeGe5FU=`) that can be shared with the other users of the chat,\nin some other way of communicating than the chat itself.\n\n**Note that the encryption here is symmetric for simlicity's sake, so all users\nwho want to communicate needs to have the same key as input to the program.**\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "A Kafka Chat application as a TUI",
"version": "0.1.2",
"project_urls": {
"Homepage": "https://github.com/swedwise/Swedwise.ChatWithKafka"
},
"split_keywords": [
"kafka",
" chat",
" tui"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "8094ef493bce2c764e3c47c82d36793dd112239014302ab0b76740ec6fd4a975",
"md5": "0e7b7037d758099bfc13af53be62c0f1",
"sha256": "3c25c156eba7cb479ed38672b732cf2e038b1990190f69f04c4f082940ae115f"
},
"downloads": -1,
"filename": "chatwithkafka-0.1.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "0e7b7037d758099bfc13af53be62c0f1",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 7851,
"upload_time": "2024-12-16T14:29:19",
"upload_time_iso_8601": "2024-12-16T14:29:19.010622Z",
"url": "https://files.pythonhosted.org/packages/80/94/ef493bce2c764e3c47c82d36793dd112239014302ab0b76740ec6fd4a975/chatwithkafka-0.1.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "9190eb5f2876cbc7ac0315417ca5c41ac6db830b00d41e1d0536e95490af0e7a",
"md5": "2984f467513c2aefb6bd53d54d72bec3",
"sha256": "e14a42204da5f8061cffeba5cc1815462dce437dbacff68777144aa71d4a0fc6"
},
"downloads": -1,
"filename": "chatwithkafka-0.1.2.tar.gz",
"has_sig": false,
"md5_digest": "2984f467513c2aefb6bd53d54d72bec3",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 6628,
"upload_time": "2024-12-16T14:29:21",
"upload_time_iso_8601": "2024-12-16T14:29:21.517504Z",
"url": "https://files.pythonhosted.org/packages/91/90/eb5f2876cbc7ac0315417ca5c41ac6db830b00d41e1d0536e95490af0e7a/chatwithkafka-0.1.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-12-16 14:29:21",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "swedwise",
"github_project": "Swedwise.ChatWithKafka",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "chatwithkafka"
}