{
  "name": "Detect and move duplicate Google Drive files with Supabase and Slack",
  "nodes": [
    {
      "id": "trigger-1",
      "name": "Google Drive Trigger",
      "type": "n8n-nodes-base.googleDriveTrigger",
      "position": [
        0,
        -160
      ]
    },
    {
      "id": "code-prepare",
      "name": "Prepare File Info",
      "type": "n8n-nodes-base.code",
      "position": [
        224,
        -160
      ]
    },
    {
      "id": "gdrive-download",
      "name": "Download File",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        448,
        -160
      ]
    },
    {
      "id": "if-validate-binary",
      "name": "Validate Binary",
      "type": "n8n-nodes-base.if",
      "position": [
        672,
        -160
      ]
    },
    {
      "id": "crypto-hash",
      "name": "Crypto",
      "type": "n8n-nodes-base.crypto",
      "position": [
        896,
        -256
      ]
    },
    {
      "id": "supa-check-hash",
      "name": "Check Hash Exists",
      "type": "n8n-nodes-base.supabase",
      "position": [
        1120,
        -256
      ]
    },
    {
      "id": "gdrive-move-dup",
      "name": "Move to Duplicates",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        1792,
        -256
      ]
    },
    {
      "id": "slack-notify",
      "name": "Notify Duplicate",
      "type": "n8n-nodes-base.slack",
      "position": [
        2016,
        -256
      ]
    },
    {
      "id": "code-prep-dup-log",
      "name": "Prepare Dup Log Data",
      "type": "n8n-nodes-base.code",
      "position": [
        2464,
        -256
      ]
    },
    {
      "id": "supa-log-dup",
      "name": "Log Duplicate Event",
      "type": "n8n-nodes-base.supabase",
      "position": [
        2688,
        -256
      ]
    },
    {
      "id": "code-prep-insert-hash",
      "name": "Prepare Hash Data",
      "type": "n8n-nodes-base.code",
      "position": [
        1792,
        96
      ]
    },
    {
      "id": "supa-insert-hash",
      "name": "Insert New Hash",
      "type": "n8n-nodes-base.supabase",
      "position": [
        2016,
        96
      ]
    },
    {
      "id": "code-handle-db-error",
      "name": "Handle DB Error",
      "type": "n8n-nodes-base.code",
      "position": [
        2240,
        96
      ]
    },
    {
      "id": "code-prep-unique-log",
      "name": "Prepare Unique Log Data",
      "type": "n8n-nodes-base.code",
      "position": [
        2464,
        96
      ]
    },
    {
      "id": "supa-log-unique",
      "name": "Log Unique Event",
      "type": "n8n-nodes-base.supabase",
      "position": [
        2688,
        96
      ]
    },
    {
      "id": "code-missing-binary",
      "name": "Handle Missing Binary",
      "type": "n8n-nodes-base.code",
      "position": [
        880,
        -16
      ]
    },
    {
      "id": "code-prep-error-log",
      "name": "Prepare Error Log Data",
      "type": "n8n-nodes-base.code",
      "position": [
        1088,
        -16
      ]
    },
    {
      "id": "supa-log-error",
      "name": "Log Error Event",
      "type": "n8n-nodes-base.supabase",
      "position": [
        1312,
        -16
      ]
    },
    {
      "id": "83d46f79-7eb1-4915-b817-695fb32e4e73",
      "name": "No Operation, do nothing",
      "type": "n8n-nodes-base.noOp",
      "position": [
        1568,
        -352
      ]
    },
    {
      "id": "9728263e-e319-41bb-b6a7-fef61060399b",
      "name": "Same File Re-triggered?",
      "type": "n8n-nodes-base.if",
      "position": [
        1344,
        -256
      ]
    },
    {
      "id": "if-duplicate",
      "name": "Hash Matched Different File?",
      "type": "n8n-nodes-base.if",
      "position": [
        1568,
        -144
      ]
    },
    {
      "id": "5b469c4c-c982-4768-b5ed-25024cba109f",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -48,
        -880
      ],
      "parameters": {
        "width": 656,
        "height": 544,
        "content": "This workflow detects and handles duplicate files uploaded to a specific Google Drive folder using content based hashing. Instead of relying on file names, it generates an MD5 hash from the actual fil"
      }
    },
    {
      "id": "b692e01c-32b3-40fe-9087-7a241f052d05",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -48,
        -272
      ],
      "parameters": {
        "width": 880,
        "height": 352,
        "content": "Watches a specific Google Drive folder for new uploads, extracts metadata, downloads the file, and validates that binary data exists before hashing."
      }
    },
    {
      "id": "fd0d975f-a6f4-496d-842b-1f04693c3540",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        848,
        -448
      ],
      "parameters": {
        "width": 416,
        "height": 352,
        "content": "Generates an MD5 hash from the file binary and checks Supabase to determine whether the hash already exists."
      }
    },
    {
      "id": "a8d32a63-100b-4768-8e25-65076003e777",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1280,
        -448
      ],
      "parameters": {
        "width": 864,
        "height": 352,
        "content": "If the hash exists for a different file, the workflow moves the file to a Duplicates folder and sends a Slack notification."
      }
    },
    {
      "id": "728ec4a7-cac6-4d9b-836b-6f89f3b0bd66",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1760,
        16
      ],
      "parameters": {
        "width": 640,
        "height": 272,
        "content": "If the hash does not exist, the workflow inserts the new hash into Supabase and confirms successful storage, including race condition handling."
      }
    },
    {
      "id": "7341d2ae-00fa-4aaa-ade2-2626851c31b4",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2416,
        -432
      ],
      "parameters": {
        "width": 496,
        "height": 720,
        "content": "Logs duplicates, unique inserts, race conditions, and binary errors into a Supabase audit table for traceability."
      }
    }
  ],
  "connections": {
    "Crypto": {
      "main": [
        [
          {
            "node": "Check Hash Exists",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Download File": {
      "main": [
        [
          {
            "node": "Validate Binary",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Handle DB Error": {
      "main": [
        [
          {
            "node": "Prepare Unique Log Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Insert New Hash": {
      "main": [
        [
          {
            "node": "Handle DB Error",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Validate Binary": {
      "main": [
        [
          {
            "node": "Crypto",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Handle Missing Binary",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Notify Duplicate": {
      "main": [
        [
          {
            "node": "Prepare Dup Log Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check Hash Exists": {
      "main": [
        [
          {
            "node": "Same File Re-triggered?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Prepare File Info": {
      "main": [
        [
          {
            "node": "Download File",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Prepare Hash Data": {
      "main": [
        [
          {
            "node": "Insert New Hash",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Move to Duplicates": {
      "main": [
        [
          {
            "node": "Notify Duplicate",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Drive Trigger": {
      "main": [
        [
          {
            "node": "Prepare File Info",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Prepare Dup Log Data": {
      "main": [
        [
          {
            "node": "Log Duplicate Event",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Handle Missing Binary": {
      "main": [
        [
          {
            "node": "Prepare Error Log Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Prepare Error Log Data": {
      "main": [
        [
          {
            "node": "Log Error Event",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Prepare Unique Log Data": {
      "main": [
        [
          {
            "node": "Log Unique Event",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Same File Re-triggered?": {
      "main": [
        [
          {
            "node": "No Operation, do nothing",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Hash Matched Different File?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Hash Matched Different File?": {
      "main": [
        [
          {
            "node": "Move to Duplicates",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Prepare Hash Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}