# Console Output Example - insert_menu_items Service

## What You'll See in the Console

When you make a request, you'll see **both** structured logs (JSON) and **formatted console prints** with full data.

---

## 1. Menu Extraction Service Response

### Console Print:
```
================================================================================
MENU EXTRACTION SERVICE RESPONSE
================================================================================
Request ID: 550e8400-e29b-41d4-a716-446655440000
Restaurant: Restaurant Name
Categories: 5
Model: gpt-4o-mini

Full Response Data:
{
  "menu": {
    "restaurant_name": "Restaurant Name",
    "categories": [
      {
        "name": "Salads",
        "description": "Fresh salads",
        "items": [
          {
            "name": "Caesar Salad",
            "description": "Classic Caesar with romaine lettuce",
            "price": "15.00 лв",
            "currency": "BGN",
            "serving_size": "250g",
            "notes": null
          },
          {
            "name": "Greek Salad",
            "description": "Traditional Greek salad",
            "price": "12.00 лв",
            "currency": "BGN",
            "serving_size": "300g",
            "notes": "Vegetarian"
          }
        ]
      },
      {
        "name": "Main Courses",
        "description": "Hot main dishes",
        "items": [
          {
            "name": "Grilled Chicken",
            "description": "Marinated chicken breast",
            "price": "18.00 лв",
            "currency": "BGN",
            "serving_size": "350g",
            "notes": null
          }
        ]
      }
    ]
  },
  "source_language": "bg",
  "target_language": "en",
  "model": "gpt-4o-mini",
  "image_count": 1
}
================================================================================
```

### Log File Entry:
```json
{
  "timestamp": "2025-12-10T14:23:45.123456",
  "level": "INFO",
  "event": "MENU_EXTRACTION_RESPONSE",
  "request_id": "550e8400-e29b-41d4-a716-446655440000",
  "response_data": { ... full data ... }
}
```

---

## 2. Transformed Payload for createMenu.php

### Console Print:
```
================================================================================
PAYLOAD BEING SENT TO createMenu.php
================================================================================
Request ID: 550e8400-e29b-41d4-a716-446655440000
City: sofia
URL: https://zavedenia.com/apps/orderapprestaurant/api/createMenu.php
Categories: 2
Total Items: 3

Full Payload:
{
  "city": "sofia",
  "token": "8800a3a64cfa947c552391f48069cacd",
  "menu": [
    {
      "name": "Salads",
      "name_uk": "Salads",
      "description": "Fresh salads",
      "description_uk": "Fresh salads",
      "items": [
        {
          "name": "Caesar Salad",
          "name_uk": "Caesar Salad",
          "description": "Classic Caesar with romaine lettuce",
          "description_uk": "Classic Caesar with romaine lettuce",
          "measure": 1,
          "items": [
            {
              "name": "Стандартна порция",
              "gramaj": 250,
              "cena": 15.0
            }
          ]
        },
        {
          "name": "Greek Salad",
          "name_uk": "Greek Salad",
          "description": "Traditional Greek salad",
          "description_uk": "Traditional Greek salad",
          "measure": 1,
          "items": [
            {
              "name": "Стандартна порция",
              "gramaj": 300,
              "cena": 12.0
            }
          ]
        }
      ]
    },
    {
      "name": "Main Courses",
      "name_uk": "Main Courses",
      "description": "Hot main dishes",
      "description_uk": "Hot main dishes",
      "items": [
        {
          "name": "Grilled Chicken",
          "name_uk": "Grilled Chicken",
          "description": "Marinated chicken breast",
          "description_uk": "Marinated chicken breast",
          "measure": 1,
          "items": [
            {
              "name": "Стандартна порция",
              "gramaj": 350,
              "cena": 18.0
            }
          ]
        }
      ]
    }
  ]
}
================================================================================
```

### Log File Entry:
```json
{
  "timestamp": "2025-12-10T14:23:48.234567",
  "level": "INFO",
  "event": "TRANSFORMED_PAYLOAD_FOR_CREATE_MENU",
  "request_id": "550e8400-e29b-41d4-a716-446655440000",
  "payload": { ... full payload ... }
}
```

### Additional Log (Request Being Sent):
```json
{
  "timestamp": "2025-12-10T14:23:48.345678",
  "level": "INFO",
  "event": "CREATE_MENU_REQUEST_PAYLOAD",
  "request_id": "550e8400-e29b-41d4-a716-446655440000",
  "attempt": 1,
  "url": "https://zavedenia.com/apps/orderapprestaurant/api/createMenu.php",
  "full_payload": { ... full payload ... }
}
```

---

## 3. Response from createMenu.php

### Console Print (Success):
```
================================================================================
RESPONSE FROM createMenu.php
================================================================================
Request ID: 550e8400-e29b-41d4-a716-446655440000
Status Code: 200
Attempt: 1/3

Full Response:
{"status":"success","message":"Menu created successfully","menu_id":12345}

Parsed JSON Response:
{
  "status": "success",
  "message": "Menu created successfully",
  "menu_id": 12345
}
================================================================================
```

