{
  "name": "Generate due diligence reports with LlamaIndex, Pinecone, and GPT-5-mini",
  "nodes": [
    {
      "id": "b3b60773-8f6e-4631-9e69-6862ed6e3009",
      "name": "Retrieve Parsed Content",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        896,
        -160
      ]
    },
    {
      "id": "32b46e46-2f09-4106-8a8a-4961ae42bcaf",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1264,
        -752
      ],
      "parameters": {
        "width": 1072,
        "height": 416,
        "content": "## Automated Due Diligence Report Generator\n\n### How it works\n1. Receive a POST webhook at /dd-ai with multipart due-diligence files; split files and create a unified deal ID.\n2. Check Pinecone for an"
      }
    },
    {
      "id": "3652d095-82b9-43e4-a55f-8d7e0c4eda13",
      "name": "Receive Upload Request",
      "type": "n8n-nodes-base.webhook",
      "position": [
        -1200,
        -160
      ]
    },
    {
      "id": "0f0e3174-43e8-4bd6-8059-be3953d584db",
      "name": "Split Uploaded Files + Build Deal ID",
      "type": "n8n-nodes-base.code",
      "position": [
        -976,
        -160
      ]
    },
    {
      "id": "e84d333f-dead-474c-800f-c8eae4d68326",
      "name": "Iterate Files for Parsing",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        -96,
        -144
      ]
    },
    {
      "id": "0b4c3de6-6724-4a96-ac2a-63796a83eb37",
      "name": "Get Pinecone Index Stats",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -736,
        -160
      ]
    },
    {
      "id": "6bf36498-9c1a-4ca6-a2bf-773d5555e432",
      "name": "Upsert Chunks to Pinecone",
      "type": "@n8n/n8n-nodes-langchain.vectorStorePinecone",
      "position": [
        1632,
        -160
      ]
    },
    {
      "id": "2fd24b26-f690-451e-b51a-9b4838ea8b89",
      "name": "Generate Embeddings (Ingest)",
      "type": "@n8n/n8n-nodes-langchain.embeddingsOpenAi",
      "position": [
        1584,
        -32
      ]
    },
    {
      "id": "548bda77-79c1-422b-940e-3674835784fd",
      "name": "Prepare Parsed Text Document",
      "type": "@n8n/n8n-nodes-langchain.documentDefaultDataLoader",
      "position": [
        1792,
        -32
      ]
    },
    {
      "id": "0ec9a189-cc57-492c-841f-affd1d44a2c2",
      "name": "Collect Ingested Deal IDs",
      "type": "n8n-nodes-base.aggregate",
      "position": [
        32,
        -576
      ]
    },
    {
      "id": "c5ee4aea-d116-4576-a4d3-903e84bd4d32",
      "name": "Prepare Analysis Context",
      "type": "n8n-nodes-base.code",
      "position": [
        272,
        -576
      ]
    },
    {
      "id": "91d65143-09f7-4911-8fd0-f7caf7fdaa4c",
      "name": "Run Due Diligence AI Analysis",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        512,
        -576
      ]
    },
    {
      "id": "7bf0b702-726b-4c79-99b1-9bb87ff82a88",
      "name": " OpenAI Chat Model (5-mini)",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        512,
        -432
      ]
    },
    {
      "id": "8a6592fe-8b2b-4f76-8027-38121ab2540c",
      "name": "Parse Structured Analysis JSON",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        1024,
        -464
      ]
    },
    {
      "id": "f43d2168-d066-4475-a9ed-3a782d53d9d5",
      "name": "Retrieve Context from Pinecone",
      "type": "@n8n/n8n-nodes-langchain.vectorStorePinecone",
      "position": [
        752,
        -464
      ]
    },
    {
      "id": "3f6e0076-4f85-417e-8f81-6d73d37012f7",
      "name": " Generate Embeddings (Retrieval)",
      "type": "@n8n/n8n-nodes-langchain.embeddingsOpenAi",
      "position": [
        656,
        -432
      ]
    },
    {
      "id": "e11c084d-36e6-4044-9de3-c318e6153131",
      "name": "Map Analysis to Report Fields",
      "type": "n8n-nodes-base.code",
      "position": [
        1168,
        -576
      ]
    },
    {
      "id": "baf80a35-7ac0-4ca2-ae29-378b5d71ed96",
      "name": "Render DD Report HTML",
      "type": "n8n-nodes-base.html",
      "position": [
        1472,
        -576
      ]
    },
    {
      "id": "ce064d94-2c3f-48b9-bfc6-e353f42f8cbb",
      "name": "Render PDF from HTML",
      "type": "n8n-nodes-puppeteer.puppeteer",
      "position": [
        1696,
        -576
      ]
    },
    {
      "id": "234bb525-e16f-429c-a5bc-39f749cfcfe8",
      "name": "Convert PDF Base64 to Binary File",
      "type": "n8n-nodes-base.convertToFile",
      "position": [
        1920,
        -576
      ]
    },
    {
      "id": "2f93d577-19ab-454a-ad8c-333eb8d18330",
      "name": "Upload Report PDF to S3",
      "type": "n8n-nodes-base.s3",
      "position": [
        2448,
        -576
      ]
    },
    {
      "id": "42dbc003-e2da-4005-bac0-745404990b40",
      "name": "Build Public Report URL",
      "type": "n8n-nodes-base.code",
      "position": [
        2672,
        -576
      ]
    },
    {
      "id": "b0d10349-c402-4adf-a06e-af5dcbc2645b",
      "name": " Merge Analysis + Report URL",
      "type": "n8n-nodes-base.merge",
      "position": [
        2944,
        -592
      ]
    },
    {
      "id": "909faa92-6fc8-4f00-8571-4630bd4de26d",
      "name": "Is Parsing Job Complete?",
      "type": "n8n-nodes-base.if",
      "position": [
        496,
        -144
      ]
    },
    {
      "id": "cc4c89d2-c586-48d1-a32f-b719e1f86beb",
      "name": "Upload File to LlamaParse",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        96,
        -144
      ]
    },
    {
      "id": "7341754f-86ea-4a5a-a967-880a711895c4",
      "name": "Check LlamaParse Job Status",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        304,
        -144
      ]
    },
    {
      "id": "d5164ab7-159b-48dd-8d3a-3b8fa28415a6",
      "name": "Wait 10s Before Recheck",
      "type": "n8n-nodes-base.wait",
      "position": [
        688,
        -128
      ]
    },
    {
      "id": "bcec3773-43fe-475f-b2a0-a60b3f1ec2e8",
      "name": "Return API Response",
      "type": "n8n-nodes-base.respondToWebhook",
      "position": [
        3200,
        -592
      ]
    },
    {
      "id": "7f640ee8-584f-4d97-b6af-e301070e309c",
      "name": "Normalize Parsed Text Payload",
      "type": "n8n-nodes-base.code",
      "position": [
        1136,
        -160
      ]
    },
    {
      "id": "118de47b-e23b-490c-a0e7-cfcea140255c",
      "name": " Check Deal Namespace Cache",
      "type": "n8n-nodes-base.code",
      "position": [
        -528,
        -160
      ]
    },
    {
      "id": "7a292f76-9126-4db2-8eed-6410ecf15e94",
      "name": "Cache Hit?",
      "type": "n8n-nodes-base.if",
      "position": [
        -352,
        -160
      ]
    },
    {
      "id": "1e26091a-1b9d-4f6a-ac36-fdd96a362351",
      "name": "Prepare S3 File Metadata",
      "type": "n8n-nodes-base.code",
      "position": [
        2256,
        -576
      ]
    },
    {
      "id": "bc94aed6-353b-4203-9cd8-f8c45ac858ca",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1264,
        -320
      ],
      "parameters": {
        "width": 448,
        "height": 336,
        "content": "## Intake & Request Normalization \nReceives multipart upload, parses filenames/binaries, and creates one normalized item per file with a shared dealId.\n"
      }
    },
    {
      "id": "cfeb2a7e-4863-4462-9de7-111907e8e31a",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -800,
        -320
      ],
      "parameters": {
        "width": 608,
        "height": 336,
        "content": "## Pinecone Cache Check\nChecks namespace stats in Pinecone to detect cache hit/miss and routes flow to direct analysis or document parsing.\n"
      }
    },
    {
      "id": "6e2eadb0-3f1b-4983-bd0d-18cfd9ade098",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -176,
        -272
      ],
      "parameters": {
        "width": 1536,
        "height": 432,
        "content": " ## Document Parsing Loop\nUploads each file for parsing, polls async status until complete, fetches markdown output, and normalizes parsed text payload."
      }
    },
    {
      "id": "5df3e070-5fe6-4b67-98fa-4766a68fb83b",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1376,
        -272
      ],
      "parameters": {
        "width": 672,
        "height": 432,
        "content": " ## Vector Ingestion \nConverts parsed content into documents, generates embeddings, upserts vectors into deal namespace, and aggregates ingestion results.\n"
      }
    },
    {
      "id": "866571b6-5fd2-455c-8712-6f084b38c8b3",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -176,
        -752
      ],
      "parameters": {
        "width": 1536,
        "height": 464,
        "content": "## AI Due Diligence Analysis\nBuilds analysis context, retrieves supporting evidence from Pinecone, runs LLM agent, and enforces structured JSON output."
      }
    },
    {
      "id": "b2be995c-d818-4986-8a82-e4e4a43e80de",
      "name": "Sticky Note6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1376,
        -752
      ],
      "parameters": {
        "width": 784,
        "height": 464,
        "content": "## Report Rendering (HTML to PDF)  \n Maps AI output to report fields, renders HTML template, generates PDF, and converts output to binary file."
      }
    },
    {
      "id": "6451d4ea-9229-4a6a-980b-b92204d2c02d",
      "name": "Sticky Note7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2176,
        -752
      ],
      "parameters": {
        "width": 1200,
        "height": 464,
        "content": "## Delivery & Webhook Response\nPrepares filename metadata, uploads PDF to S3, builds public URL, merges outputs, and returns final API response."
      }
    }
  ],
  "connections": {
    "Cache Hit?": {
      "main": [
        [
          {
            "node": "Prepare Analysis Context",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Iterate Files for Parsing",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Render PDF from HTML": {
      "main": [
        [
          {
            "node": "Convert PDF Base64 to Binary File",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Render DD Report HTML": {
      "main": [
        [
          {
            "node": "Render PDF from HTML",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Receive Upload Request": {
      "main": [
        [
          {
            "node": "Split Uploaded Files + Build Deal ID",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Build Public Report URL": {
      "main": [
        [
          {
            "node": " Merge Analysis + Report URL",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Retrieve Parsed Content": {
      "main": [
        [
          {
            "node": "Normalize Parsed Text Payload",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Upload Report PDF to S3": {
      "main": [
        [
          {
            "node": "Build Public Report URL",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait 10s Before Recheck": {
      "main": [
        [
          {
            "node": "Check LlamaParse Job Status",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Pinecone Index Stats": {
      "main": [
        [
          {
            "node": " Check Deal Namespace Cache",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Is Parsing Job Complete?": {
      "main": [
        [
          {
            "node": "Retrieve Parsed Content",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Wait 10s Before Recheck",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Prepare Analysis Context": {
      "main": [
        [
          {
            "node": "Run Due Diligence AI Analysis",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Prepare S3 File Metadata": {
      "main": [
        [
          {
            "node": "Upload Report PDF to S3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Collect Ingested Deal IDs": {
      "main": [
        [
          {
            "node": "Prepare Analysis Context",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Iterate Files for Parsing": {
      "main": [
        [
          {
            "node": "Collect Ingested Deal IDs",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Upload File to LlamaParse",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Upload File to LlamaParse": {
      "main": [
        [
          {
            "node": "Check LlamaParse Job Status",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Upsert Chunks to Pinecone": {
      "main": [
        [
          {
            "node": "Iterate Files for Parsing",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    " Check Deal Namespace Cache": {
      "main": [
        [
          {
            "node": "Cache Hit?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    " OpenAI Chat Model (5-mini)": {
      "ai_languageModel": [
        [
          {
            "node": "Run Due Diligence AI Analysis",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Check LlamaParse Job Status": {
      "main": [
        [
          {
            "node": "Is Parsing Job Complete?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    " Merge Analysis + Report URL": {
      "main": [
        [
          {
            "node": "Return API Response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Generate Embeddings (Ingest)": {
      "ai_embedding": [
        [
          {
            "node": "Upsert Chunks to Pinecone",
            "type": "ai_embedding",
            "index": 0
          }
        ]
      ]
    },
    "Prepare Parsed Text Document": {
      "ai_document": [
        [
          {
            "node": "Upsert Chunks to Pinecone",
            "type": "ai_document",
            "index": 0
          }
        ]
      ]
    },
    "Map Analysis to Report Fields": {
      "main": [
        [
          {
            "node": "Render DD Report HTML",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Normalize Parsed Text Payload": {
      "main": [
        [
          {
            "node": "Upsert Chunks to Pinecone",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Run Due Diligence AI Analysis": {
      "main": [
        [
          {
            "node": "Map Analysis to Report Fields",
            "type": "main",
            "index": 0
          },
          {
            "node": " Merge Analysis + Report URL",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Parse Structured Analysis JSON": {
      "ai_outputParser": [
        [
          {
            "node": "Run Due Diligence AI Analysis",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "Retrieve Context from Pinecone": {
      "ai_tool": [
        [
          {
            "node": "Run Due Diligence AI Analysis",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    " Generate Embeddings (Retrieval)": {
      "ai_embedding": [
        [
          {
            "node": "Retrieve Context from Pinecone",
            "type": "ai_embedding",
            "index": 0
          }
        ]
      ]
    },
    "Convert PDF Base64 to Binary File": {
      "main": [
        [
          {
            "node": "Prepare S3 File Metadata",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Split Uploaded Files + Build Deal ID": {
      "main": [
        [
          {
            "node": "Get Pinecone Index Stats",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}