This section describes how a customer's food order flows through the system, covering gRPC communication, Kafka topics, status transitions, and real-time updates.
- The Customer searches for restaurants and food items.
- A gRPC call is made from the Customer Service to the Restaurant Service to retrieve restaurant and menu information.
- The customer browses the results and selects food items to place an order.
- After finalizing the selection, the customer places the order.
- The system:
- Publishes order details to the Kafka topic:
order-restaurant-request. - Persists the order in the Customer Service database.
- Publishes order details to the Kafka topic:
- The Restaurant Service listens to the
order-restaurant-requesttopic. - It:
- Extracts the order data.
- Saves it in the Restaurant database.
- Sends a notification to the restaurant UI/agent.
- The restaurant can either accept or reject the incoming order.
- Upon action:
- The system publishes an order status update to the Kafka topic:
order-statuswith either"PLACED"or"REJECTED". - Both Customer and Restaurant Services subscribe to this topic to:
- Update their databases.
- Trigger UI notifications for status changes.
- The system publishes an order status update to the Kafka topic:
-
If the order is accepted:
- The Restaurant Service updates the order status to
"PREPARED"and publishes it to theorder-statustopic. - Then, it publishes a rider request to the
rider-requestKafka topic.
- The Restaurant Service updates the order status to
-
The Rider Service listens to
rider-requestand initiates rider matching.
- Riders receive delivery request notifications in real-time.
- A rider can accept the request within a configured timeout window.
- When a rider accepts the delivery:
- The order status is updated to
"ONTHEWAY"and published toorder-status. - The rider's live location is continuously published to the
rider-location-updatestopic. - The Customer Service consumes this topic to allow customers to track their delivery in real-time.
- The order status is updated to
- After successful delivery:
- The Rider Service updates the order status to
"DELIVERED". - This is published to the
order-statustopic and synchronized across all involved services and UIs.
- The Rider Service updates the order status to
