Metadata-Version: 2.5
Name: lazy-kafka
Version: 0.1.0
Summary: A TUI application to enhance the Kafka eco-system devX.
Project-URL: Documentation, https://github.com/lazy-kafka/lazy-kafka#readme
Project-URL: Issues, https://github.com/lazy-kafka/lazy-kafka/issues
Project-URL: Source, https://github.com/lazy-kafka/lazy-kafka
Author-email: Timon Viola <44016238+timonviola@users.noreply.github.com>
License-Expression: MIT
License-File: LICENSE.txt
Keywords: kafka,kafka-connect,schema-registry,terminal,textual,tui
Classifier: Development Status :: 5 - Production/Stable
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: Implementation :: CPython
Requires-Python: >=3.12
Requires-Dist: click>=8.0.0
Requires-Dist: confluent-kafka[avro,json,protobuf]<=2.16.1,>=2.4.0
Requires-Dist: httpx
Requires-Dist: rich
Requires-Dist: textual>=8.0.0
Requires-Dist: typer
Description-Content-Type: text/markdown

# lazy-kafka

[![PyPI - Version](https://img.shields.io/pypi/v/lazy-kafka.svg)](https://pypi.org/project/lazy-kafka)
[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/lazy-kafka.svg)](https://pypi.org/project/lazy-kafka)
[![Coverage](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/lazy-kafka/lazy-kafka/trunk/.github/badges/coverage-badge.json&style=flat)](https://github.com/lazy-kafka/lazy-kafka/actions)

-----

A tui application to enhance Kafka eco-system devX.

I started this project quite a while ago and haven't really worked on it all that much. There are many, more feature rich and mature projects, so probably you should not use exactly this one. The purpose of this project is to have some fun, not to churn out a project. I am making the repo public, so maybe someone can get inspired/look around 🤷

[![asciicast](https://asciinema.org/a/1258296.svg)](https://asciinema.org/a/1258296)

# Features
- tui
- cli

## Kafka
- list topics
- display basic topic information
- list messages (experimental)

## Kafka connect
- list connectors
- display basic connector information
- display connector status
- monitor connector status (follow)

## Schema Registry
- list subjects
- create, delete subjects
- display subject data



## Table of Contents

- [Installation](#installation)
- [License](#license)

## Installation

```console
pip install lazy-kafka
```

## License

`lazy-kafka` is distributed under the terms of the [MIT](https://spdx.org/licenses/MIT.html) license.

# dev
This project uses [uv](https://docs.astral.sh/uv/) for dependency/env management
(provided by `devenv.nix`). A `Justfile` provides a couple of shortcuts for things
that aren't a single straightforward command (local dev setup, test coverage flags,
release bump) — everything else is just plain `uv run ...`.

run:
- 🐳 docker environment `$ scripts/start-up`
- 📦 install deps `$ uv sync` (or enter the devenv shell, which does this for you)
- 🔧 one-time local setup (pre-commit hooks, etc.) `$ just setup`
- 💾 run the app `$ uv run python src/lazy_kafka/__main__.py`
- 📃 textual dev console `$ uv run textual console -x EVENT -x SYSTEM --port 7342`
- 🧪 run tests with coverage `$ just test`
- 🔍 type-check `$ uv run mypy src/lazy_kafka tests`
- 🎨 lint/format `$ uv run ruff check .` / `$ uv run ruff format .`

If you are using pip:
- `pip install -e .`
- `lazy-kafka`

check topics:
docker exec 1793ae26d162 /bin/kafka-topics --bootstrap-server=localhost:9092

## Docker compose
The docker compose will:
- Start a Kafka cluster: 1 broker and 1 zookeeper
  - create a test-topic
- Start ConfluentSchemaRegistry
  - register a 'test-schema' for the 'test-topic'
- Start LocalStack S3 bucket 'test-bucket'
- Start Kafka Connect
  - create a connector to read from test-topic, dump to S3 test-bucket



# useful

curl -s -XGET http://localhost:8083/connector-plugins | jq '.[].class'

curl -XGET http://localhost:8083/connectors

# Roadmap

## v0.1.0
- settings management
- k-connect continuous update (like watch)
  - [x] Color the State column based on the value
  - [x] Fix currently highlighted connector selection on update
  - [x] Load from config file
    - [-] Add file watcher - get inspiration from watchdog or [toolong](https://github.com/Textualize/toolong/blob/main/src/toolong/watcher.py)
  - [x] Expose more configuration (kafka auth related)

## v0.2.0
- [ ] see messages in a stream
  - [ ] extend kafka page support: AIOKafka/confluent-kafka library facade
    - [ ] implementation only with confluent-kafka, but with a facade
- [ ] produce messages into a stream
  - [ ] concrete producer
  - [ ] dummy producer (agent pool pattern?)



## 

## v1.0
Generate client code from openapi
- deprecate confluent-kafka in favor of [kafka-rest api](https://github.com/confluentinc/kafka-rest/blob/master/api/v3/openapi.yaml)
    - [docker](https://hub.docker.com/r/confluentinc/cp-kafka-rest)
- kakfa-connect
-schema-registy

## 04-28
- [x] kafka consume feature
- [ ] kafka consume UI with message table
- [ ] CLI
  - [x] initial set up
  - [ ] factor into own module
  - [x] consume command to follow topic
  - [ ] produce command (de-scope e.g.: schemathesis like test data generation)
- [ ] tests
  - [-] :( 

## 09-15
- schema listing and browsing
  x multiple versions of stuff (-> always show the latest)
  x ** it is cumbersome to go from subject to schema (human exploration) **
    ** it is easy to look up `id` -> schema (how the messages are serialized) **
    0. request to list subjects
    1. request to `subjects/<subject>/versions` to list versions
    2. request to `subjects/<subjects>/versions/-1` to get the latest schema info
    3. request to `schemas/ids/{id}/schema`
  -> can delete schema with a dialog popping up
  -> The design philosophy is to handle events as close to the source as possible. 


- create modal screens to create schema, connector, topic (?)
- create settings management from config file
- create a screen for settings
- add delete action
- 



# Development
- confluent kafka docs: https://docs.confluent.io/platform/current/clients/confluent-kafka-python/html/index.html#confluent_kafka.TopicPartition
- detailed example of confluent kafka lib api: https://github.com/confluentinc/confluent-kafka-python/issues/1443


🫛 lazy-kafka ➜ textual console -x EVENT -x SYSTEM --port 7342
🫛 lazy-kafka ➜ python src/lazy_kafka/__main__.py --help
🫛 lazy-kafka ➜ python src/lazy_kafka/scripts/topic_schema_producer.py
🫛 lazy-kafka ➜textual run --dev --port 7342 src/lazy_kafka/__main__.py

The app does not handle the case where topics are empty. Produce dummy data with the cli:
🐣 lazy-kafka ➜ python -m lazy_kafka kafka produce -f src/lazy_kafka/default_config.toml test-topic

(optionally also run this:)
🐣 lazy-kafka ❯ python -m lazy_kafka kafka consume -f src/lazy_kafka/default_config.toml test-topic

---

- built with Mistral :)
