{
  "name": "Generate production database schemas from Excel and CSV with OpenAI and LangChain",
  "nodes": [
    {
      "id": "9b4e0000-40d0-41b2-add6-a781e4ad10f0",
      "name": "File Upload Webhook",
      "type": "n8n-nodes-base.webhook",
      "position": [
        -2480,
        64
      ]
    },
    {
      "id": "6eed8414-4724-44b4-bcfe-bae6a3664880",
      "name": "Workflow Configuration",
      "type": "n8n-nodes-base.set",
      "position": [
        -2224,
        64
      ]
    },
    {
      "id": "4d95d201-0631-4e5b-9cfd-5b109ade4a19",
      "name": "Check File Type",
      "type": "n8n-nodes-base.if",
      "position": [
        -1904,
        64
      ]
    },
    {
      "id": "df4bbefc-a934-41be-a397-e3549a9616e5",
      "name": "Extract Excel Data",
      "type": "n8n-nodes-base.extractFromFile",
      "position": [
        -1680,
        -16
      ]
    },
    {
      "id": "dc7d4633-54af-4f1a-9813-f02f63336d78",
      "name": "Extract CSV Data",
      "type": "n8n-nodes-base.extractFromFile",
      "position": [
        -1680,
        192
      ]
    },
    {
      "id": "dc93fd9e-bf72-4bc4-bdcc-740ca9adf65f",
      "name": "Merge Extracted Data",
      "type": "n8n-nodes-base.merge",
      "position": [
        -1456,
        64
      ]
    },
    {
      "id": "62fa98bb-0c4f-4edf-a48c-b1e9f1c3a6cf",
      "name": "Compute File Hash & Profile Data",
      "type": "n8n-nodes-base.code",
      "position": [
        -1168,
        64
      ]
    },
    {
      "id": "24d0205d-e64f-4f35-b96a-ba46828840e1",
      "name": "Column Profiling Engine",
      "type": "n8n-nodes-base.code",
      "position": [
        -1008,
        64
      ]
    },
    {
      "id": "c8f729ae-0c03-43df-b1bc-5c9513fc8929",
      "name": "Schema Reasoning Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        -768,
        64
      ]
    },
    {
      "id": "baa3d410-b8c9-453c-851c-ed3500a80c29",
      "name": "Schema Output Parser",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        -608,
        240
      ]
    },
    {
      "id": "d8d13598-9cbc-48c6-abc1-72205dd4cebf",
      "name": "Rules Validation Layer",
      "type": "n8n-nodes-base.code",
      "position": [
        -416,
        64
      ]
    },
    {
      "id": "629a370a-55e4-4375-b5e2-034f4ee0d722",
      "name": "Check Validation Result",
      "type": "n8n-nodes-base.if",
      "position": [
        -160,
        64
      ]
    },
    {
      "id": "95cf0cff-2f8c-4862-bef9-1bf490168cfd",
      "name": "Prepare Revision Feedback",
      "type": "n8n-nodes-base.set",
      "position": [
        -352,
        592
      ]
    },
    {
      "id": "c017017b-6acd-45a3-bdb5-3f7fe5f391db",
      "name": "Generate SQL DDL",
      "type": "n8n-nodes-base.code",
      "position": [
        128,
        112
      ]
    },
    {
      "id": "400d66c3-f4e1-45e0-bec9-640d20726fe5",
      "name": "Generate ERD & Data Dictionary",
      "type": "n8n-nodes-base.code",
      "position": [
        128,
        304
      ]
    },
    {
      "id": "c3b15664-431b-4894-8e1e-a57f31574f05",
      "name": "Generate Load Plan",
      "type": "n8n-nodes-base.code",
      "position": [
        112,
        576
      ]
    },
    {
      "id": "0675b44d-f19a-402d-92bb-efdcb4554248",
      "name": "Combine Final Outputs",
      "type": "n8n-nodes-base.merge",
      "position": [
        400,
        192
      ]
    },
    {
      "id": "73a2eec7-43a2-4ee1-bf31-13798a6d49ce",
      "name": "Explanation Agent (Optional)",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        560,
        192
      ]
    },
    {
      "id": "2ecc3f41-3280-4e31-91e6-093e23cada12",
      "name": "Return Schema Results",
      "type": "n8n-nodes-base.respondToWebhook",
      "position": [
        1056,
        192
      ]
    },
    {
      "id": "7f02b7c5-1bc0-47bf-8379-17f4a516cf8a",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -3040,
        -144
      ],
      "parameters": {
        "width": 384,
        "height": 480,
        "content": "## AI Data Schema Generator\n\n## How it works\nThis workflow accepts CSV/XLSX files via webhook, extracts and cleans the data, and performs deep profiling to understand column types, relationships, and "
      }
    },
    {
      "id": "88092068-2f50-4df0-9a54-f5c4fd94f5a1",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2576,
        -128
      ],
      "parameters": {
        "width": 550,
        "height": 400,
        "content": "## Input & Config\n\nHandles file upload and workflow settings.\n- Webhook receives file  \n- Config defines thresholds  \n- Prepares data for processing  "
      }
    },
    {
      "id": "4f1b9743-e9a1-4338-9255-4620127879a3",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1504,
        -144
      ],
      "parameters": {
        "width": 246,
        "height": 480,
        "content": "## merge\n extracted data is merged\n"
      }
    },
    {
      "id": "2e531cd3-96b8-415b-a9bc-775328463885",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        368,
        -16
      ],
      "parameters": {
        "width": 486,
        "height": 656,
        "content": "## Combine & Explain\n\nMerges outputs and adds insights.\n\n- Combines DDL, ERD, load plan  \n- Optional AI explanation  \n- Uses LLM for schema reasoning  "
      }
    },
    {
      "id": "ed3a0e20-bfcd-4c9b-94d9-625087fcadaf",
      "name": "Sticky Note6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2000,
        -144
      ],
      "parameters": {
        "width": 486,
        "height": 480,
        "content": "## File Extraction\n\nExtracts structured data from uploaded files.\n\n- Detects Excel vs CSV  \n- Parses rows into JSON  \n- Merges extracted outputs  "
      }
    },
    {
      "id": "76147c0f-c496-4748-aef0-e6ca54bfa292",
      "name": "Sticky Note7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1232,
        -144
      ],
      "parameters": {
        "width": 358,
        "height": 480,
        "content": "## Column Analysis Engine\n\nPerforms deep column-level profiling.\n- Detects types, nulls, uniqueness  \n- Identifies potential IDs  \n- Suggests foreign key candidates  "
      }
    },
    {
      "id": "aa68b698-0219-4ba8-bde1-3397e16b46b3",
      "name": "OpenAI GPT",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        -816,
        240
      ]
    },
    {
      "id": "db050ca1-3c69-4bb6-a960-c0655fb35067",
      "name": "Sticky Note8",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -464,
        -160
      ],
      "parameters": {
        "width": 470,
        "height": 384,
        "content": "## Validation Layer\n\nEnsures schema correctness.\n\n- Checks type accuracy  \n- Validates PK/FK rules  \n- Detects conflicts and errors  "
      }
    },
    {
      "id": "3036509c-933d-43fe-af21-288c1a7b4ef6",
      "name": "Sticky Note9",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -848,
        -144
      ],
      "parameters": {
        "width": 358,
        "height": 496,
        "content": "## AI Schema Generation\n\nAI designs database schema.\n- Normalizes table structure  \n- Assigns SQL types  \n- Defines PKs, FKs, constraints  "
      }
    },
    {
      "id": "7b046947-b4b2-4dff-871a-c212d11ffafe",
      "name": "Sticky Note11",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -560,
        432
      ],
      "parameters": {
        "width": 438,
        "height": 352,
        "content": "## Revision Handling\n\nImproves schema if validation fails.\n\n- Sends feedback to AI  \n- Tracks retry attempts  "
      }
    },
    {
      "id": "ae85bd8f-eea9-4c54-80ee-28e624cc3744",
      "name": "Sticky Note12",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        32,
        -144
      ],
      "parameters": {
        "width": 294,
        "height": 608,
        "content": "## Schema Output Generation\n\nGenerates core database outputs.\n\n- SQL DDL creation  \n- ERD + data dictionary  \n- Load plan generation  "
      }
    },
    {
      "id": "3bd311bf-f9a9-4d5d-b728-8ebfa7b65906",
      "name": "Sticky Note13",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        896,
        0
      ],
      "parameters": {
        "width": 358,
        "height": 416,
        "content": "## Response Output\n\nReturns final structured result.\n\n- Sends JSON response via webhook  \n- Includes all generated artifacts  \n- Adds metadata and timestamps  "
      }
    },
    {
      "id": "2191a217-3296-4f40-b159-2e35970d8942",
      "name": "Sticky Note14",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -32,
        480
      ],
      "parameters": {
        "width": 374,
        "height": 256,
        "content": "## Load Plan Engine\n\n- Calculates load sequence  "
      }
    },
    {
      "id": "8a8bb5cd-7ebb-4672-80a2-7a028c676f0c",
      "name": "OpenAI GPT-(Explanation)",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        608,
        496
      ]
    }
  ],
  "connections": {
    "OpenAI GPT": {
      "ai_languageModel": [
        [
          {
            "node": "Schema Reasoning Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Check File Type": {
      "main": [
        [
          {
            "node": "Extract Excel Data",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Extract CSV Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract CSV Data": {
      "main": [
        [
          {
            "node": "Merge Extracted Data",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Generate SQL DDL": {
      "main": [
        [
          {
            "node": "Combine Final Outputs",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract Excel Data": {
      "main": [
        [
          {
            "node": "Merge Extracted Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Generate Load Plan": {
      "main": [
        [
          {
            "node": "Return Schema Results",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "File Upload Webhook": {
      "main": [
        [
          {
            "node": "Workflow Configuration",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Merge Extracted Data": {
      "main": [
        [
          {
            "node": "Compute File Hash & Profile Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Schema Output Parser": {
      "ai_outputParser": [
        [
          {
            "node": "Schema Reasoning Agent",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "Combine Final Outputs": {
      "main": [
        [
          {
            "node": "Explanation Agent (Optional)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Rules Validation Layer": {
      "main": [
        [
          {
            "node": "Check Validation Result",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Schema Reasoning Agent": {
      "main": [
        [
          {
            "node": "Rules Validation Layer",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Workflow Configuration": {
      "main": [
        [
          {
            "node": "Check File Type",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check Validation Result": {
      "main": [
        [
          {
            "node": "Generate SQL DDL",
            "type": "main",
            "index": 0
          },
          {
            "node": "Generate ERD & Data Dictionary",
            "type": "main",
            "index": 0
          },
          {
            "node": "Generate Load Plan",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Prepare Revision Feedback",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Column Profiling Engine": {
      "main": [
        [
          {
            "node": "Schema Reasoning Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI GPT-(Explanation)": {
      "ai_languageModel": [
        [
          {
            "node": "Explanation Agent (Optional)",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Prepare Revision Feedback": {
      "main": [
        [
          {
            "node": "Schema Reasoning Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Explanation Agent (Optional)": {
      "main": [
        [
          {
            "node": "Return Schema Results",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Generate ERD & Data Dictionary": {
      "main": [
        [
          {
            "node": "Combine Final Outputs",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Compute File Hash & Profile Data": {
      "main": [
        [
          {
            "node": "Column Profiling Engine",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}