Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
126 changes: 126 additions & 0 deletions docs/apps/food_delivery.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
# Stateful Food Delivery App

`pas.apps.food_delivery.app.StatefulFoodDeliveryApp` is a stateful Food Delivery application that manages restaurant browsing, cart management, checkout, and order history with PAS navigation.
It launches in `RestaurantList` and transitions between restaurant browsing, menu viewing, cart management, checkout, and order tracking flows based on completed operations.

---

## Navigation States

---

### RestaurantList

Home screen for browsing and searching restaurants, viewing cart, and accessing order history.

| Tool | Backend call(s) | Returns | Navigation effect |
| --- | --- | --- | --- |
| `list_restaurants()` | `StatefulFoodDeliveryApp.list_restaurants()` | `list[dict[str, Any]]` restaurant summaries | Remains in `RestaurantList` |
| `search_restaurants(query: str)` | `StatefulFoodDeliveryApp.search_restaurants(query)` | `list[dict[str, Any]]` matching restaurants | Remains in `RestaurantList` |
| `open_restaurant(restaurant_id: str)` | `StatefulFoodDeliveryApp.get_restaurant(restaurant_id)` | `dict[str, Any]` restaurant details | → `RestaurantDetail(restaurant_id)` |
| `view_cart()` | `StatefulFoodDeliveryApp.get_cart()` | `dict[str, Any]` cart contents | → `CartView` |
| `view_orders()` | `StatefulFoodDeliveryApp.list_orders()` | `dict[str, Any]` orders list with pagination | → `OrderListView` |

---

### RestaurantDetail

Screen for viewing a specific restaurant and its menu items.

| Tool | Backend call(s) | Returns | Navigation effect |
| --- | --- | --- | --- |
| `get_restaurant(restaurant_id: str)` | `StatefulFoodDeliveryApp.get_restaurant(restaurant_id)` | `dict[str, Any]` restaurant details | Remains in `RestaurantDetail` |
| `list_menu(restaurant_id: str)` | `StatefulFoodDeliveryApp.list_menu(restaurant_id)` | `list[dict[str, Any]]` menu items | Remains in `RestaurantDetail` |
| `search_menu_item(query: str)` | `StatefulFoodDeliveryApp.search_menu_item(query, restaurant_id)` | `list[dict[str, Any]]` matching menu items | Remains in `RestaurantDetail` |
| `open_menu_item(item_id: str)` | `StatefulFoodDeliveryApp.get_item(item_id)` | `dict[str, Any]` menu item details | → `MenuItemDetail(item_id, restaurant_id)` |
| `go_back()` | — | Navigation indicator string | → Previous state (via navigation stack) |

---

### MenuItemDetail

Screen for viewing a specific menu item with customization options.

| Tool | Backend call(s) | Returns | Navigation effect |
| --- | --- | --- | --- |
| `get_item(item_id: str)` | `StatefulFoodDeliveryApp.get_item(item_id)` | `dict[str, Any]` menu item details | Remains in `MenuItemDetail` |
| `add_cart(item_id: str, quantity: int, customizations: dict[str, str] \| None = None)` | `StatefulFoodDeliveryApp.add_to_cart(item_id, quantity, customizations)` | `str` confirmation message | → `CartView` |
| `go_back()` | — | Navigation indicator string | → Previous state (via navigation stack) |

---

### CartView

Screen for viewing and managing the shopping cart.

| Tool | Backend call(s) | Returns | Navigation effect |
| --- | --- | --- | --- |
| `get_cart()` | `StatefulFoodDeliveryApp.get_cart()` | `dict[str, Any]` cart contents with items and total | Remains in `CartView` |
| `update_cart(item_id: str, quantity: int)` | `StatefulFoodDeliveryApp.update_cart(item_id, quantity)` | `str` confirmation message | Remains in `CartView` |
| `remove_from_cart(item_id: str)` | `StatefulFoodDeliveryApp.remove_from_cart(item_id)` | `str` confirmation message | Remains in `CartView` |
| `clear_cart()` | `StatefulFoodDeliveryApp.clear_cart()` | `str` confirmation message | Remains in `CartView` |
| `checkout()` | Reads cart, delivery address, and payment method | `dict[str, Any]` checkout info | → `CheckoutView` |
| `go_back()` | — | Navigation indicator string | → Previous state (via navigation stack) |

---

### CheckoutView

Screen for checkout and order placement.

| Tool | Backend call(s) | Returns | Navigation effect |
| --- | --- | --- | --- |
| `set_address(address: str)` | `StatefulFoodDeliveryApp.set_delivery_address(address)` | `str` confirmation message | Remains in `CheckoutView` |
| `set_payment(method: str)` | `StatefulFoodDeliveryApp.set_payment_method(method)` | `str` confirmation message | Remains in `CheckoutView` |
| `submit_order()` | `StatefulFoodDeliveryApp.place_order()` | `str` order ID | → `OrderDetail(order_id)` |
| `go_back()` | — | Navigation indicator string | → Previous state (via navigation stack) |

