n8n Workflow System

flowchart TD
    %% =====================
    %% Entry & Data Ingest
    %% =====================
    START[Pentest Start]

    CRAWL["Crawling<br/>(Web Application)"]
    SCAN["Scanning<br/>(Network / Infra)"]

    SRC["Source Code Processor<br/>(Subworkflow)"]

    VDB[(Vector Database<br/>Per-Pentest Context)]

    START -->|Webapp target| CRAWL
    START -->|Network target| SCAN

    %% Crawling OR Scanning → Source Code Processor → Vector DB
    CRAWL --> SRC
    SCAN --> SRC
    SRC --> VDB

    %% =====================
    %% Planner Phase
    %% =====================
    P1[Planner<br/><br/>
    1. Review Phase Report from Supervisor<br/>
    2. Determine next phase<br/>
    3. Plan steps for phase<br/>
    4. Match agents to steps<br/>
    5. Output Phase Plan]

    VDB --> P1

    %% =====================
    %% Supervisor Phase
    %% =====================
    S1[Supervisor<br/><br/>
    1. Receive Phase Plan from Planner<br/>
    2. Execute steps one by one<br/>
    3. Call agents with goal + depth<br/>
    4. Follow leads when warranted<br/>
    5. Track progress + context]

    P1 -->|Phase Plan| S1

    %% =====================
    %% Agent Core
    %% =====================
    A1[Agent<br/><br/>
    1. Receive goal, depth, targets, context<br/>
    2. Execute methodology up to depth<br/>
    3. Stop when goal achieved<br/>
    4. Report vulns as found<br/>
    5. Return structured findings + leads]

    S1 -->|Call Agent| A1

    %% =====================
    %% Agent Subworkflows
    %% =====================
    BATCH["Pentest Batch Executor<br/>(Subworkflow)"]
    HITL[Human in the Loop]

    REPORT["Report Vulnerability<br/>(Subworkflow)"]

    CVE["CVE Agent<br/>(Lookup CVE Databases)"]

    SUM["Summarizer<br/>(Subworkflow)"]
    MD[(Execution Summary<br/>Markdown Store)]

    %% Batch execution + HITL
    A1 -->|Execute tools| BATCH
    BATCH -->|If enabled| HITL
    HITL --> BATCH
    BATCH --> A1

    %% Vulnerability reporting + validation
    A1 -->|Report finding| REPORT
    REPORT -->|Validate finding| BATCH
    REPORT --> A1

    %% CVE lookup
    A1 -->|Service / version| CVE
    CVE --> A1

    %% Summarization
    A1 -->|End of agent execution| SUM
    SUM --> MD

    %% =====================
    %% Supervisor → Planner Loop
    %% =====================
    S2["Supervisor (Phase Complete)"<br/><br/>
    1. All steps executed<br/>
    2. Compile Phase Report<br/>
    3. Send to Planner]

    A1 -->|Agent completion| S2

    S2 -->|Phase Report| P1

    %% =====================
    %% Completion
    %% =====================
    END[Engagement Complete]
    P1 -->|"Done" signal| END