{
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "nodes": [
    {
      "id": "111e7ffd-a227-419e-92d8-4674937d500b",
      "name": "Initialize Variables",
      "type": "n8n-nodes-base.set",
      "position": [
        -2800,
        640
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "init_iteration",
              "name": "iteration_count",
              "type": "number",
              "value": 0
            },
            {
              "id": "init_feedback",
              "name": "previous_feedback",
              "type": "string",
              "value": "="
            },
            {
              "id": "form_data",
              "name": "form_data",
              "type": "object",
              "value": "={{ $json }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "fdd03c42-f3a4-4f97-b92b-b485006597d5",
      "name": "Architect Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatAnthropic",
      "position": [
        -2448,
        864
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "claude-sonnet-4-5-20250929",
          "cachedResultName": "Claude Sonnet 4.5"
        },
        "options": {
          "topP": 0.9,
          "temperature": 0.3
        }
      },
      "credentials": {
        "anthropicApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "0fcd5225-a3e2-41ec-8a20-f91374943abb",
      "name": "Reviewer Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatAnthropic",
      "position": [
        -2032,
        800
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "claude-sonnet-4-5-20250929",
          "cachedResultName": "Claude Sonnet 4.5"
        },
        "options": {
          "topP": 0.85,
          "temperature": 0.1
        }
      },
      "credentials": {
        "anthropicApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "35e74634-e270-4bb5-9254-92cc9ae537e0",
      "name": "Optimizer Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatAnthropic",
      "position": [
        -1648,
        816
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "claude-sonnet-4-5-20250929",
          "cachedResultName": "Claude Sonnet 4.5"
        },
        "options": {
          "topP": 0.95,
          "temperature": 0.5
        }
      },
      "credentials": {
        "anthropicApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "5cf35188-cd26-4c03-a077-74c1b1e2a219",
      "name": "Agent 1: Database Architect",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        -2512,
        624
      ],
      "parameters": {
        "text": "=Database Requirements:\n- What they're building: {{ $json.form_data['What are you building?'] }}\n- Database Technology: {{ $json.form_data['Database Technology'] }}\n- Industry: {{ $json.form_data['Industry/Niche'] }}\n- Data to track: {{ $json.form_data['What data do you need to track?'] }}\n- Team size: {{ $json.form_data['Team Size'] }}\n- Expected scale: {{ $json.form_data['Expected Scale'] }}\n- Key workflows: {{ $json.form_data['Key Workflows'] }}\n- Integrations: {{ $json.form_data['Any integrations needed?'] }}\n- Special requirements: {{ $json.form_data['Special Requirements'] }}\n\n{{ $json.previous_feedback ? '\u26a0\ufe0f PREVIOUS DESIGN HAD ISSUES - ITERATION ' + ($json.iteration_count + 1) + '/3:\\n\\nPrevious Feedback:\\n' + $json.previous_feedback + '\\n\\nPlease redesign the schema addressing ALL the concerns mentioned above. Focus especially on CRITICAL and HIGH priority items.\\n\\n' : '' }}\n\nPlease design a complete {{ $json.form_data['Database Technology'] }} database schema for this use case. Output your design as structured JSON.",
        "options": {
          "systemMessage": "=You are a senior {{ $json.form_data['Database Technology'] }} database architect with 15+ years experience.\nYou design production-grade schemas that are scalable, normalized, and follow best practices. You consider performance, indexing, and future growth.\n\nOutput your design as structured JSON with:\n- tables: Array of table objects with:\n  - name: string\n  - columns: Array of {name, type, constraints, description}\n  - primary_key: string or array\n  - indexes: Array of {name, columns, type}\n  - foreign_keys: Array of {column, references_table, references_column}\n- enums: Array of {name, values}\n- extensions: Array of extension names needed\n- relationships: Description of how tables relate\n- reasoning: Explanation for key design decisions\n\nBe thorough and production-ready. Consider the scale and requirements carefully."
        },
        "promptType": "define"
      },
      "typeVersion": 2.2
    },
    {
      "id": "36347feb-c90a-4c6b-91de-05ce97d206c7",
      "name": "Agent 2: Schema Reviewer",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        -2112,
        624
      ],
      "parameters": {
        "text": "=Original Requirements:\n{{ JSON.stringify($('Initialize Variables').item.json.form_data, null, 2) }}\n\nProposed Schema from Agent 1:\n{{ $('Agent 1: Database Architect').item.json.output }}\n\nPlease conduct a thorough review of this database schema design. Check for issues in normalization, indexing, data types, constraints, performance, scalability, and security.\n\nOutput structured feedback with severity levels: CRITICAL, HIGH, MEDIUM, LOW",
        "options": {
          "systemMessage": "You are a {{ $('Initialize Variables').item.json.form_data['Database Technology'] }} code reviewer and database optimization expert.\nYour job is to find issues, enforce best practices, and ensure production-readiness.\n\nReview checklist:\n- Normalization (3NF minimum, appropriate denormalization)\n- Indexing strategy (missing indexes? over-indexing?)\n- Data types (appropriate choices for the database type)\n- Constraints (missing NOT NULL? need CHECK constraints?)\n- Performance (N+1 query risks? missing composite indexes?)\n- Scalability (will this work at 10x, 100x scale?)\n- Security (sensitive data? need encryption? row-level security?)\n- Missing common fields (created_at, updated_at, soft deletes)\n- Relationships properly defined\n\nOutput structured feedback in this format:\n\nCRITICAL Issues:\n- [Issue 1]\n- [Issue 2]\n\nHIGH Priority:\n- [Issue 1]\n\nMEDIUM Priority:\n- [Issue 1]\n\nLOW Priority / Suggestions:\n- [Issue 1]\n\nPositive Aspects:\n- [Good thing 1]\n\nBe thorough but fair. If the design is solid, say so."
        },
        "promptType": "define"
      },
      "typeVersion": 2.2
    },
    {
      "id": "2af46d4b-c82d-4caa-b035-00f031139901",
      "name": "Agent 3: Optimizer & Scorer",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        -1696,
        624
      ],
      "parameters": {
        "text": "=Original Requirements:\n{{ JSON.stringify($('Initialize Variables').item.json.form_data, null, 2) }}\n\nProposed Schema:\n{{ $('Agent 1: Database Architect').item.json.output }}\n\nReview Feedback:\n{{ $('Agent 2: Schema Reviewer').item.json.output }}\n\nPlease:\n1. Apply final polish and optimizations to the schema\n2. Add advanced features (materialized views, helper functions, useful views)\n3. Provide monitoring recommendations\n4. Create a comprehensive score card\n5. Generate implementation guidance\n\nScore each dimension 0-10 with justification. Be honest but constructive.",
        "options": {
          "systemMessage": "You are a {{ $('Initialize Variables').item.json.form_data['Database Technology'] }} performance optimizer and database strategist.\nApply final polish, add advanced features, and score the design holistically.\n\nAdd:\n- Performance optimizations (materialized views, covering indexes, partitioning if needed)\n- Developer experience improvements (useful views, helper functions)\n- Monitoring recommendations (what to track in production)\n- Migration strategy (how to deploy safely)\n- Backup and disaster recovery considerations\n\nCreate a comprehensive score card:\n\n\ud83d\udcca DATABASE ARCHITECTURE SCORE\n\nOverall Grade: [A+, A, A-, B+, B, B-, C+, C, C-, D, F] ([score]/100)\n\nDetailed Scores:\n\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\n\nSchema Design: [X]/10\n[Brief justification]\n\nPerformance: [X]/10\n[Brief justification]\n\nScalability: [X]/10\n[Brief justification]\n\nDeveloper Experience: [X]/10\n[Brief justification]\n\nProduction Readiness: [X]/10\n[Brief justification]\n\nSecurity: [X]/10\n[Brief justification]\n\n\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\n\n\ud83d\udcaa Key Strengths:\n\u2022 [Strength 1]\n\u2022 [Strength 2]\n\u2022 [Strength 3]\n\n\u26a0\ufe0f Recommended Improvements:\n\u2022 [Improvement 1]\n\u2022 [Improvement 2]\n\n\ud83d\ude80 Next Steps:\n1. [Step 1]\n2. [Step 2]\n3. [Step 3]\n\nScore fairly but be honest. Grade A/B means production-ready, C means needs work, D/F means major issues."
        },
        "promptType": "define"
      },
      "typeVersion": 2.2
    },
    {
      "id": "e996f5e3-2a0a-4074-8401-98678a9af716",
      "name": "Track Iteration",
      "type": "n8n-nodes-base.set",
      "position": [
        -1360,
        848
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "iteration",
              "name": "iteration_count",
              "type": "number",
              "value": "={{ $('Initialize Variables').item.json.iteration_count + 1 }}"
            },
            {
              "id": "feedback",
              "name": "previous_feedback",
              "type": "string",
              "value": "={{ $('Agent 3: Optimizer & Scorer').item.json.output }}"
            },
            {
              "id": "form_data_passthrough",
              "name": "form_data",
              "type": "object",
              "value": "={{ $('Initialize Variables').item.json.form_data }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "8bcad8e1-19ba-4272-9a79-df0ca6e78b9b",
      "name": "SQL Generator Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatAnthropic",
      "position": [
        -720,
        800
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "claude-sonnet-4-5-20250929",
          "cachedResultName": "Claude Sonnet 4.5"
        },
        "options": {
          "topP": 0.85,
          "temperature": 0.2
        }
      },
      "credentials": {
        "anthropicApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "8b4d9e93-09bf-44ae-8de5-867f8f863680",
      "name": "Agent 4: Generate SQL Script",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        -736,
        544
      ],
      "parameters": {
        "text": "=Database Technology: {{ $('Initialize Variables').item.json.form_data['Database Technology'] }}\n\nFinal Approved Schema:\n{{ $('Agent 1: Database Architect').item.json.output }}\n\nOptimizations and Enhancements:\n{{ $('Agent 3: Optimizer & Scorer').item.json.output }}\n\nPlease generate a complete, production-ready SQL migration script for {{ $('Initialize Variables').item.json.form_data['Database Technology'] }}.\n\nOutput ONLY the SQL script, no markdown formatting, no additional commentary.",
        "options": {
          "systemMessage": "=You are a {{ $('Initialize Variables').item.json.form_data['Database Technology'] }} SQL script generator.\n\nTake the database schema design and convert it into a complete, production-ready SQL migration script.\n\nYour output must:\n- Start with proper transaction handling (BEGIN; ... COMMIT;)\n- Include all necessary extensions (for PostgreSQL)\n- Create ENUMs before tables that use them\n- Create tables in correct dependency order (referenced tables first)\n- Add all indexes after table creation\n- Add all constraints and triggers\n- Include helpful comments explaining complex parts\n- Be idempotent where possible (IF NOT EXISTS clauses)\n- End with a commented-out rollback script\n\nFormat:\n-- ============================================\n-- Database Migration Script\n-- Generated: [timestamp]\n-- Database: {{ $('Initialize Variables').item.json.form_data['Database Technology'] }}\n-- ============================================\n\nBEGIN;\n\n[Your SQL here]\n\nCOMMIT;\n\n-- ============================================\n-- ROLLBACK SCRIPT (commented out)\n-- ============================================\n-- BEGIN;\n-- [DROP statements in reverse order]\n-- COMMIT;\n\nOutput ONLY the SQL script. No markdown code blocks, no explanations."
        },
        "promptType": "define"
      },
      "typeVersion": 2.2
    },
    {
      "id": "63b46e42-9b6a-41de-9451-79971b04139e",
      "name": "Success Response",
      "type": "n8n-nodes-base.set",
      "position": [
        352,
        432
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "status",
              "name": "execution_status",
              "type": "string",
              "value": "success"
            },
            {
              "id": "message",
              "name": "message",
              "type": "string",
              "value": "\u2705 Database created successfully!"
            },
            {
              "id": "sql_script",
              "name": "sql_script",
              "type": "string",
              "value": "={{ $('Agent 4: Generate SQL Script').item.json.output }}"
            },
            {
              "id": "schema_design",
              "name": "schema_design",
              "type": "string",
              "value": "={{ $('Agent 1: Database Architect').item.json.output }}"
            },
            {
              "id": "review_feedback",
              "name": "review_feedback",
              "type": "string",
              "value": "={{ $('Agent 2: Schema Reviewer').item.json.output }}"
            },
            {
              "id": "score_card",
              "name": "score_card",
              "type": "string",
              "value": "={{ $('Agent 3: Optimizer & Scorer').item.json.output }}"
            },
            {
              "id": "iterations",
              "name": "iterations_needed",
              "type": "number",
              "value": "={{ $('Initialize Variables').item.json.iteration_count }}"
            },
            {
              "id": "database_tech",
              "name": "database_technology",
              "type": "string",
              "value": "={{ $('Initialize Variables').item.json.form_data['Database Technology'] }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "32d22b08-b65c-46fc-bb9d-6c70c9248ab2",
      "name": "Error Response",
      "type": "n8n-nodes-base.set",
      "position": [
        352,
        656
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "status",
              "name": "execution_status",
              "type": "string",
              "value": "failed"
            },
            {
              "id": "message",
              "name": "message",
              "type": "string",
              "value": "\u26a0\ufe0f SQL script generated but execution failed. You can still use the script manually."
            },
            {
              "id": "error",
              "name": "sql_error",
              "type": "string",
              "value": "={{ $('Execute SQL in PostgreSQL').item.json.error }}"
            },
            {
              "id": "sql_script",
              "name": "sql_script",
              "type": "string",
              "value": "={{ $('Agent 4: Generate SQL Script').item.json.output }}"
            },
            {
              "id": "schema_design",
              "name": "schema_design",
              "type": "string",
              "value": "={{ $('Agent 1: Database Architect').item.json.output }}"
            },
            {
              "id": "review_feedback",
              "name": "review_feedback",
              "type": "string",
              "value": "={{ $('Agent 2: Schema Reviewer').item.json.output }}"
            },
            {
              "id": "score_card",
              "name": "score_card",
              "type": "string",
              "value": "={{ $('Agent 3: Optimizer & Scorer').item.json.output }}"
            },
            {
              "id": "iterations",
              "name": "iterations_needed",
              "type": "number",
              "value": "={{ $('Initialize Variables').item.json.iteration_count }}"
            },
            {
              "id": "database_tech",
              "name": "database_technology",
              "type": "string",
              "value": "={{ $('Initialize Variables').item.json.form_data['Database Technology'] }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "f568d255-cfe1-4e5a-a511-bdba7169c1c8",
      "name": "Max Iterations Reached",
      "type": "n8n-nodes-base.set",
      "position": [
        -944,
        720
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "max_iterations_msg",
              "name": "message",
              "type": "string",
              "value": "\u26a0\ufe0f Reached maximum iterations (3). Proceeding with best available design."
            },
            {
              "id": "passthrough_iteration",
              "name": "iteration_count",
              "type": "number",
              "value": "={{ $json.iteration_count }}"
            },
            {
              "id": "passthrough_form",
              "name": "form_data",
              "type": "object",
              "value": "={{ $json.form_data }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "8cb73c84-fd04-4f5c-a125-a905b723f83d",
      "name": "Is Score A or B?",
      "type": "n8n-nodes-base.if",
      "position": [
        -1296,
        576
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "fdbb64c0-d9c9-4568-8aec-2e7679ae846f",
              "operator": {
                "type": "string",
                "operation": "regex"
              },
              "leftValue": "={{ $json.output }}",
              "rightValue": "Overall Grade: [AB][+-]?"
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "420bdf51-d812-40a6-8dc2-3a2b7e5de425",
      "name": "Can Retry?",
      "type": "n8n-nodes-base.if",
      "position": [
        -1136,
        896
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "fdbb64c0-d9c9-4568-8aec-2e7679ae846f",
              "operator": {
                "type": "number",
                "operation": "lte"
              },
              "leftValue": "={{ $json.iteration_count }}",
              "rightValue": 3
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "daa05f0e-e96f-4772-8aa2-fd87decab67e",
      "name": "Form",
      "type": "n8n-nodes-base.form",
      "position": [
        640,
        560
      ],
      "parameters": {
        "options": {},
        "operation": "completion",
        "completionTitle": "SQL Creation Finished",
        "completionMessage": "={{ $json }}"
      },
      "typeVersion": 2.3
    },
    {
      "id": "f95d30af-f34c-4055-a6d9-4cd2d6a2b349",
      "name": "Execute SQL in PostgreSQL",
      "type": "n8n-nodes-base.postgres",
      "onError": "continueErrorOutput",
      "position": [
        32,
        544
      ],
      "parameters": {
        "query": "{{ $json.output }}",
        "options": {},
        "operation": "executeQuery"
      },
      "credentials": {
        "postgres": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.6
    },
    {
      "id": "2a1a9a5c-b10b-43e0-bbfc-a32592dcd374",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -3696,
        640
      ],
      "parameters": {
        "color": 7,
        "width": 528,
        "height": 256,
        "content": "## \ud83d\udcdd Form Intake\n**User fills database requirements**\n\n\u2699\ufe0f **Customization Options:**\n- Add more fields for specific industries\n- Add file upload for existing schema\n- Add budget field for pricing tiers\n- Collect company name for personalization\n\n\ud83d\udca1 **Tip:** The more detailed the input, the better the AI agents perform!"
      },
      "typeVersion": 1
    },
    {
      "id": "f2bc8cbd-9fb3-49ed-afcc-5c66cf514c41",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -3168,
        320
      ],
      "parameters": {
        "color": 4,
        "width": 352,
        "height": 240,
        "content": "## \ud83d\udd27 Setup Phase\n**Prepares data for agent pipeline**\n\n\u2699\ufe0f **Customization:**\n- Store user data in CRM here\n- Log to analytics (Mixpanel/Segment)\n- Add user identification/tracking\n\n\ud83c\udfaf **Purpose:** Enables retry loop with context"
      },
      "typeVersion": 1
    },
    {
      "id": "cad9ac20-ac3e-460f-840f-d7d454cab077",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2640,
        256
      ],
      "parameters": {
        "color": 7,
        "width": 352,
        "height": 320,
        "content": "## \ud83e\udd16 Agent 1: Architect\n**Creates initial schema design**\n\n\u2699\ufe0f **Model Config:**\n- Temp: 0.3 (creative but consistent)\n- Max tokens: 4000\n\n\ud83c\udfa8 **Customization:**\n- Switch to GPT-4 for cost savings\n- Increase temperature for creative solutions\n- Add industry-specific templates\n\n\ud83d\udcca **Expected time:** 30-45 seconds"
      },
      "typeVersion": 1
    },
    {
      "id": "1fd88b9e-b13d-4ae7-8280-c27941bb78f6",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2224,
        256
      ],
      "parameters": {
        "color": 7,
        "width": 336,
        "height": 320,
        "content": "## \ud83e\udd16 Agent 2: Reviewer\n**Quality control & validation**\n\n\u2699\ufe0f **Model Config:**\n- Temp: 0.1 (strict & analytical)\n- Max tokens: 3000\n\n\ud83c\udfa8 **Customization:**\n- Add compliance checks (GDPR, HIPAA)\n- Add industry-specific validations\n- Integrate with linting tools\n\n\u26a1 **Expected time:** 20-30 seconds"
      },
      "typeVersion": 1
    },
    {
      "id": "aa91d473-11a4-42fc-a99b-2d5f2fb0a5d6",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1808,
        256
      ],
      "parameters": {
        "color": 7,
        "width": 336,
        "height": 320,
        "content": "## \ud83e\udd16 Agent 3: Optimizer\n**Final polish & scoring**\n\n\u2699\ufe0f **Model Config:**\n- Temp: 0.5 (balanced creativity)\n- Max tokens: 3500\n\n\ud83c\udfa8 **Customization:**\n- Adjust scoring criteria\n- Add performance benchmarking\n- Custom grading rubrics per industry\n\n\ud83c\udfaf **Outputs:** Score card + enhancements"
      },
      "typeVersion": 1
    },
    {
      "id": "589e4e59-6771-48c5-bbd0-65a5a2037800",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1344,
        208
      ],
      "parameters": {
        "color": 7,
        "width": 432,
        "height": 336,
        "content": "## \ud83d\udd04 Quality Gate\n**Ensures high-quality output**\n\n\u2699\ufe0f **Current Logic:**\n- A/B grades \u2192 Proceed \u2705\n- C/D/F grades \u2192 Retry (max 3x)\n\n\ud83c\udfa8 **Customization:**\n- Change threshold (accept C+?)\n- Add manual approval step\n- Send low scores to human review\n- Adjust max retries (1-5)\n\n\ud83d\udcb0 **Trade-off:** More retries = higher cost but better quality"
      },
      "typeVersion": 1
    },
    {
      "id": "ddfe7f84-6dec-4d76-b1bb-e9b518d08fab",
      "name": "Sticky Note6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -960,
        1024
      ],
      "parameters": {
        "color": 7,
        "width": 368,
        "height": 304,
        "content": "## \ud83d\udd01 Retry Loop\n**Iterative improvement system**\n\n\u2699\ufe0f **Current:** Max 3 attempts\n\n\ud83c\udfa8 **Customization:**\n- Increase max retries for complex projects\n- Add different agents for retries\n- Implement escalation (retry with Opus)\n- Track retry metrics for optimization\n\n\ud83d\udcca **Insight:** Most designs pass in 1-2 iterations"
      },
      "typeVersion": 1
    },
    {
      "id": "c85e8f0d-105f-4311-931f-595806af11e1",
      "name": "Sticky Note7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -800,
        176
      ],
      "parameters": {
        "color": 7,
        "width": 368,
        "height": 336,
        "content": "## \ud83e\udd16 Agent 4: SQL Generator\n**Converts schema to executable SQL**\n\n\u2699\ufe0f **Model Config:**\n- Temp: 0.2 (precision critical)\n- Max tokens: 4000\n\n\ud83c\udfa8 **Customization:**\n- Add migration versioning (Flyway/Liquibase)\n- Generate ORM models (Prisma schema)\n- Add seed data generation\n- Support multiple SQL dialects\n\n\ud83d\udcbe **Output:** Production-ready SQL script"
      },
      "typeVersion": 1
    },
    {
      "id": "aa299285-26ea-41c1-8563-371280cb3ae1",
      "name": "Sticky Note8",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        160,
        48
      ],
      "parameters": {
        "color": 7,
        "width": 336,
        "height": 336,
        "content": "## \u2705 Execution Validation\n**Handles success & failures gracefully**\n\n\u2699\ufe0f **Current Behavior:**\n- Success \u2192 Full response\n- Failure \u2192 Script + error details\n\n\ud83c\udfa8 **Customization:**\n- Retry failed SQL automatically\n- Send errors to monitoring (Sentry)\n- Trigger webhook on success\n- Add rollback capability\n\n\ud83c\udfaf **User always gets usable output**"
      },
      "typeVersion": 1
    },
    {
      "id": "3a0fcc3f-d8fa-4ebb-8361-68b5fefc4998",
      "name": "Sticky Note9",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -3680,
        128
      ],
      "parameters": {
        "color": 6,
        "width": 480,
        "height": 480,
        "content": "## \ud83d\ude80 Workflow Overview\n**AI Database Architect - Multi-Agent System**\n\n\ud83d\udcca **Performance:**\n- Average time: 60-90 seconds\n- Success rate: ~85% first attempt\n- Cost per run: ~$0.15-0.30\n\n\ud83c\udfaf **Conversion Strategy:**\n1. Free: Blueprint + Score\n2. Paid: Implementation + 3 automations\n3. Enterprise: Full setup + optimization\n\n\ud83d\udcc8 **Optimization Ideas:**\n- A/B test agent prompts\n- Cache common patterns\n- Pre-built templates for industries\n- Parallel agent execution\n\n\ud83d\udca1 **Track:** Completion rate, avg score, retry count"
      },
      "typeVersion": 1
    },
    {
      "id": "efc60c80-5ed9-4f4e-bef4-1d59741b72e7",
      "name": "Sticky Note10",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -48,
        752
      ],
      "parameters": {
        "color": 7,
        "width": 256,
        "height": 176,
        "content": "## Query Execute\n\nIf you are using **PostgreSQL** this will automatically run the script on your database"
      },
      "typeVersion": 1
    },
    {
      "id": "017f5635-1592-4da2-ab23-d70c2df11d74",
      "name": "Form Submission",
      "type": "n8n-nodes-base.formTrigger",
      "position": [
        -3088,
        720
      ],
      "parameters": {
        "options": {},
        "formTitle": "AI Database Architect - By Evervise",
        "formFields": {
          "values": [
            {
              "fieldType": "textarea",
              "fieldLabel": "What are you building?",
              "placeholder": "e.g. CRM for real estate agents",
              "requiredField": true
            },
            {
              "fieldType": "dropdown",
              "fieldLabel": "Database Technology",
              "fieldOptions": {
                "values": [
                  {
                    "option": "PostgreSQL"
                  },
                  {
                    "option": "MySQL"
                  },
                  {
                    "option": "MSSQL"
                  },
                  {
                    "option": "MariaDB"
                  }
                ]
              },
              "requiredField": true
            },
            {
              "fieldLabel": "Industry/Niche",
              "placeholder": "e.g. Real Estate, SaaS, E-commerce",
              "requiredField": true
            },
            {
              "fieldType": "textarea",
              "fieldLabel": "What data do you need to track?",
              "placeholder": "e.g. contacts, deals, properties, interactions, documents"
            },
            {
              "fieldType": "number",
              "fieldLabel": "Team Size",
              "placeholder": "5"
            },
            {
              "fieldLabel": "Expected Scale",
              "placeholder": "e.g. 1000 records, 100k records, 1M+ records"
            },
            {
              "fieldType": "textarea",
              "fieldLabel": "Key Workflows",
              "placeholder": "e.g. lead comes in \u2192 assign to agent \u2192 track showings \u2192 close deal \u2192 commission calculation"
            },
            {
              "fieldLabel": "Any integrations needed?",
              "placeholder": "email, calendar, WhatsApp, Stripe, etc."
            },
            {
              "fieldType": "textarea",
              "fieldLabel": "Special Requirements",
              "placeholder": "multi-language, file uploads, complex relationships, audit logging, etc."
            },
            {
              "fieldType": "email",
              "fieldLabel": "Your Email",
              "placeholder": "your@email.com",
              "requiredField": true
            }
          ]
        },
        "formDescription": "Get a production-grade database schema designed and reviewed by 3 AI experts"
      },
      "typeVersion": 2.3
    },
    {
      "id": "54b07bcf-7c04-4064-a8f4-ed08eb8865e0",
      "name": "If User Is Using Excel",
      "type": "n8n-nodes-base.if",
      "position": [
        -400,
        560
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "3ba71a4a-01e0-4be3-bf2e-349fe5c6710c",
              "operator": {
                "type": "string",
                "operation": "contains"
              },
              "leftValue": "={{ $('Form Submission').item.json['Database Technology'].toLowerCase() }}",
              "rightValue": "postgres"
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "4bd49a49-fa81-42d1-b80d-192a99cbfaf3",
      "name": "Form End Without Execute",
      "type": "n8n-nodes-base.form",
      "position": [
        -80,
        1008
      ],
      "parameters": {
        "options": {},
        "operation": "completion",
        "completionTitle": "SQL Creation Finished",
        "completionMessage": "={{ $json }}"
      },
      "typeVersion": 2.3
    },
    {
      "id": "ce8db403-6f22-44e7-8e68-b773102ff7ab",
      "name": "Sticky Note19",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -3664,
        928
      ],
      "parameters": {
        "color": 6,
        "width": 448,
        "height": 272,
        "content": "## \ud83d\ude80 Built by Evervise\n\n**Automating the repetitive so you can focus on what matters**\n\n### Need Help?\n\ud83d\udce7 **Support**: mark.marin@evervise.com\n\ud83c\udf10 **Website**: [evervise.ai](https://evervise.ai)  \n\ud83d\udcac **Response Time**: Usually within 24 hours\n**License**: Customize freely for your needs\n\n*Questions about customization? We've been there. Reach out.*"
      },
      "typeVersion": 1
    }
  ],
  "connections": {
    "Can Retry?": {
      "main": [
        [
          {
            "node": "Agent 1: Database Architect",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Max Iterations Reached",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Error Response": {
      "main": [
        [
          {
            "node": "Form",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Reviewer Model": {
      "ai_languageModel": [
        [
          {
            "node": "Agent 2: Schema Reviewer",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Architect Model": {
      "ai_languageModel": [
        [
          {
            "node": "Agent 1: Database Architect",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Form Submission": {
      "main": [
        [
          {
            "node": "Initialize Variables",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Optimizer Model": {
      "ai_languageModel": [
        [
          {
            "node": "Agent 3: Optimizer & Scorer",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Track Iteration": {
      "main": [
        [
          {
            "node": "Can Retry?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Is Score A or B?": {
      "main": [
        [
          {
            "node": "Agent 4: Generate SQL Script",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Track Iteration",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Success Response": {
      "main": [
        [
          {
            "node": "Form",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "SQL Generator Model": {
      "ai_languageModel": [
        [
          {
            "node": "Agent 4: Generate SQL Script",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Initialize Variables": {
      "main": [
        [
          {
            "node": "Agent 1: Database Architect",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If User Is Using Excel": {
      "main": [
        [
          {
            "node": "Execute SQL in PostgreSQL",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Form End Without Execute",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Max Iterations Reached": {
      "main": [
        [
          {
            "node": "Agent 4: Generate SQL Script",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Agent 2: Schema Reviewer": {
      "main": [
        [
          {
            "node": "Agent 3: Optimizer & Scorer",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Execute SQL in PostgreSQL": {
      "main": [
        [
          {
            "node": "Success Response",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Error Response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Agent 1: Database Architect": {
      "main": [
        [
          {
            "node": "Agent 2: Schema Reviewer",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Agent 3: Optimizer & Scorer": {
      "main": [
        [
          {
            "node": "Is Score A or B?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Agent 4: Generate SQL Script": {
      "main": [
        [
          {
            "node": "If User Is Using Excel",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}