### Console Print (If Not JSON):
```
================================================================================
RESPONSE FROM createMenu.php
================================================================================
Request ID: 550e8400-e29b-41d4-a716-446655440000
Status Code: 200
Attempt: 1/3

Full Response:
Menu created successfully

(Response is not JSON format)
================================================================================
```

### Log File Entries:
```json
{
  "timestamp": "2025-12-10T14:23:50.456789",
  "level": "INFO",
  "event": "CREATE_MENU_RESPONSE",
  "request_id": "550e8400-e29b-41d4-a716-446655440000",
  "attempt": 1,
  "status_code": 200,
  "full_response": "{\"status\":\"success\",\"message\":\"Menu created successfully\",\"menu_id\":12345}"
}
```

```json
{
  "timestamp": "2025-12-10T14:23:50.567890",
  "level": "INFO",
  "event": "CREATE_MENU_RESPONSE_PARSED",
  "request_id": "550e8400-e29b-41d4-a716-446655440000",
  "response_data": {
    "status": "success",
    "message": "Menu created successfully",
    "menu_id": 12345
  }
}
```

---

## 4. Final Status

### Console (via structured logs):
```
========================================
```
```json
{
  "timestamp": "2025-12-10T14:23:50.678901",
  "level": "INFO",
  "event": "MENU_UPLOAD_PROCESSING_COMPLETED_SUCCESSFULLY",
  "request_id": "550e8400-e29b-41d4-a716-446655440000",
  "city": "sofia",
  "filename": "menu.jpg",
  "source_language": "bg",
  "target_language": "en",
  "categories_count": 2,
  "total_items": 3,
  "processing_time_seconds": 12.45,
  "status": "SUCCESS"
}
```
```
========================================
```

---

## Complete Console Flow

When you run the service, you'll see:

1. ✅ Initial request logs (validation, file reading)
2. ✅ Background task scheduled confirmation
3. ✅ **BIG BOX: Menu Extraction Response** (full JSON data)
4. ✅ **BIG BOX: Payload Being Sent to createMenu.php** (full JSON data)
5. ✅ **BIG BOX: Response from createMenu.php** (full response + parsed JSON)
6. ✅ Final status with metrics

## Verification Points

### To verify createMenu.php was called:
Look for these in console:
- `PAYLOAD BEING SENT TO createMenu.php` (shows what's being sent)
- `CREATE_MENU_REQUEST_PAYLOAD` log (confirms request was made)
- `RESPONSE FROM createMenu.php` (shows the response received)

### To verify menu extraction worked:
Look for:
- `MENU EXTRACTION SERVICE RESPONSE` (full extracted menu data)

### All data is:
- ✅ **Printed to console** (with nice formatting)
- ✅ **Logged to logs/app.log** (JSON format for processing)
- ✅ **Includes full request/response bodies**

---

## Example Full Console Session

```bash
$ uvicorn app.main:app --reload

INFO:     Started server process [12345]
INFO:     Waiting for application startup.
...

# User makes request via curl

{"event": "insert_menu_items_request", "request_id": "550e8400..."}
{"event": "VALIDATING_REQUEST", ...}
{"event": "FILE_READ_SUCCESS", "size_kb": 239.92, ...}
{"event": "REQUEST_ACCEPTED_202", ...}

# Background processing starts

{"event": "menu_upload_processing_started", ...}
{"event": "STEP_1_START: Calling menu extraction service", ...}

================================================================================
MENU EXTRACTION SERVICE RESPONSE
================================================================================
Request ID: 550e8400...
Restaurant: Restaurant Name
Categories: 2
Model: gpt-4o-mini

Full Response Data:
{
  "menu": { ... FULL MENU DATA ... }
}
================================================================================

{"event": "STEP_1_COMPLETED", ...}
{"event": "STEP_2_START: Transforming menu data", ...}

================================================================================
PAYLOAD BEING SENT TO createMenu.php
================================================================================
Request ID: 550e8400...
City: sofia
URL: https://zavedenia.com/...

Full Payload:
{
  "city": "sofia",
  "token": "8800a3a6...",
  "menu": [ ... FULL TRANSFORMED DATA ... ]
}
================================================================================

{"event": "STEP_3_START", ...}
{"event": "API_REQUEST_ATTEMPT", ...}

================================================================================
RESPONSE FROM createMenu.php
================================================================================
Request ID: 550e8400...
Status Code: 200

Full Response:
{"status":"success", ...}

Parsed JSON Response:
{
  "status": "success",
  "message": "Menu created successfully"
}
================================================================================

========================================
MENU_UPLOAD_PROCESSING_COMPLETED_SUCCESSFULLY
status: SUCCESS
processing_time_seconds: 12.45
========================================
```

## Summary

Every critical data point is now:
1. **Printed to console** with clear formatting and boxes
2. **Logged to file** in JSON format with full data
3. **Includes complete request/response bodies** for verification
4. **Easy to verify** createMenu.php was actually called and what it returned
