{
  "name": "Generate photo-based construction cost estimates with GPT-4 Vision and DDC CWICR",
  "nodes": [
    {
      "id": "0f4cbe14-7ba4-46c5-81d2-6b1d4482efcc",
      "name": "Photo Upload Form",
      "type": "n8n-nodes-base.formTrigger",
      "position": [
        29104,
        400
      ]
    },
    {
      "id": "fae54f1a-9225-48c1-a755-83dca9f15033",
      "name": "Extract Input",
      "type": "n8n-nodes-base.code",
      "position": [
        29328,
        400
      ]
    },
    {
      "id": "d5b99499-be6d-4da7-a381-94cdf5e9f7d4",
      "name": "Configure Language",
      "type": "n8n-nodes-base.code",
      "position": [
        29552,
        400
      ]
    },
    {
      "id": "2ad831a9-2893-4a0c-992e-337eb4a4bc36",
      "name": "Has Photo?",
      "type": "n8n-nodes-base.if",
      "position": [
        29776,
        400
      ]
    },
    {
      "id": "97d8463c-6e3b-4b16-b44f-6147d7b17f91",
      "name": "Error No Photo",
      "type": "n8n-nodes-base.code",
      "position": [
        29984,
        560
      ]
    },
    {
      "id": "b9545c52-79e0-447f-bb2c-fe81fc38a6bf",
      "name": "STAGE 1 Vision Prompt",
      "type": "n8n-nodes-base.set",
      "position": [
        29984,
        384
      ]
    },
    {
      "id": "0fb1af6a-fa06-44e6-9181-2f0c3073f1f6",
      "name": "STAGE 1 Analyze Photo",
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "position": [
        30208,
        384
      ]
    },
    {
      "id": "7a62ea97-a203-4ce0-b693-90d385aa542c",
      "name": "GPT-4 Vision",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        30208,
        592
      ]
    },
    {
      "id": "f4168e15-aa61-4878-a583-79df493e8104",
      "name": "Parse STAGE 1",
      "type": "n8n-nodes-base.code",
      "position": [
        30480,
        384
      ]
    },
    {
      "id": "c733ceb2-3357-42b1-b585-0cf2f8d3f2d1",
      "name": "STAGE 4 Decompose Prompt",
      "type": "n8n-nodes-base.set",
      "position": [
        30656,
        384
      ]
    },
    {
      "id": "b7550960-96b9-400a-82cd-57fcae2813ec",
      "name": "STAGE 4 Decompose LLM",
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "position": [
        30880,
        384
      ]
    },
    {
      "id": "b973f4c7-7800-48ac-bd3f-f6a7f1e4d278",
      "name": "GPT-4 Decompose",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        30880,
        592
      ]
    },
    {
      "id": "ae0ff40d-08ce-4c80-8cdc-69d7a343b1a7",
      "name": "Parse STAGE 4",
      "type": "n8n-nodes-base.code",
      "position": [
        31168,
        384
      ]
    },
    {
      "id": "70e62b94-292e-4f2e-b3bc-ca607618d772",
      "name": "Prepare Works",
      "type": "n8n-nodes-base.code",
      "position": [
        31344,
        384
      ]
    },
    {
      "id": "10b9b98b-f782-499f-9c12-e254af13bd0a",
      "name": "Loop Works",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        31536,
        384
      ]
    },
    {
      "id": "79f735d7-6de7-4a05-88e7-12d08b2fd6df",
      "name": "Store Work Data",
      "type": "n8n-nodes-base.code",
      "position": [
        32016,
        592
      ]
    },
    {
      "id": "60873726-0ece-4e69-91dc-73c77ad796b2",
      "name": "Wait",
      "type": "n8n-nodes-base.wait",
      "position": [
        32160,
        592
      ]
    },
    {
      "id": "c5e35231-575a-4d53-95c4-ef2875363906",
      "name": "Restore Work Data",
      "type": "n8n-nodes-base.code",
      "position": [
        32304,
        592
      ]
    },
    {
      "id": "595e380e-4b57-4063-a594-fb89e010f81f",
      "name": "Vector Search",
      "type": "@n8n/n8n-nodes-langchain.vectorStoreQdrant",
      "position": [
        32464,
        592
      ]
    },
    {
      "id": "782d04ee-61c6-40a0-85bf-c5554533f3b5",
      "name": "Embeddings",
      "type": "@n8n/n8n-nodes-langchain.embeddingsOpenAi",
      "position": [
        32448,
        752
      ]
    },
    {
      "id": "e527cbd6-8841-4425-902a-ee4a28706c2f",
      "name": "STAGE 5 Parse & Score",
      "type": "n8n-nodes-base.code",
      "position": [
        32720,
        592
      ]
    },
    {
      "id": "577e8350-ff19-4b73-a53f-80605484a493",
      "name": "Accumulate",
      "type": "n8n-nodes-base.code",
      "position": [
        32864,
        592
      ]
    },
    {
      "id": "9b8dd6f9-e36b-4fc0-bac8-5a0857890e32",
      "name": "STAGE 7.5 Aggregate & Validate",
      "type": "n8n-nodes-base.code",
      "position": [
        31824,
        352
      ]
    },
    {
      "id": "d3fe33db-d2a6-4217-a976-10aeab400af9",
      "name": "STAGE 9 HTML Report",
      "type": "n8n-nodes-base.code",
      "position": [
        32240,
        352
      ]
    },
    {
      "id": "286a9e9b-d24d-49b1-aaf1-eaeea6fb079a",
      "name": "Final HTML Output",
      "type": "n8n-nodes-base.code",
      "position": [
        32448,
        352
      ]
    },
    {
      "id": "b32c35fe-7284-4c29-818b-c8fed8b42ee5",
      "name": "Validation Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        31696,
        48
      ],
      "parameters": {
        "width": 260,
        "height": 464,
        "content": "## ✅ STAGE 7.5: Validation\n\n**Checks performed:**\n1. Minimum 3 work items\n2. Found rate % > 50%\n3. Zero cost items < 30%\n4. Renovation has demolition\n\nGroups works by category:\n- PREPARATION\n- MAIN\n- "
      }
    },
    {
      "id": "fec19cc3-f61f-48bd-86a2-d919d0b36b3f",
      "name": "Pipeline Overview",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        28688,
        640
      ],
      "parameters": {
        "width": 328,
        "height": 240,
        "content": "## 📊 Pipeline Overview\n\n| Stage | Description |\n|-------|-------------|\n| 1 | Vision analyzes photo |\n| 4 | Decompose to works |\n| 5 | Vector search pricing |\n| 5.2 | Parse & Score results |\n| 7 | Cal"
      }
    },
    {
      "id": "3623a3d0-55cd-4741-bf4e-58b49c7e2bc2",
      "name": "Block 1 Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        29040,
        48
      ],
      "parameters": {
        "width": 1080,
        "height": 824,
        "content": "## Block 1: Photo Upload & Config\n\nThis block:\n- Receives photo from web form\n- Extracts language/region settings\n- Configures Vector DB collection\n- Validates photo presence\n\n**Supported formats:** J"
      }
    },
    {
      "id": "a8f67a11-ec59-401c-bf06-429aec72f28a",
      "name": "Block 2 Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        30144,
        48
      ],
      "parameters": {
        "width": 464,
        "height": 820,
        "content": "## Block 2: STAGE 1 - Vision Analysis\n\n### 🤖 AI Photo Analysis\n\nGPT-4 Vision analyzes photo:\n- Detects room type (bathroom, kitchen, etc.)\n- Identifies construction elements\n- Estimates dimensions fro"
      }
    },
    {
      "id": "fb2c4ced-db96-4bd2-9032-22ccd960fec4",
      "name": "Block 3 Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        30624,
        48
      ],
      "parameters": {
        "width": 656,
        "height": 816,
        "content": "## Block 3: STAGE 4 - Work Decomposition\n\n### 🤖 AI Decomposition\n\nDecomposes elements into construction works:\n- BATHROOM → waterproofing, tiling, plumbing\n- KITCHEN → cabinets, countertops, backsplas"
      }
    },
    {
      "id": "9db962cb-16a4-4368-961d-f00fb59edca9",
      "name": "Block 4 Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        31296,
        48
      ],
      "parameters": {
        "width": 380,
        "height": 816,
        "content": "## Block 4: STAGE 5 - Pricing Loop\n\nProcesses each work item:\n\n1. **Vector Search** - Find rates in Qdrant\n2. **Parse Results** - Extract costs & resources\n3. **Quality Scoring** - Rate match quality\n"
      }
    },
    {
      "id": "d34124bf-ae65-49e3-b801-4d80f553964d",
      "name": "Vector Search Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        32768,
        48
      ],
      "parameters": {
        "width": 276,
        "height": 176,
        "content": "### 🔍 Vector Search\n\nSearches DDC CWICR database:\n- 3072-dim embeddings\n- Top 5 matches per query\n- Multilingual support"
      }
    },
    {
      "id": "581a9ed1-67e0-4677-be4a-921a38abc68e",
      "name": "Parse Score Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        31696,
        528
      ],
      "parameters": {
        "width": 1356,
        "height": 336,
        "content": "### ⚡ STAGE 5.2 Parse & Score\n\n**FIXED:** Correct document extraction\n\nExtracts from Qdrant results:\n- Total cost from content\n- Rate code, name, unit\n- Resources (labor/material/machine)\n"
      }
    },
    {
      "id": "77b90b95-27a5-4703-90d7-7cc6364d559f",
      "name": "Block 6 Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        31968,
        48
      ],
      "parameters": {
        "width": 776,
        "height": 460,
        "content": "## Block 6: Report Generation\n\n### 📊 STAGE 9 HTML Report\n**Features:**\n- Professional design\n- Quality indicators (● ○)\n- Calculation formulas\n- Clickable rate links\n- Cost structure charts\n- Phase ti"
      }
    },
    {
      "id": "d260439b-2562-4319-b022-cc7954dacb71",
      "name": "AI Models Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        28688,
        48
      ],
      "parameters": {
        "width": 328,
        "height": 232,
        "content": "## 🧠 AI Models Used\n\n**GPT-4 Vision** — Photo analysis\n**GPT-4** — Work decomposition\n\nCan be replaced with:\n- Anthropic Claude 3.5\n- Google Gemini Pro\n- OpenRouter models"
      }
    },
    {
      "id": "6ddf3397-f636-42cd-aac2-ade61036c5e4",
      "name": "Qdrant Setup Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        32768,
        256
      ],
      "parameters": {
        "width": 272,
        "height": 248,
        "content": "### 📥 Vector Database Setup\n\nTo enable search:\n1. Install Qdrant (local or VPS)\n2. Add Qdrant credentials\n3. Upload DDC CWICR dataset\n4. Select collection for your language\n\nCollections available on ["
      }
    },
    {
      "id": "60030e9d-0323-425b-a99f-973e6ec0e077",
      "name": "Info1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        29040,
        -112
      ],
      "parameters": {
        "width": 560,
        "height": 144,
        "content": "# 📸 Photo Cost Estimate Pro v2\n\n## Multi-stage AI decomposition pipeline\n\n"
      }
    },
    {
      "id": "809715a7-2395-4fe1-a987-7e8df7c0cdb8",
      "name": "AI Models Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        28688,
        304
      ],
      "parameters": {
        "width": 328,
        "height": 312,
        "content": "### Pipeline:\n1. 📷 GPT-4 Vision → Elements\n2. 🔄 STAGE 4: Decompose → Works  \n3. 🔍 Vector Search DDC CWICR\n4. ✅ Validation Stage\n5. 📊 HTML Report\n\n### Regions (9):\n🇩🇪 Berlin | 🇬🇧 Toronto | 🇷🇺 St. Peter"
      }
    },
    {
      "id": "b4e01f61-6023-4851-b7ae-7d555c5059de",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        32368,
        -112
      ],
      "parameters": {
        "width": 356,
        "height": 132,
        "content": "⭐ **If you find our tools helpful**, please consider **starring our repository** on [GitHub](https://github.com/datadrivenconstruction/OpenConstructionEstimate-DDC-CWICR). \n\nYour support helps us impr"
      }
    }
  ],
  "connections": {
    "Wait": {
      "main": [
        [
          {
            "node": "Restore Work Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Accumulate": {
      "main": [
        [
          {
            "node": "Loop Works",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Embeddings": {
      "ai_embedding": [
        [
          {
            "node": "Vector Search",
            "type": "ai_embedding",
            "index": 0
          }
        ]
      ]
    },
    "Has Photo?": {
      "main": [
        [
          {
            "node": "STAGE 1 Vision Prompt",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Error No Photo",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop Works": {
      "main": [
        [
          {
            "node": "STAGE 7.5 Aggregate & Validate",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Store Work Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "GPT-4 Vision": {
      "ai_languageModel": [
        [
          {
            "node": "STAGE 1 Analyze Photo",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Extract Input": {
      "main": [
        [
          {
            "node": "Configure Language",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Parse STAGE 1": {
      "main": [
        [
          {
            "node": "STAGE 4 Decompose Prompt",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Parse STAGE 4": {
      "main": [
        [
          {
            "node": "Prepare Works",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Prepare Works": {
      "main": [
        [
          {
            "node": "Loop Works",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Vector Search": {
      "main": [
        [
          {
            "node": "STAGE 5 Parse & Score",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "GPT-4 Decompose": {
      "ai_languageModel": [
        [
          {
            "node": "STAGE 4 Decompose LLM",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Store Work Data": {
      "main": [
        [
          {
            "node": "Wait",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Photo Upload Form": {
      "main": [
        [
          {
            "node": "Extract Input",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Restore Work Data": {
      "main": [
        [
          {
            "node": "Vector Search",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Configure Language": {
      "main": [
        [
          {
            "node": "Has Photo?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "STAGE 9 HTML Report": {
      "main": [
        [
          {
            "node": "Final HTML Output",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "STAGE 1 Analyze Photo": {
      "main": [
        [
          {
            "node": "Parse STAGE 1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "STAGE 1 Vision Prompt": {
      "main": [
        [
          {
            "node": "STAGE 1 Analyze Photo",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "STAGE 4 Decompose LLM": {
      "main": [
        [
          {
            "node": "Parse STAGE 4",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "STAGE 5 Parse & Score": {
      "main": [
        [
          {
            "node": "Accumulate",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "STAGE 4 Decompose Prompt": {
      "main": [
        [
          {
            "node": "STAGE 4 Decompose LLM",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "STAGE 7.5 Aggregate & Validate": {
      "main": [
        [
          {
            "node": "STAGE 9 HTML Report",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}