Skip to main content
In this lesson, we’ll build the backend dashboard for our warehouse—completing the event-driven flow using Apache Kafka and Flask. We’ll begin by reviewing how the toy shop frontend publishes order events, then implement a Kafka consumer in the warehouse UI.

Recap: Producing Order Events

When a customer places an order in the toy shop frontend (app.py), we serialize the cart as JSON and send it to the cartevent Kafka topic:
In your Flask logs, you’ll see:
And the JSON event published to Kafka looks like:

Building the Warehouse UI Consumer

  1. Close the toy shop folder and open final-projects/warehouse-ui in VS Code.
  2. Edit app.py, importing Kafka and configuring logging at the top:
  1. Add a function to poll Kafka for order events:
Below is a breakdown of the Kafka consumer configuration:
Ensure bootstrap.servers matches your Kafka broker’s public IP. You can verify it in the AWS EC2 dashboard.
The image shows an AWS EC2 dashboard with details of a running instance named "kafka-server." It displays information such as the instance ID, public IPv4 address, and instance type.

Rendering the Dashboard

Expose a Flask route that fetches orders from Kafka and renders them in dashboard.html:
In dashboard.html, iterate over orders to display each customer’s details, products, and total amount.

Running and Testing the Warehouse UI

Visit http://localhost:5000/ in your browser. The dashboard polls Kafka for new cartevent messages.

End-to-End Test

  1. In the toy shop frontend, add Toy 6 to the cart.
  2. Enter Rose as the customer name and Delhi as the address.
  3. Click Place Order to send the event to Kafka.
  4. Return to the warehouse dashboard and refresh. You should see Rose’s order listed.

Next Steps

  • Auto-refresh the dashboard when new events arrive
  • Persist orders to a database and map products to rack locations
  • Add packing instructions or real-time inventory lookups
Congratulations! You’ve built an end-to-end event-driven warehouse dashboard using Apache Kafka. Next, we’ll recap the full architecture and explore scaling strategies.

Watch Video

Practice Lab