Skip to content

Instantly share code, notes, and snippets.

@jeroos
Created October 30, 2024 03:12
Show Gist options
  • Save jeroos/cdf8089766fb0a1678721b7a51819d1a to your computer and use it in GitHub Desktop.
Save jeroos/cdf8089766fb0a1678721b7a51819d1a to your computer and use it in GitHub Desktop.

Food Delivery Management API

Models

  • Restaurant (Id, Name, Menu[])
  • Order (Id, RestaurantId, CustomerAddress, Status, Items[])

API Endpoints

1. GET /api/restaurants

List restaurants

  • Query parameters:
{
    "cuisine": "Italian",
    "location": "Downtown",
    "rating": 4,
    "isOpen": true
}
  • Response:
{
    "restaurants": [
        {
            "id": 1,
            "name": "Bella Italia",
            "cuisine": "Italian",
            "rating": 4.5,
            "estimatedDeliveryTime": 30,
            "minimumOrder": 15.00
        }
    ]
}

2. POST /api/orders

Place order

  • Request:
{
    "restaurantId": 1,
    "customerName": "Eve Wilson",
    "deliveryAddress": "123 Main St",
    "phone": "123-456-7890",
    "items": [
        {
            "menuItemId": 1,
            "quantity": 2,
            "specialInstructions": "Extra cheese"
        }
    ]
}
  • Validation:
    • Restaurant must be open
    • Minimum order amount
    • Valid phone format
    • Delivery address within range

3. PUT /api/orders/{id}/status

Update order status

  • Business rules:
    • Sequential status updates
    • Time tracking for each stage
    • Notification triggers

4. GET /api/restaurants/{id}/analytics

Get restaurant analytics

  • Response:
{
    "period": "2024-11",
    "totalOrders": 150,
    "revenue": 4500.00,
    "averageDeliveryTime": 28,
    "popularItems": [
        {
            "name": "Margherita Pizza",
            "orderCount": 45,
            "revenue": 675.00
        }
    ]
}

Requirements

  • Handle multiple payment methods
  • Implement delivery tracking
  • Manage delivery zones
  • Handle order rating/feedback

Error Handling

Implement global exception handling with appropriate status codes:

  • 400: Bad Request (validation errors)
  • 404: Not Found
  • 409: Conflict (business rule violations)
  • 500: Internal Server Error
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment