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 *