---

### OrderListView

Screen for viewing order history.

| Tool | Backend call(s) | Returns | Navigation effect |
| --- | --- | --- | --- |
| `list_orders()` | `StatefulFoodDeliveryApp.list_orders()` | `dict[str, Any]` orders list with pagination | Remains in `OrderListView` |
| `open_order(order_id: str)` | `StatefulFoodDeliveryApp.get_order(order_id)` | `dict[str, Any]` order details | → `OrderDetail(order_id)` |
| `go_back()` | — | Navigation indicator string | → Previous state (via navigation stack) |

---

### OrderDetail

Screen for viewing a specific order's details.

| Tool | Backend call(s) | Returns | Navigation effect |
| --- | --- | --- | --- |
| `get_order(order_id: str)` | `StatefulFoodDeliveryApp.get_order(order_id)` | `dict[str, Any]` complete order details | Remains in `OrderDetail` |
| `cancel_order(order_id: str)` | `StatefulFoodDeliveryApp.cancel_order(order_id)` | `str` confirmation message | Remains in `OrderDetail` |
| `reorder_order(order_id: str)` | `StatefulFoodDeliveryApp.reorder(order_id)` | `str` confirmation message | → `CartView` |
| `go_back()` | — | Navigation indicator string | → Previous state (via navigation stack) |

---

## Summary Table

| State | Context | Transitions Out | Self-Loops |
|-------|---------|-----------------|------------|
| **RestaurantList** | — | `open_restaurant` → RestaurantDetail, `view_cart` → CartView, `view_orders` → OrderListView | `list_restaurants`, `search_restaurants` |
| **RestaurantDetail** | restaurant_id | `open_menu_item` → MenuItemDetail, `go_back` → previous state | `get_restaurant`, `list_menu`, `search_menu_item` |
| **MenuItemDetail** | item_id, restaurant_id | `add_cart` → CartView, `go_back` → previous state | `get_item` |
| **CartView** | — | `checkout` → CheckoutView, `go_back` → previous state | `get_cart`, `update_cart`, `remove_from_cart`, `clear_cart` |
| **CheckoutView** | — | `submit_order` → OrderDetail, `go_back` → previous state | `set_address`, `set_payment` |
| **OrderListView** | — | `open_order` → OrderDetail, `go_back` → previous state | `list_orders` |
| **OrderDetail** | order_id | `reorder_order` → CartView, `go_back` → previous state | `get_order`, `cancel_order` |

---

## Navigation Helpers

- Navigation transitions are handled in `StatefulFoodDeliveryApp.handle_state_transition` based on the completed tool name.
- States store context parameters (e.g., `restaurant_id`, `item_id`, `order_id`) for navigation.
- Cart can only contain items from a single restaurant at a time.
- After order submission, the cart is automatically cleared.
- `go_back()` is inherited from `StatefulApp` and uses the navigation stack to return to the previous state.
- Order cancellation can only be performed on orders with status "placed", "preparing", or "delivering" (not "delivered" or "cancelled").
1 change: 1 addition & 0 deletions docs/apps/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Use these pages to explore the current user-facing tool surface for each PAS sta
- [Stateful Reminder App](./reminder.md)
- [Stateful Shopping App](./shopping.md)
- [Stateful Note App](./notes.md)
- [Stateful Food Delivery App](./food_delivery.md)


## Navigation Framework Recap
Expand Down
3 changes: 3 additions & 0 deletions pas/apps/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from pas.apps.contacts.app import StatefulContactsApp
from pas.apps.core import AppState, StatefulApp
from pas.apps.email.app import StatefulEmailApp
from pas.apps.food_delivery import StatefulFoodDeliveryApp
from pas.apps.messaging.app import StatefulMessagingApp
from pas.apps.note import StatefulNotesApp
from pas.apps.proactive_aui import PASAgentUserInterface
Expand All @@ -29,6 +30,7 @@
"StatefulCalendarApp",
"StatefulContactsApp",
"StatefulEmailApp",
"StatefulFoodDeliveryApp",
"StatefulMessagingApp",
"StatefulNotesApp",
"StatefulReminderApp",
Expand All @@ -48,4 +50,5 @@
StatefulMessagingApp,
StatefulNotesApp,
StatefulReminderApp,
StatefulFoodDeliveryApp,
]
25 changes: 25 additions & 0 deletions pas/apps/food_delivery/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
"""Stateful food delivery application package."""

from __future__ import annotations

from pas.apps.food_delivery.app import StatefulFoodDeliveryApp
from pas.apps.food_delivery.states import (
CartView,
CheckoutView,
MenuItemDetail,
OrderDetail,
OrderListView,
RestaurantDetail,
RestaurantList,
)

__all__ = [
"CartView",
"CheckoutView",
"MenuItemDetail",
"OrderDetail",
"OrderListView",
"RestaurantDetail",
"RestaurantList",
"StatefulFoodDeliveryApp",
]
Loading