Real-Time Food Order Tracking with Redpanda: A Practical Guide

Introduction

Imagine youโ€™re building a food delivery app like Talabat or Zomato. When a customer places an order, they want instant updates:

  • โœ… Order confirmed
  • ๐Ÿ‘จโ€๐Ÿณ Food is being prepared
  • ๐Ÿ™ต Delivery on the way
  • ๐Ÿ“ฆ Delivered

How do you make this real-time experience possible?

The answer: event streaming, and one of the best tools for that is Redpanda โ€” a fast, Kafka-compatible streaming platform with no Java dependencies and a simpler developer experience.

In this tutorial, weโ€™ll build a real-time order tracking system using Redpanda.


๐Ÿชฐ What Youโ€™ll Need

  • Docker installed
  • Python 3.8+ installed
  • kafka-python or confluent-kafka (pip install kafka-python)
  • Basic Python knowledge

๐Ÿ› ๏ธ Step 1: Run Redpanda Locally (via Docker)

Letโ€™s spin up Redpanda with a single command:

docker run -d --pull=always --name=redpanda \
  -p 9092:9092 -p 9644:9644 \
  docker.redpanda.com/redpandadata/redpanda:latest \
  redpanda start --overprovisioned --smp 1 --memory 1G --reserve-memory 0M \
  --node-id 0 --check=false --kafka-addr PLAINTEXT://0.0.0.0:9092

๐Ÿ” Ports:
9092 = Kafka API (for producers/consumers)
9644 = Redpanda Admin API


๐Ÿ“ Step 2: Define the Use Case

Letโ€™s simulate this real-life order journey:

StepStatus Event
1Order Placed
2Preparing Food
3Out for Delivery
4Delivered

Each event will be sent as a message to Redpanda, and the frontend can subscribe in real-time.


๐Ÿ“จ Step 3: Create a Topic for Orders

Use Python to create a topic called order-status:

from kafka.admin import KafkaAdminClient, NewTopic

admin = KafkaAdminClient(bootstrap_servers="localhost:9092")
topic = NewTopic(name="order-status", num_partitions=1, replication_factor=1)
admin.create_topics([topic])

๐Ÿ‘จโ€๐Ÿณ Step 4: Simulate Order Status Updates (Producer)

from kafka import KafkaProducer
import json, time

producer = KafkaProducer(
    bootstrap_servers='localhost:9092',
    value_serializer=lambda v: json.dumps(v).encode('utf-8')
)

order_id = "ORDER123"
status_updates = [
    {"order_id": order_id, "status": "Order Placed"},
    {"order_id": order_id, "status": "Preparing Food"},
    {"order_id": order_id, "status": "Out for Delivery"},
    {"order_id": order_id, "status": "Delivered"}
]

for update in status_updates:
    producer.send('order-status', update)
    print(f"Sent update: {update}")
    time.sleep(2)  # simulate delay

producer.flush()

๐Ÿ“ฌ Step 5: Real-Time Order Tracker (Consumer)

from kafka import KafkaConsumer
import json

consumer = KafkaConsumer(
    'order-status',
    bootstrap_servers='localhost:9092',
    auto_offset_reset='earliest',
    group_id='tracker-service',
    value_deserializer=lambda v: json.loads(v.decode('utf-8'))
)

print("Listening for order updates...\n")

for message in consumer:
    update = message.value
    print(f"Order {update['order_id']} - Status: {update['status']}")

๐Ÿ–ฅ๏ธ What This Looks Like in Real Life

๐Ÿ‘จโ€๐Ÿ’ป Backend (Producer):

Keeps sending order updates to Redpanda.

๐Ÿ“ฑ Frontend (Consumer):

Subscribes to updates and instantly shows users when the rider is nearby.

You can plug the consumer into a WebSocket or REST API to stream updates to a frontend or mobile app.


๐Ÿ“ˆ Why Redpanda?

  • โšก Blazing-fast performance
  • ๐Ÿงน Kafka-compatible (reuse existing tools)
  • ๐Ÿฉถ No JVM needed โ€” lightweight and easy to run
  • ๐Ÿ› ๏ธ Built-in CLI and monitoring tools

โœ… Next Steps

  • Add multiple topics (e.g. order-payments, user-feedback)
  • Connect Redpanda to a frontend via WebSockets
  • Deploy Redpanda on Kubernetes or Redpanda Cloud
  • Monitor your streams with Redpanda Console

๐Ÿ’ฌ Final Thoughts

Redpanda makes it easier than ever to build real-time systems. Whether you’re handling food orders, stock prices, or IoT sensors โ€” streaming is the future, and Redpanda helps you get there faster.


๐Ÿ‘‹ Stay Connected

Want help setting up Redpanda for your own use case? Reach out or comment below!

Leave a Comment

Comments

No comments yet. Why don’t you start the discussion?

Leave a Reply

Your email address will not be published. Required fields are marked *