This demo application showcases workflows and local development using Dapr and the Diagrid Dashboard using a fictional e-commerce scenario. The scenario consists of two microservices:
- Order Management Service (
order-management) - A controller app that orchestrates order processing - Inventory Service (
inventory-service) - A worker app that manages inventory and processes notifications
Under its default configuration, the applications in this solution do not depend on any external services.
The project features three main Dapr building blocks:
Workflow visibility is provided by the Diagrid Dashboard, a utility container created to enhance the Dapr developer experience.
An API tester is also included for the Order Manager service which can be accessed by visiting /scalar on the Order
Manager service address.
This project uses .NET Aspire to provide an easy local development experience.
Take a look at the running documentation for a complete guide.
WIP
- Order Processing Workflow: Complete order lifecycle from validation to fulfillment
- Pub/Sub Notifications: Real-time order status updates (created, payment processed, shipped, delivered)
- Service Invocation: Real-time inventory checks and order updates
- State Store: Persistent inventory management using Dapr state store
The services in this project use a set of well-known environment variables for configuring Dapr.
APP_ID- Name of the application, often in kebab-caseAPP_PORT- Port on which the service listensDAPR_API_TOKEN- Dapr API tokenDAPR_GRPC_ENDPOINT- Dapr gRPC endpointDAPR_HTTP_ENDPOINT- Dapr HTTP endpoint
POST /order- Start an order processing workflowGET /order/{orderId}- Get the status of a workflow by ID
To try using the Pub/Sub and Service Invocation APIs directly vs. through a workflow:
POST /promotion- Send a promotional notification (simple pub/sub example)POST /inventory/search- Check inventory for multiple items via service invocationGET /inventory/{productId}- Show current inventory for a single product via service invocation
POST /inventory/search- Get current inventory from the state storeGET /inventory/{productId}- Get current inventory for a single productPOST /inventory/initialize- Initialize state store inventory with sample dataPOST /inventory/update- Update inventory levels in state storePOST /order-notification- Pubsub subscription handler for order notificationsPOST /promotion- Pubsub subscription handler for promotion notifications
When running targeting a local Dapr, these environment variables are automatically set by the Aspire Dapr integration. When running targeting Catalyst, they are set based on values from Catalyst that you will provide.
With the application running, use the following commands to call the APIs.
curl -X POST http://localhost:8081/inventory/initializecurl -X POST http://localhost:8080/orders/process \
-H "Content-Type: application/json" \
-d '{
"customerId": "cust-001",
"items": [
{"productId": "prod-001", "quantity": 2, "price": 29.99},
{"productId": "prod-002", "quantity": 1, "price": 49.99}
]
}'curl http://localhost:8080/orders/{orderId}/statuscurl -X POST http://localhost:8080/promotions/send \
-H "Content-Type: application/json" \
-d '{
"promotionType": "flash_sale",
"message": "50% off all items for the next 2 hours!",
"targetAudience": "all_customers"
}'Check multiple items:
curl -X POST http://localhost:8080/orders/check-inventory \
-H "Content-Type: application/json" \
-d '{
"items": [
{"productId": "prod-001"},
{"productId": "prod-002"}
]
}'Check single product:
curl http://localhost:8080/orders/check-inventory/prod-001Once deployed, you'll receive URLs for both services. Use these URLs to test:
curl -X POST https://$INVENTORY_URL/inventory/initializecurl -X POST https://$ORDER_URL/orders/process \
-H "Content-Type: application/json" \
-d '{
"customerId": "cust-001",
"items": [
{"productId": "prod-001", "quantity": 2, "price": 29.99},
{"productId": "prod-002", "quantity": 1, "price": 49.99}
]
}'Retrieve the orderId from the payload returned and replace it in the curl command below.
curl https://$ORDER_URL/orders/{orderId}/status


