{
  "name": "Mask PII in documents for GDPR-safe AI processing with Postgres and Claude",
  "nodes": [
    {
      "id": "3510f22b-6743-4ee5-ac1a-59df62cf54d0",
      "name": "Document Upload Webhook",
      "type": "n8n-nodes-base.webhook",
      "position": [
        -2528,
        432
      ]
    },
    {
      "id": "bbfef060-261b-451e-982a-36408aa5f722",
      "name": "Workflow Configuration",
      "type": "n8n-nodes-base.set",
      "position": [
        -2320,
        432
      ]
    },
    {
      "id": "723dec91-ad38-4a6f-9eae-8c34197b76e2",
      "name": "OCR Extract Text",
      "type": "n8n-nodes-base.extractFromFile",
      "position": [
        -2128,
        432
      ]
    },
    {
      "id": "570e62ce-852e-41b1-889c-1e3197343ecd",
      "name": "Email Detector",
      "type": "n8n-nodes-base.code",
      "position": [
        -1728,
        144
      ]
    },
    {
      "id": "f62cc18d-7992-4efa-8d32-7f70d18ac8a5",
      "name": "Phone Detector",
      "type": "n8n-nodes-base.code",
      "position": [
        -1728,
        336
      ]
    },
    {
      "id": "1e01d3c6-92f3-43c5-b112-e1b710915ae3",
      "name": "ID Number Detector",
      "type": "n8n-nodes-base.code",
      "position": [
        -1728,
        528
      ]
    },
    {
      "id": "89110cc9-a2e8-4c9d-8b21-402061b83355",
      "name": "Address Detector AI",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        -1808,
        848
      ]
    },
    {
      "id": "3725829c-72a7-4f14-9e91-dc32234b9813",
      "name": "Address Output Parser",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        -1616,
        992
      ]
    },
    {
      "id": "0c9d02ad-87f3-43d9-9e24-e72cd97e180f",
      "name": "Merge PII Detections",
      "type": "n8n-nodes-base.merge",
      "position": [
        -1440,
        240
      ]
    },
    {
      "id": "93b9bdf5-468b-40fa-b6ea-b7136216de88",
      "name": "PII Consolidation & Conflict Resolver",
      "type": "n8n-nodes-base.code",
      "position": [
        -1216,
        240
      ]
    },
    {
      "id": "40678c14-67ad-461b-9043-bcb76a86cb08",
      "name": "Tokenization & Vault Storage",
      "type": "n8n-nodes-base.code",
      "position": [
        -992,
        240
      ]
    },
    {
      "id": "4d8bd2f6-f05e-4de5-8111-184cc985217a",
      "name": "Store Tokens in Vault",
      "type": "n8n-nodes-base.postgres",
      "position": [
        -800,
        240
      ]
    },
    {
      "id": "7811a902-0f0d-40a2-81c8-351d768f0ed1",
      "name": "Generate Masked Text",
      "type": "n8n-nodes-base.code",
      "position": [
        -560,
        240
      ]
    },
    {
      "id": "30e64592-f363-4ebe-9f37-2fd4d6a80218",
      "name": "AI Processing (Masked Data)",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        -160,
        0
      ]
    },
    {
      "id": "c7bf152b-79fe-417e-8d05-969ea2a47b6d",
      "name": "AI Processing Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatAnthropic",
      "position": [
        -192,
        160
      ]
    },
    {
      "id": "786dded9-24f5-47be-aece-b90469b04314",
      "name": "AI Output Parser",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        80,
        128
      ]
    },
    {
      "id": "6763634c-e71d-4f3b-8be2-b36d1210dd4c",
      "name": "Re-Injection Controller",
      "type": "n8n-nodes-base.code",
      "position": [
        320,
        80
      ]
    },
    {
      "id": "b07a8d69-9ff1-4b97-8a10-f682492b9a03",
      "name": "Retrieve Original Values",
      "type": "n8n-nodes-base.postgres",
      "position": [
        672,
        80
      ]
    },
    {
      "id": "ad95487c-c75a-4c60-bc59-113df00118d3",
      "name": "Restore Original PII",
      "type": "n8n-nodes-base.code",
      "position": [
        864,
        80
      ]
    },
    {
      "id": "b89c3f08-3277-4f3b-9089-1df0f2ee4edd",
      "name": "Store Audit Log",
      "type": "n8n-nodes-base.postgres",
      "position": [
        1296,
        80
      ]
    },
    {
      "id": "c0acedc8-c86d-495a-93f2-06b9d23e763c",
      "name": "Masking Success Check",
      "type": "n8n-nodes-base.if",
      "position": [
        -352,
        240
      ]
    },
    {
      "id": "92d0e6fd-5fc3-4514-9b7e-242d0f0744c1",
      "name": "Block AI Processing",
      "type": "n8n-nodes-base.set",
      "position": [
        -32,
        496
      ]
    },
    {
      "id": "6b5a1df1-c718-47be-9e90-f5cfd63438a7",
      "name": "Send Alert Notification",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        208,
        496
      ]
    },
    {
      "id": "522979b9-1913-4023-9b69-4b4e77485c09",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -3216,
        224
      ],
      "parameters": {
        "width": 512,
        "height": 528,
        "content": "## GDPR-Safe AI Document Processing\n\nThis workflow processes uploaded documents while protecting sensitive personal data. When a PDF is uploaded, OCR extracts the text and multiple detectors identify "
      }
    },
    {
      "id": "a7ff2577-87c2-4288-be8b-740f78424024",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1840,
        -16
      ],
      "parameters": {
        "width": 288,
        "height": 736,
        "content": "## PII Detection Layer\n\nMultiple detectors scan the document to identify sensitive information such as emails, phone numbers, ID numbers, and physical addresses."
      }
    },
    {
      "id": "0b397b8d-bdc0-49e7-8283-c24a4de572b0",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1008,
        48
      ],
      "parameters": {
        "width": 352,
        "height": 384,
        "content": "##Tokenization & Vault Storage\n\nEach detected PII value is replaced with a secure token such as:\n\n<<EMAIL_AB12>>\nThe original values are stored securely in a Postgres vault table."
      }
    },
    {
      "id": "b6fe8410-fcb8-4361-a6e7-7d05115523f6",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2000,
        736
      ],
      "parameters": {
        "width": 560,
        "height": 368,
        "content": "## Address Detection (AI) local ollama\n\nAn AI model analyzes the OCR text to detect physical addresses that are harder to capture with regex patterns."
      }
    },
    {
      "id": "cc20d7c8-66ed-497e-9e73-3c4cf902b5bb",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1504,
        96
      ],
      "parameters": {
        "width": 224,
        "height": 368,
        "content": "## Merge Detection Results\n\nAll detection outputs are merged into a single dataset."
      }
    },
    {
      "id": "078fd05b-a6ae-44e3-bbbb-938a61eb1722",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2640,
        272
      ],
      "parameters": {
        "width": 304,
        "height": 368,
        "content": "## Document Upload\n\nA webhook receives uploaded documents.\nThis entry point triggers the workflow and passes the file to the OCR step for text extraction."
      }
    },
    {
      "id": "4299741e-35d4-4fce-965d-e32f1ebcb859",
      "name": "Sticky Note8",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1264,
        48
      ],
      "parameters": {
        "width": null,
        "height": 400,
        "content": "## IResolve Overlapping Detections\n\nOverlapping or duplicate PII detections are resolved."
      }
    },
    {
      "id": "4c28716e-8aaf-4992-8c93-c8fbf7724cbb",
      "name": "Sticky Note9",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2192,
        272
      ],
      "parameters": {
        "width": 256,
        "height": 352,
        "content": "## OCR Text Extraction\n\nExtracts text from uploaded PDF files."
      }
    },
    {
      "id": "1cfdffc2-3008-4cb9-9377-94fe2785925f",
      "name": "Sticky Note10",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        272,
        -176
      ],
      "parameters": {
        "width": 336,
        "height": 416,
        "content": "## PII Re-Injection Controller\n\nAnalyzes AI output to determine whether specific tokens should be replaced with original values.\n\nRestoration follows defined permissions to control where sensitive dat"
      }
    },
    {
      "id": "4b48d393-fa34-4c81-9835-d0ad8631646c",
      "name": "Sticky Note11",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        640,
        -176
      ],
      "parameters": {
        "width": 432,
        "height": 416,
        "content": "## Restore Original Values\n\nOriginal PII values are retrieved from the vault and restored only in approved fields.\n\nThis ensures controlled access to sensitive data."
      }
    },
    {
      "id": "ab011bb0-977f-43e9-877e-fb15d63c59be",
      "name": "Sticky Note12",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -128,
        272
      ],
      "parameters": {
        "width": 496,
        "height": 432,
        "content": "## IMasking Safety Check\n\nBefore AI processing, the workflow verifies that masking was successful.\n\nIf masking fails, AI processing is blocked to prevent accidental exposure of sensitive information."
      }
    },
    {
      "id": "f80f3a53-98a9-413e-92fc-e62b0f87d78b",
      "name": "Sticky Note13",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -256,
        -176
      ],
      "parameters": {
        "width": 512,
        "height": 416,
        "content": "## AI Processing (Masked Data)\n\nThe masked document is sent to an AI model for analysis.\n\nSince sensitive data is replaced with tokens, the AI can safely summarize or extract structured information."
      }
    },
    {
      "id": "506c70db-8cd2-4478-ae6a-a6b15b77a941",
      "name": "Ollama Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOllama",
      "position": [
        -1904,
        992
      ]
    },
    {
      "id": "8e32d94c-dd17-4736-bc91-d8e78653d59e",
      "name": "Sticky Note14",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1200,
        -64
      ],
      "parameters": {
        "width": 368,
        "height": 304,
        "content": "## Compliance Audit Log\n\nAll detection, masking, AI access, and restoration events are recorded in a Postgres audit table.\n\nThis provides traceability and supports privacy compliance requirements."
      }
    }
  ],
  "connections": {
    "Email Detector": {
      "main": [
        [
          {
            "node": "Merge PII Detections",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Phone Detector": {
      "main": [
        [
          {
            "node": "Merge PII Detections",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "AI Output Parser": {
      "ai_outputParser": [
        [
          {
            "node": "AI Processing (Masked Data)",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "OCR Extract Text": {
      "main": [
        [
          {
            "node": "Email Detector",
            "type": "main",
            "index": 0
          },
          {
            "node": "Phone Detector",
            "type": "main",
            "index": 0
          },
          {
            "node": "ID Number Detector",
            "type": "main",
            "index": 0
          },
          {
            "node": "Address Detector AI",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Ollama Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Address Detector AI",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "ID Number Detector": {
      "main": [
        [
          {
            "node": "Merge PII Detections",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Processing Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Processing (Masked Data)",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Address Detector AI": {
      "main": [
        [
          {
            "node": "Merge PII Detections",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Block AI Processing": {
      "main": [
        [
          {
            "node": "Send Alert Notification",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Generate Masked Text": {
      "main": [
        [
          {
            "node": "Masking Success Check",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Merge PII Detections": {
      "main": [
        [
          {
            "node": "PII Consolidation & Conflict Resolver",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Restore Original PII": {
      "main": [
        [
          {
            "node": "Store Audit Log",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Address Output Parser": {
      "ai_outputParser": [
        [
          {
            "node": "Address Detector AI",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "Masking Success Check": {
      "main": [
        [
          {
            "node": "AI Processing (Masked Data)",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Block AI Processing",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Store Tokens in Vault": {
      "main": [
        [
          {
            "node": "Generate Masked Text",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Workflow Configuration": {
      "main": [
        [
          {
            "node": "OCR Extract Text",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Document Upload Webhook": {
      "main": [
        [
          {
            "node": "Workflow Configuration",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Re-Injection Controller": {
      "main": [
        [
          {
            "node": "Retrieve Original Values",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Retrieve Original Values": {
      "main": [
        [
          {
            "node": "Restore Original PII",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Processing (Masked Data)": {
      "main": [
        [
          {
            "node": "Re-Injection Controller",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Tokenization & Vault Storage": {
      "main": [
        [
          {
            "node": "Store Tokens in Vault",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "PII Consolidation & Conflict Resolver": {
      "main": [
        [
          {
            "node": "Tokenization & Vault Storage",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}