{
  "name": "HYPEAKZ \u2014 Invoice Data Extractor (OCR + AI, 100% Local)",
  "nodes": [
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "extract-invoice",
        "responseMode": "responseNode"
      },
      "id": "node-webhook",
      "name": "Invoice Upload",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [
        250,
        300
      ]
    },
    {
      "parameters": {
        "operation": "extractFromFile",
        "options": {}
      },
      "id": "node-extract-text",
      "name": "Extract Text from PDF",
      "type": "n8n-nodes-base.extractFromFile",
      "typeVersion": 1,
      "position": [
        500,
        300
      ]
    },
    {
      "parameters": {
        "model": "llama3.2",
        "baseUrl": "http://ollama:11434"
      },
      "id": "node-ollama",
      "name": "Ollama Local LLM",
      "type": "@n8n/n8n-nodes-langchain.lmOllama",
      "typeVersion": 1,
      "position": [
        750,
        550
      ]
    },
    {
      "parameters": {
        "prompt": "You are an invoice data extraction specialist. Extract all structured data from this invoice text:\n\n{{ $json.data }}\n\nReturn a JSON object with:\n- invoice_number: the invoice/reference number\n- invoice_date: date of invoice (ISO format if possible)\n- due_date: payment due date\n- vendor_name: company that issued the invoice\n- vendor_address: full address\n- vendor_tax_id: VAT/tax ID if present\n- client_name: who the invoice is billed to\n- client_address: billing address\n- line_items: array of items, each with: description, quantity, unit_price, total\n- subtotal: pre-tax total\n- tax_rate: tax percentage\n- tax_amount: tax in currency\n- total_amount: final total with currency symbol\n- currency: detected currency (EUR, USD, GBP, etc.)\n- payment_terms: payment conditions\n- bank_details: IBAN/bank info if present\n- notes: any additional notes\n\nIf a field is not found, use null. Be precise with numbers."
      },
      "id": "node-parse",
      "name": "Parse Invoice Data (AI)",
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "typeVersion": 1.4,
      "position": [
        750,
        300
      ]
    },
    {
      "parameters": {
        "values": {
          "string": [
            {
              "name": "invoice_data",
              "value": "={{ $json.text }}"
            },
            {
              "name": "source_file",
              "value": "={{ $('Invoice Upload').item.json.headers['content-disposition'] }}"
            },
            {
              "name": "processed_at",
              "value": "={{ $now.toISO() }}"
            },
            {
              "name": "model",
              "value": "llama3.2 (local)"
            }
          ]
        }
      },
      "id": "node-format",
      "name": "Format Output",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        1000,
        300
      ]
    },
    {
      "parameters": {
        "respondWith": "json",
        "responseBody": "={{ JSON.stringify($json) }}"
      },
      "id": "node-respond",
      "name": "Return Invoice Data",
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1.1,
      "position": [
        1250,
        300
      ]
    }
  ],
  "connections": {
    "Invoice Upload": {
      "main": [
        [
          {
            "node": "Extract Text from PDF",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract Text from PDF": {
      "main": [
        [
          {
            "node": "Parse Invoice Data (AI)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Ollama Local LLM": {
      "ai_languageModel": [
        [
          {
            "node": "Parse Invoice Data (AI)",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Parse Invoice Data (AI)": {
      "main": [
        [
          {
            "node": "Format Output",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Format Output": {
      "main": [
        [
          {
            "node": "Return Invoice Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1"
  },
  "tags": [
    {
      "name": "HYPEAKZ.IO"
    },
    {
      "name": "Self-Hosted AI"
    },
    {
      "name": "Ollama"
    },
    {
      "name": "Invoice Processing"
    }
  ]
}