A distributed chat application using Apache Kafka for message processing. Implemented Feature A: all users exchange messages in one shared topic, seeing each other's messages in real time.
Within Feature A:
- All users connect to a single Kafka topic
chat - All sent messages are visible to all users
- No separation by chat rooms (unlike Feature B)
- No message filtering (unlike Feature C)
- Python 3.8+
- Apache Kafka (installed and configured)
zsh(macOS default),bashorcmd(for Windows) installed- Git
-
Clone repository
git clone https://github.com/bluvvis/chat-kafka.git cd chat-kafka -
Create and activate a virtual environment
macOS / Linux:
python3 -m venv venv source venv/bin/activateWindows (cmd):
python -m venv venv venv\Scripts\activate
-
Install dependencies
pip install -r requirements.txt
Open a separate terminal window and run:
zookeeper-server-start /opt/homebrew/etc/kafka/zookeeper.propertiesThen in a new terminal window:
kafka-server-start /opt/homebrew/etc/kafka/server.propertiesIn the Kafka directory:
bin/zookeeper-server-start.sh config/zookeeper.propertiesNew window:
bin/kafka-server-start.sh config/server.propertiesOpen a new terminal and run:
kafka-topics --create \
--topic chat \
--bootstrap-server localhost:9092 \
--partitions 1 \
--replication-factor 1Check the topic availability:
kafka-topics --list --bootstrap-server localhost:9092In the Kafka directory:
.\bin\windows\zookeeper-server-start.bat .\config\zookeeper.propertiesNew window:
.\bin\windows\kafka-server-start.bat .\config\server.propertiesOpen a new terminal and run:
kafka-topics.bat --create --bootstrap-server localhost:9092 --topic chat --partitions 1 --replication-factor 1Check the topic availability:
kafka-topics.bat --list --bootstrap-server localhost:9092-
Window 1 - Consumer:
python3 consumer.py
You should see:
Kafka Chat Consumer started. Listening for messages... -
Window 2 - Producer (sender):
python3 producer.py
Enter a username, such as
bluvvis, and send messages. They will appear in all running consumers. -
Multiple windows: You can run multiple
producer.pyin separate terminals to emulate multiple users.
- ✅ General topic: All users are connected to one topic
chat - ✅ Real time: Messages are instantly delivered and displayed
- ✅ Verification: Testing was carried out manually through several terminals (producer and consumer)
- ❌ Isolation and filtering: Not applicable - Feature A was selected according to the technical specifications
- ✅ Message order: The sending order is preserved
chat-kafka/
├── consumer.py # Message recipient
├── producer.py # Message Sender
├── requirements.txt # Python Dependencies
├── README.md # Project Description
└── venv/ # Virtual environment (add to .gitignore)Grigorij Belaev, Farit Sharafutdinov, Batraz Dzesov, Stanislav Delyukov
GitHub: @bluvvis