{
  "name": "Smarter RAG agents with enriched retrieval and modular workflows",
  "nodes": [
    {
      "id": "6052b910-009b-4db5-a956-096758e7cc07",
      "name": "Default Data Loader",
      "type": "@n8n/n8n-nodes-langchain.documentDefaultDataLoader",
      "position": [
        320,
        704
      ]
    },
    {
      "id": "c777cf9b-4048-4889-98e1-da1c38aaeb50",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1040,
        448
      ],
      "parameters": {
        "width": 1751,
        "height": 672,
        "content": "## File Ingestion pipeline"
      }
    },
    {
      "id": "cb389645-8257-4542-9255-ada92122865f",
      "name": "Recursive Character Text Splitter",
      "type": "@n8n/n8n-nodes-langchain.textSplitterRecursiveCharacterTextSplitter",
      "position": [
        400,
        912
      ]
    },
    {
      "id": "a034b27b-f602-43b4-a588-c284610a0b90",
      "name": "Delete Old Doc Rows",
      "type": "n8n-nodes-base.supabase",
      "position": [
        -256,
        768
      ]
    },
    {
      "id": "95aeede8-3cd7-489b-ae0e-f197af68fdde",
      "name": "When chat message received",
      "type": "@n8n/n8n-nodes-langchain.chatTrigger",
      "position": [
        -736,
        -32
      ]
    },
    {
      "id": "2a479838-750b-4a07-b58b-629040fef5f3",
      "name": "Insert into Supabase Vectorstore",
      "type": "@n8n/n8n-nodes-langchain.vectorStoreSupabase",
      "position": [
        224,
        480
      ]
    },
    {
      "id": "d3adc752-00a4-4e06-9d8b-93975b6248c2",
      "name": "Embeddings Google Gemini1",
      "type": "@n8n/n8n-nodes-langchain.embeddingsGoogleGemini",
      "position": [
        192,
        704
      ]
    },
    {
      "id": "9b02b9e2-1883-4c81-bf70-0d07aafd8c4d",
      "name": "On form submission",
      "type": "n8n-nodes-base.formTrigger",
      "position": [
        -928,
        672
      ]
    },
    {
      "id": "1545a027-fa95-4344-84eb-54da0b454285",
      "name": "Extract from File",
      "type": "n8n-nodes-base.extractFromFile",
      "position": [
        -704,
        672
      ]
    },
    {
      "id": "495722e8-2746-40ec-8793-667ab334bd89",
      "name": "Loop Over Items",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        -512,
        1360
      ]
    },
    {
      "id": "202868eb-6fab-4d39-a3c6-cdc0601abf86",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1040,
        1136
      ],
      "parameters": {
        "width": 1751,
        "height": 672,
        "content": "## Enrichment Pipeline"
      }
    },
    {
      "id": "177b1443-2e70-40e0-9a5b-2885e0a95f85",
      "name": "Get many rows",
      "type": "n8n-nodes-base.supabase",
      "position": [
        -736,
        1360
      ]
    },
    {
      "id": "6cb4273c-9f85-46bf-aae6-5d1a7b33321a",
      "name": "Update a row",
      "type": "n8n-nodes-base.supabase",
      "position": [
        320,
        1360
      ]
    },
    {
      "id": "8f6c4eef-8e8a-4149-8547-d5154fc68348",
      "name": "Merge",
      "type": "n8n-nodes-base.merge",
      "position": [
        -32,
        688
      ]
    },
    {
      "id": "ec4628dc-0b9b-416a-b9d8-bf5999828382",
      "name": "Wait",
      "type": "n8n-nodes-base.wait",
      "position": [
        512,
        1360
      ]
    },
    {
      "id": "05d41aff-ac21-4f17-a807-485a8c6a58ba",
      "name": "Set File Data",
      "type": "n8n-nodes-base.set",
      "position": [
        -480,
        672
      ]
    },
    {
      "id": "74925cc0-31fb-4ff5-9dea-9af6b155ad63",
      "name": "Metadata Obtention",
      "type": "@n8n/n8n-nodes-langchain.googleGemini",
      "position": [
        -32,
        1360
      ]
    },
    {
      "id": "507d8646-ef0b-442a-a887-496dcec2dbd2",
      "name": "Schedule Trigger",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        -960,
        1360
      ]
    },
    {
      "id": "a61859c2-872f-4510-a43f-c8490a76b938",
      "name": "Edit Fields",
      "type": "n8n-nodes-base.set",
      "position": [
        -256,
        1360
      ]
    },
    {
      "id": "63388b99-9d84-41cf-b8c6-94186db049b2",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1040,
        -384
      ],
      "parameters": {
        "width": 1744,
        "height": 800,
        "content": "## RAG Chat Agent"
      }
    },
    {
      "id": "1689c6a8-ba5f-493b-b31b-718bf7ce2ada",
      "name": "Query Builder",
      "type": "@n8n/n8n-nodes-langchain.googleGemini",
      "position": [
        -512,
        -32
      ]
    },
    {
      "id": "dee30e44-bd9b-421f-b9d0-5365ca8813bf",
      "name": "RAG Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        -96,
        -240
      ]
    },
    {
      "id": "14f8779d-043a-4b3b-8f96-ff6a0f5c1026",
      "name": "Reranker",
      "type": "@n8n/n8n-nodes-langchain.rerankerCohere",
      "position": [
        240,
        192
      ]
    },
    {
      "id": "024e08cb-30a6-4a1d-804c-f715b77ab220",
      "name": "Google Gemini 2.0 Flash",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        -160,
        -16
      ]
    },
    {
      "id": "af9307db-b459-4ce2-8dd6-c4207edfdc16",
      "name": "Postgres Chat Memory",
      "type": "@n8n/n8n-nodes-langchain.memoryPostgresChat",
      "position": [
        -32,
        -16
      ]
    },
    {
      "id": "ddc2ba09-f1bf-40e3-a48a-1cb08962279d",
      "name": "Embeddings Google Gemini",
      "type": "@n8n/n8n-nodes-langchain.embeddingsGoogleGemini",
      "position": [
        112,
        192
      ]
    },
    {
      "id": "3fa897aa-3299-4198-9ed1-05808311e6dc",
      "name": "Supabase Vector Store",
      "type": "@n8n/n8n-nodes-langchain.vectorStoreSupabase",
      "position": [
        112,
        -16
      ]
    },
    {
      "id": "84305b9d-2042-4f61-8d87-0208675d2d58",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1424,
        480
      ],
      "parameters": {
        "width": 272,
        "height": 256,
        "content": "## 🟩 File Ingestion Pipeline\n\nExtracts and chunks uploaded PDFs.\nEmbeds content and stores it in Supabase vector DB.\nClean and modular, ready for other sources (Notion, Drive, etc)."
      }
    },
    {
      "id": "2eb9bc0a-08dc-468e-88d4-fafb76dddbbb",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1408,
        1152
      ],
      "parameters": {
        "width": 272,
        "height": 256,
        "content": "## 🟨 Enrichment Pipeline (Async)\n\nEnriches chunks with semantic metadata using a lightweight LLM.\nImproves retrieval and enables filters like audience, use_case, risks.\nRuns asynchronously to reduce c"
      }
    },
    {
      "id": "a8e76143-cb9f-412e-96c3-e9f5cfbf4e17",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1408,
        -384
      ],
      "parameters": {
        "width": 272,
        "height": 288,
        "content": "## 🟦 RAG Agent Pipeline\n\nHandles user questions with memory, filtering, reranking, and references.\nPowered by a Query Builder + Cohere Reranker + Gemini LLM.\nAnswers only with retrieved content — safe"
      }
    },
    {
      "id": "315431cf-6b7f-43e9-ac3a-a3b2bd1280d7",
      "name": "Sticky Note26",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2672,
        -48
      ],
      "parameters": {
        "width": 832,
        "height": 1568,
        "content": "## 🧩 Prepare the Database (SQL)\n\nNow we’ll build the foundation that powers search, enrichment, and retrieval — think of it as creating the “semantic filing system” for your document library.\n\n### ✅ *"
      }
    },
    {
      "id": "d9415450-8f09-4120-aacb-af623509c0aa",
      "name": "Sticky Note9",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2640,
        512
      ],
      "parameters": {
        "width": 768,
        "height": 896,
        "content": "-- 🧹 (Optional) Clean up any previous table for fresh setup\ndrop table documents;\n\n-- 🧠 Enable pgvector to store and search vector embeddings\ncreate extension vector;\n\n-- 📚 Create the main table to st"
      }
    }
  ],
  "connections": {
    "Wait": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Merge": {
      "main": [
        [
          {
            "node": "Insert into Supabase Vectorstore",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Reranker": {
      "ai_reranker": [
        [
          {
            "node": "Supabase Vector Store",
            "type": "ai_reranker",
            "index": 0
          }
        ]
      ]
    },
    "Edit Fields": {
      "main": [
        [
          {
            "node": "Metadata Obtention",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Update a row": {
      "main": [
        [
          {
            "node": "Wait",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get many rows": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Query Builder": {
      "main": [
        [
          {
            "node": "RAG Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set File Data": {
      "main": [
        [
          {
            "node": "Delete Old Doc Rows",
            "type": "main",
            "index": 0
          },
          {
            "node": "Merge",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop Over Items": {
      "main": [
        [],
        [
          {
            "node": "Edit Fields",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Schedule Trigger": {
      "main": [
        [
          {
            "node": "Get many rows",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract from File": {
      "main": [
        [
          {
            "node": "Set File Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Metadata Obtention": {
      "main": [
        [
          {
            "node": "Update a row",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "On form submission": {
      "main": [
        [
          {
            "node": "Extract from File",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Default Data Loader": {
      "ai_document": [
        [
          {
            "node": "Insert into Supabase Vectorstore",
            "type": "ai_document",
            "index": 0
          }
        ]
      ]
    },
    "Delete Old Doc Rows": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Postgres Chat Memory": {
      "ai_memory": [
        [
          {
            "node": "RAG Agent",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "Supabase Vector Store": {
      "ai_tool": [
        [
          {
            "node": "RAG Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Google Gemini 2.0 Flash": {
      "ai_languageModel": [
        [
          {
            "node": "RAG Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Embeddings Google Gemini": {
      "ai_embedding": [
        [
          {
            "node": "Supabase Vector Store",
            "type": "ai_embedding",
            "index": 0
          }
        ]
      ]
    },
    "Embeddings Google Gemini1": {
      "ai_embedding": [
        [
          {
            "node": "Insert into Supabase Vectorstore",
            "type": "ai_embedding",
            "index": 0
          }
        ]
      ]
    },
    "When chat message received": {
      "main": [
        [
          {
            "node": "Query Builder",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Insert into Supabase Vectorstore": {
      "main": [
        []
      ]
    },
    "Recursive Character Text Splitter": {
      "ai_textSplitter": [
        [
          {
            "node": "Default Data Loader",
            "type": "ai_textSplitter",
            "index": 0
          }
        ]
      ]
    }
  }
}