> ## Documentation Index
> Fetch the complete documentation index at: https://docs.criar.in/llms.txt
> Use this file to discover all available pages before exploring further.

# Food Menu

> Weekly cafeteria menu management and nutrition information for Parents and Staff.

## 1. API Purpose

The Food Menu API communicates the school cafeteria's schedule and nutrition details to parents. It helps parents stay informed about their child's tiffin/meal plans and supports dietary management.

***

## 2. Endpoint Definition

| Method | Route                                 | Auth   | Description                 |
| ------ | ------------------------------------- | ------ | --------------------------- |
| GET    | `/parent-app/food-menu`               | 🔐 JWT | View daily/weekly food menu |
| GET    | `/web-app/food-menu`                  | 🔐 JWT | List all menu definitions   |
| GET    | `/web-app/food-menu/:id`              | 🔐 JWT | View single menu detail     |
| POST   | `/web-app/food-menu`                  | 🔐 JWT | Create new food menu item   |
| PUT    | `/web-app/food-menu/:id`              | 🔐 JWT | Update menu item details    |
| DELETE | `/web-app/food-menu/:id`              | 🔐 JWT | Delete a menu item          |
| POST   | `/web-app/bulk-import-food-menu`      | 🔐 JWT | Bulk import from Excel/CSV  |
| POST   | `/web-app/bulk-import-food-menu-json` | 🔐 JWT | Bulk import from JSON       |

***

## 3. Authentication Flow

Standard JWT validation.

* Parents can only view the menu for their school.
* Staff require `food.manage` permissions to update the menu or schedule.

***

## 4. Request Structure

#### GET /parent-app/food-menu

**Query Parameters:**

| Field  | Type   | Required | Description                         |
| ------ | ------ | -------- | ----------------------------------- |
| day    | string | No       | Filter by day (e.g., Monday).       |
| period | string | No       | Filter by period (e.g., Breakfast). |

#### GET /web-app/food-menu

**Query Parameters:**

| Field     | Type   | Required | Description        |
| --------- | ------ | -------- | ------------------ |
| skole\_id | string | Yes      | School identifier. |
| menu\_day | string | No       | Filter by day.     |
| period    | string | No       | Filter by period.  |

#### GET /web-app/food-menu/:id

**URL Parameters:**

| Field | Type   | Description                 |
| ----- | ------ | --------------------------- |
| id    | number | ID of the food menu record. |

#### POST /web-app/food-menu

**Request Body:**

```json theme={null}
{
  "skole_id": "SKL001",
  "food_menu_title": "Healthy Breakfast",
  "food_menu_items": "Oatmeal, Banana, Milk",
  "menu_nutrients": "Fiber, Potassium, Calcium",
  "menu_health_benefits": "Energy boost, Heart healthy",
  "menu_day": "Monday",
  "period": "Breakfast",
  "status": "active"
}
```

#### PUT /web-app/food-menu/:id

**Request Body:**

```json theme={null}
{
  "food_menu_title": "Updated Title",
  "status": "inactive"
}
```

#### DELETE /web-app/food-menu/:id

**URL Parameters:**

| Field | Type   | Description   |
| ----- | ------ | ------------- |
| id    | number | ID to delete. |

#### POST /web-app/bulk-import-food-menu-json

**Request Body:**

```json theme={null}
{
  "skole_id": "SKL001",
  "records": [
    {
      "food_menu_title": "Lunch",
      "food_menu_items": "Rice, Dal, Salad",
      "menu_day": "Monday",
      "period": "Lunch"
    }
  ]
}
```

#### POST /web-app/bulk-import-food-menu

**Content-Type:** `multipart/form-data`
**Query Parameters:** `skole_id=SKL001`
**File:** Upload `.xlsx` or `.csv` file.

***

## 5. Response Structure

#### Success: Parent Menu View (200 OK)

**Route:** `GET /parent-app/food-menu`

```json theme={null}
{
  "success": true,
  "data": [
    {
      "day": "Monday",
      "period": "Breakfast",
      "items": "Oatmeal, Banana",
      "health_benefits": "Energy boost"
    }
  ]
}
```

#### Success: Admin Menu List (200 OK)

**Route:** `GET /web-app/food-menu`

```json theme={null}
{
  "success": true,
  "data": [
    {
      "id": 1,
      "food_menu_title": "Healthy Breakfast",
      "status": "active"
    }
  ]
}
```

#### Success: Single Item Detail (200 OK)

**Route:** `GET /web-app/food-menu/:id`

```json theme={null}
{
  "success": true,
  "data": {
    "id": 1,
    "food_menu_title": "Healthy Breakfast",
    "nutrients": "Fiber, Calcium",
    "period": "Breakfast"
  }
}
```

#### Success: Menu Created (201 Created)

**Route:** `POST /web-app/food-menu`

```json theme={null}
{
  "success": true,
  "message": "Menu item created",
  "data": { "id": 5 }
}
```

#### Success: Bulk Import Results (200 OK)

**Route:** `POST /web-app/bulk-import-food-menu-json`

```json theme={null}
{
  "success": true,
  "message": "Bulk import completed",
  "data": {
    "total": 10,
    "inserted": 10,
    "errors": 0
  }
}
```

#### Success: Item Deleted (200 OK)

**Route:** `DELETE /web-app/food-menu/:id`

```json theme={null}
{
  "success": true,
  "message": "Food menu item deleted"
}
```

***

## 6. Error Responses

| HTTP Code | Description                          |
| --------- | ------------------------------------ |
| 400       | Invalid `menu_day` or `period` value |

***

## 7. Security Considerations

* **Tenant Isolation:** Menus are strictly scoped by `skole_id`.
* **Status Toggle:** Inactive menus are automatically filtered out of the parent app view.

***

## 8. Token Usage

```http theme={null}
GET /parent-app/food-menu?day=Monday
Authorization: Bearer <TOKEN>
```

***

## 9. Token Refresh

N/A.

***

## 10. Logout / Session Invalidation

N/A.

***

## 11. Usage Example (cURL)

```bash theme={null}
curl -H "Authorization: Bearer <TOKEN>" \
"http://localhost:3000/parent-app/food-menu?period=lunch"
```

***

## 12. Notes / Special Behaviors

* **Scheduling:** The menu system separates "Menu Definitions" (what the food is) from "Schedules" (when it is served).
* **Nutrients:** Information is provided as a plain text summary for parent reference.
