{
  "name": "AI study assistant with RAG - Google Gemini with Drive & Supabase vector search",
  "nodes": [
    {
      "id": "0db018d8-693f-4e47-be62-4b34d7b8d77f",
      "name": "Embeddings Google Gemini",
      "type": "@n8n/n8n-nodes-langchain.embeddingsGoogleGemini",
      "position": [
        912,
        592
      ]
    },
    {
      "id": "edf2e17e-a730-486b-8e2a-8acaef9e84a3",
      "name": "Supabase Vector Store",
      "type": "@n8n/n8n-nodes-langchain.vectorStoreSupabase",
      "position": [
        912,
        400
      ]
    },
    {
      "id": "1a55495f-44be-4c71-9a9d-f4886a8980a8",
      "name": "Postgres Chat Memory",
      "type": "@n8n/n8n-nodes-langchain.memoryPostgresChat",
      "position": [
        368,
        608
      ]
    },
    {
      "id": "39d7a9b3-66d8-41fb-8454-6a80885131d1",
      "name": "Calculator",
      "type": "@n8n/n8n-nodes-langchain.toolCalculator",
      "position": [
        768,
        464
      ]
    },
    {
      "id": "d943532d-4ae7-4829-a381-191cf84ea622",
      "name": "When chat message received",
      "type": "@n8n/n8n-nodes-langchain.chatTrigger",
      "position": [
        176,
        192
      ]
    },
    {
      "id": "f37c1723-0049-4b1d-8354-3acfd5179cb4",
      "name": "Google Gemini Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        256,
        448
      ]
    },
    {
      "id": "225fb496-37d1-4dd7-b008-179ebb0880cc",
      "name": "Folder all file to vector",
      "type": "@n8n/n8n-nodes-langchain.toolWorkflow",
      "position": [
        576,
        448
      ]
    },
    {
      "id": "2cec8fcc-a3ed-459e-9e30-1fad8a7b6765",
      "name": "Study Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        448,
        192
      ]
    },
    {
      "id": "cf65699a-9e5a-4c24-b256-fe3892c154fd",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -224,
        96
      ],
      "parameters": {
        "width": 336,
        "height": 640,
        "content": "# 🤖 AI Study Assistant (RAG Chat)\n\n**Purpose:** Conversational AI that helps you study by answering questions from your uploaded documents.\n\n**Flow:** Chat Input → AI Agent → Vector Search + Memory + "
      }
    },
    {
      "id": "eddf672b-4bd8-45d6-bf4e-29ddd688f1e5",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        416,
        32
      ],
      "parameters": {
        "width": 288,
        "height": 352,
        "content": "**AI Agent (Core)** - Orchestrates all tools and memory. Handles Drive links, searches documents, maintains context, and responds naturally using Gemini 2.5 Pro.\n"
      }
    },
    {
      "id": "c201dfbd-714c-4629-8a49-9acc006af38a",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        912,
        256
      ],
      "parameters": {
        "width": null,
        "height": 272,
        "content": "**Document Search Tool** - Retrieves relevant information from uploaded study materials using semantic similarity search with 768-dim embeddings.\n"
      }
    },
    {
      "id": "e29b5f39-3fcb-40b2-9ba0-02ef7d070f2a",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        512,
        512
      ],
      "parameters": {
        "width": null,
        "height": 208,
        "content": "\n\n\n\n\n\n**Drive Uploader Tool** - When user shares a Drive link in chat, automatically triggers the indexing workflow to add files to vector store.\n"
      }
    },
    {
      "id": "54a5e290-1ec4-4b97-96ed-d424aaf3c2ca",
      "name": "Embeddings Google Gemini4",
      "type": "@n8n/n8n-nodes-langchain.embeddingsGoogleGemini",
      "position": [
        1232,
        1392
      ]
    },
    {
      "id": "7682b868-5215-452d-b110-ff8007f2d059",
      "name": "Default Data Loader2",
      "type": "@n8n/n8n-nodes-langchain.documentDefaultDataLoader",
      "position": [
        1408,
        1376
      ]
    },
    {
      "id": "ceacbea3-3c6a-47d1-83a6-386cb1166414",
      "name": "Execute a SQL query",
      "type": "n8n-nodes-base.postgres",
      "position": [
        400,
        1120
      ]
    },
    {
      "id": "90883ae9-8d17-4a72-83be-da4dae013343",
      "name": "Code in JavaScript",
      "type": "n8n-nodes-base.code",
      "position": [
        176,
        1120
      ]
    },
    {
      "id": "1e5ac5c6-ae2c-400d-b531-a18c823a3d07",
      "name": "When Executed by Another Workflow",
      "type": "n8n-nodes-base.executeWorkflowTrigger",
      "position": [
        -32,
        1120
      ]
    },
    {
      "id": "472c0470-a590-476a-b23b-77617b042a39",
      "name": "Loop Over Items",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        832,
        1120
      ]
    },
    {
      "id": "8e8a66a7-9a2c-4ed9-91b3-80d805b1dbab",
      "name": "Search files and folders",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        608,
        1120
      ]
    },
    {
      "id": "21559a2e-f0d3-40a1-8809-5f2a31cde811",
      "name": "Insert into Supabase Vectorstore",
      "type": "@n8n/n8n-nodes-langchain.vectorStoreSupabase",
      "position": [
        1280,
        1120
      ]
    },
    {
      "id": "a818d7b0-1c5e-4273-96d1-d72ff2960823",
      "name": "Download File",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        1072,
        1136
      ]
    },
    {
      "id": "0cf08172-6b3e-44a9-aec7-44a2b5e582ff",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        592,
        1296
      ],
      "parameters": {
        "width": 176,
        "height": 128,
        "content": "**List Drive Files** - Retrieves all files from the specified Google Drive folder using extracted folder ID.\n"
      }
    },
    {
      "id": "98009dab-d49a-4205-9d9b-da29c3560d98",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1040,
        960
      ],
      "parameters": {
        "width": 150,
        "height": null,
        "content": "**List Drive Files** - Retrieves all files from the specified Google Drive folder using extracted folder ID.\n"
      }
    },
    {
      "id": "57415dae-d6cd-4c5a-8305-ee9100bec975",
      "name": "Sticky Note6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1264,
        864
      ],
      "parameters": {
        "width": null,
        "height": 240,
        "content": "**Store Embeddings** - Generates 768-dim vectors via Gemini and inserts documents into Supabase for semantic search.\n**AI Embeddings** - Converts text to 768-dimensional vectors using Google Gemini te"
      }
    },
    {
      "id": "677fd038-4cd9-483b-84ff-98373a6affb4",
      "name": "Sticky Note7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -480,
        944
      ],
      "parameters": {
        "width": 368,
        "height": 512,
        "content": "# 📁 Drive to Supabase Vector Store for Study RAG\n\nProcesses Google Drive folder files into Supabase vector embeddings for RAG applications.\n\n**Flow:** Drive URL → Parse ID → Init DB → Fetch Files → Lo"
      }
    },
    {
      "id": "975c4447-f0fe-48fd-afb9-e4da35b30080",
      "name": "Sticky Note8",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -80,
        1280
      ],
      "parameters": {
        "width": 176,
        "height": 128,
        "content": "**Trigger Node** - Starts workflow when called from another n8n workflow. Accepts Drive folder URL as input.\n"
      }
    },
    {
      "id": "a9cdb11e-fbb5-43b8-aa5d-6ea48be4fc85",
      "name": "Sticky Note9",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        160,
        1280
      ],
      "parameters": {
        "width": 150,
        "height": 128,
        "content": "**Extract Folder ID** - Parses Google Drive URL using regex to extract folder/file ID for API calls.\n"
      }
    },
    {
      "id": "01282543-fd57-4815-af73-bf26a2ff4a12",
      "name": "Sticky Note10",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        368,
        1280
      ],
      "parameters": {
        "width": 176,
        "height": null,
        "content": "**Initialize Database** - Creates Supabase vector table with pgvector extension and match_documents search function. ⚠️ Drops existing table!\n"
      }
    }
  ],
  "connections": {
    "Calculator": {
      "ai_tool": [
        [
          {
            "node": "Study Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Download File": {
      "main": [
        [
          {
            "node": "Insert into Supabase Vectorstore",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop Over Items": {
      "main": [
        [],
        [
          {
            "node": "Download File",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Code in JavaScript": {
      "main": [
        [
          {
            "node": "Execute a SQL query",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Execute a SQL query": {
      "main": [
        [
          {
            "node": "Search files and folders",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Default Data Loader2": {
      "ai_document": [
        [
          {
            "node": "Insert into Supabase Vectorstore",
            "type": "ai_document",
            "index": 0
          }
        ]
      ]
    },
    "Postgres Chat Memory": {
      "ai_memory": [
        [
          {
            "node": "Study Agent",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "Supabase Vector Store": {
      "ai_tool": [
        [
          {
            "node": "Study Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Embeddings Google Gemini": {
      "ai_embedding": [
        [
          {
            "node": "Supabase Vector Store",
            "type": "ai_embedding",
            "index": 0
          }
        ]
      ]
    },
    "Google Gemini Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Study Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Search files and folders": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Embeddings Google Gemini4": {
      "ai_embedding": [
        [
          {
            "node": "Insert into Supabase Vectorstore",
            "type": "ai_embedding",
            "index": 0
          }
        ]
      ]
    },
    "Folder all file to vector": {
      "ai_tool": [
        [
          {
            "node": "Study Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "When chat message received": {
      "main": [
        [
          {
            "node": "Study Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Insert into Supabase Vectorstore": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When Executed by Another Workflow": {
      "main": [
        [
          {
            "node": "Code in JavaScript",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}