{
  "name": "Code Review Assistant via OpenAI",
  "nodes": [
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "code-review",
        "responseMode": "lastNode",
        "options": {}
      },
      "id": "cra00001-0001-4000-8000-000000000001",
      "name": "Code Review Webhook",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [240, 300]
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "field1",
              "name": "language",
              "value": "={{ $json.body.language }}",
              "type": "string"
            },
            {
              "id": "field2",
              "name": "code",
              "value": "={{ $json.body.code }}",
              "type": "string"
            },
            {
              "id": "field3",
              "name": "focusArea",
              "value": "={{ $json.body.focusArea ?? 'general' }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "id": "cra00001-0002-4000-8000-000000000002",
      "name": "Extract Code Fields",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3,
      "position": [460, 300]
    },
    {
      "parameters": {
        "model": "gpt-4o",
        "messages": {
          "values": [
            {
              "role": "system",
              "content": "You are an expert code reviewer. Analyse the provided code snippet for bugs, security issues, performance problems, and style violations. Return a structured JSON with keys: summary, bugs, security, performance, style, score (0-10)."
            },
            {
              "role": "user",
              "content": "Language: {{ $json.language }}\nFocus: {{ $json.focusArea }}\n\nCode:\n```\n{{ $json.code }}\n```"
            }
          ]
        },
        "options": {
          "temperature": 0.2,
          "maxTokens": 1000,
          "responseFormat": "json_object"
        }
      },
      "id": "cra00001-0003-4000-8000-000000000003",
      "name": "Analyse with OpenAI",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "typeVersion": 1,
      "position": [680, 300]
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "out1",
              "name": "review",
              "value": "={{ JSON.parse($json.message.content) }}",
              "type": "object"
            },
            {
              "id": "out2",
              "name": "reviewedAt",
              "value": "={{ new Date().toISOString() }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "id": "cra00001-0004-4000-8000-000000000004",
      "name": "Format Review Response",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3,
      "position": [900, 300]
    }
  ],
  "connections": {
    "Code Review Webhook": {
      "main": [[{ "node": "Extract Code Fields", "type": "main", "index": 0 }]]
    },
    "Extract Code Fields": {
      "main": [[{ "node": "Analyse with OpenAI", "type": "main", "index": 0 }]]
    },
    "Analyse with OpenAI": {
      "main": [[{ "node": "Format Review Response", "type": "main", "index": 0 }]]
    }
  },
  "active": false,
  "settings": { "executionOrder": "v1" },
  "meta": {},
  "pinData": {}
}
