cartevent topic. In this article we’ll build a simple front-end that produces order events to the Kafka cluster and verify those events on the broker.
Below you’ll find the project layout, installation steps, the complete Flask app that produces events, how to run the UI, check logs, and validate messages on the Kafka broker.
Project layout
Open a terminal, switch into the project folder, and install dependencies:
requirements.txt):
Flask app — producing order events to Kafka
Openapp.py in your editor. The example below shows the essential, corrected parts of the Flask application: imports, logging, Kafka producer configuration, a delivery callback, sample product data, routes for cart operations, and the handler that produces an order event to the cartevent topic.
Be sure to replace
54.226.13.161:9092 in the bootstrap.servers configuration with the public IP of your Kafka Amazon Elastic Compute Cloud (EC2) instance and the correct port. If broker is not reachable, the producer will fail to connect.Updating the bootstrap server
If your frontend cannot connect to Kafka, confirm thebootstrap.servers setting in app.py uses the EC2 instance’s public IPv4 address and the Kafka listener port (default 9092). You can copy the public IP from the EC2 console and update the configuration accordingly.

Running the frontend and placing an order
Start the Flask app:cartevent topic.


Checking the application logs
The Flask app logs HTTP requests as well as producer activity. If message delivery succeeds, the delivery callback logs the metadata (topic, partition, offset, timestamp). Example local logs:Consuming messages on the Kafka broker
On the Kafka EC2 instance you can create thecartevent topic (if not already created) and consume messages to verify they were produced by the frontend.
Next steps
With the Toy Shop producing order events to thecartevent topic, a logical next step is to implement the Warehouse UI (an internal consumer dashboard). That dashboard can consume cartevent messages and present orders to warehouse staff for picking, packing, and shipping.