# E-Commerce Example: gRPC API Expose commands and queries via gRPC services. ## Proto File Definition Create `Protos/ecommerce.proto`: ```protobuf syntax = "proto3"; package ecommerce; service OrderService { rpc PlaceOrder(PlaceOrderCommand) returns (PlaceOrderResponse); rpc CancelOrder(CancelOrderCommand) returns (google.protobuf.Empty); rpc GetOrder(GetOrderQuery) returns (OrderDto); rpc ListOrders(ListOrdersQuery) returns (OrderListResponse); } message PlaceOrderCommand { string customer_id = 1; repeated OrderLineDto lines = 2; string shipping_address = 3; } message PlaceOrderResponse { string order_id = 1; } message OrderDto { string order_id = 1; string customer_id = 2; repeated OrderLineDto lines = 3; double total_amount = 4; string status = 5; int64 placed_at = 6; } ``` ## gRPC Setup ```csharp builder.Services.AddGrpc(); var app = builder.Build(); app.MapGrpcService(); app.MapGrpcReflectionService(); app.Run(); ``` ## See Also - [09-complete-code.md](09-complete-code.md) - Full working example - [gRPC Integration](../../grpc-integration/README.md)