The Order Management System is a microservices application consisting of two main services:
- Orders Service: Handles order creation and management via HTTP and gRPC APIs
- Kitchen Service: Provides a web interface for viewing orders
┌─────────────────┐ gRPC ┌─────────────────┐
│ Kitchen Service│ ──────────► │ Orders Service │
│ Port: 1000 │ │ HTTP: 8000 │
│ (Web UI) │ │ gRPC: 9000 │
└─────────────────┘ └─────────────────┘
- HTTP API:
http://localhost:8000 - gRPC API:
localhost:9000
Creates a new order in the system.
Endpoint: POST /orders
Request Body:
{
"customer_id": 123,
"product_id": 456,
"quantity": 2
}Request Parameters:
| Field | Type | Required | Description |
|---|---|---|---|
customer_id |
integer | Yes | ID of the customer placing the order |
product_id |
integer | Yes | ID of the product being ordered |
quantity |
integer | Yes | Number of items to order |
Response:
{
"status": "success"
}Example Request:
curl -X POST http://localhost:8000/orders \
-H "Content-Type: application/json" \
-d '{
"customer_id": 123,
"product_id": 456,
"quantity": 2
}'Example Response:
{
"status": "success"
}Error Responses:
400 Bad Request: Invalid JSON or missing required fields500 Internal Server Error: Server error during order creation
The Orders Service implements the following gRPC service:
service OrderService {
rpc CreateOrder(CreateOrderRequest) returns (CreateOrderResponse);
rpc GetOrders(GetOrdersRequest) returns (GetOrderResponse);
}Creates a new order via gRPC.
Method: OrderService.CreateOrder
Request Message:
message CreateOrderRequest {
int32 customerID = 1;
int32 productID = 2;
int32 quantity = 3;
}Response Message:
message CreateOrderResponse {
string status = 1;
}Retrieves orders for a specific customer.
Method: OrderService.GetOrders
Request Message:
message GetOrdersRequest {
int32 customerID = 1;
}Response Message:
message GetOrderResponse {
repeated Order orders = 1;
}
message Order {
int32 OrderID = 1;
int32 CustomerID = 2;
int32 ProductID = 3;
int32 Quantity = 4;
}- Web Interface:
http://localhost:1000
The Kitchen Service provides a web-based dashboard for viewing orders.
Endpoint: GET /
Response: HTML page displaying all orders in a table format.
Features:
- Displays orders in a formatted table
- Shows Order ID, Customer ID, and Quantity
- Automatically creates a sample order when accessed
- Connects to Orders Service via gRPC to fetch data
Example Usage:
# Open in browser
open http://localhost:1000
# Or curl to see HTML
curl http://localhost:1000Represents an order in the system.
{
"order_id": 42,
"customer_id": 123,
"product_id": 456,
"quantity": 2
}Fields:
| Field | Type | Description |
|---|---|---|
order_id |
integer | Unique identifier for the order |
customer_id |
integer | ID of the customer who placed the order |
product_id |
integer | ID of the product being ordered |
quantity |
integer | Number of items ordered |
- Go 1.22.0 or later
- All dependencies installed (
go mod tidy)
-
Start Orders Service:
make run-orders # or go run services/orders/*.go
-
Start Kitchen Service:
make run-kitchen # or go run services/kitchen/*.go
- Orders HTTP API:
:8000 - Orders gRPC API:
:9000 - Kitchen Web UI:
:1000
# Create an order
curl -X POST http://localhost:8000/orders \
-H "Content-Type: application/json" \
-d '{"customer_id": 123, "product_id": 456, "quantity": 2}'# View orders dashboard
curl http://localhost:1000You can use tools like grpcurl or evans to test the gRPC endpoints:
# Install grpcurl
go install github.com/fullstorydev/grpcurl/cmd/grpcurl@latest
# List services
grpcurl -plaintext localhost:9000 list
# Call CreateOrder
grpcurl -plaintext -d '{"customerID": 123, "productID": 456, "quantity": 2}' \
localhost:9000 OrderService.CreateOrder
# Call GetOrders
grpcurl -plaintext -d '{"customerID": 42}' \
localhost:9000 OrderService.GetOrdersThe HTTP API returns standard HTTP status codes:
200 OK: Request successful400 Bad Request: Invalid request data500 Internal Server Error: Server error
Error responses include a JSON body with error details.
The gRPC API returns standard gRPC status codes:
OK: Request successfulINVALID_ARGUMENT: Invalid request parametersINTERNAL: Internal server error
- ✅ HTTP API for order creation
- ✅ gRPC API for order creation and retrieval
- ✅ Web interface for order viewing
- ✅ In-memory order storage
⚠️ Order IDs are currently hardcoded (42)⚠️ Limited error handling⚠️ No authentication/authorization
- Database persistence
- User authentication
- Order status tracking
- Product catalog integration
- Order history and analytics
- API versioning
- Rate limiting
- Comprehensive error handling
For issues or questions about the API, please refer to the source code or create an issue in the project repository.