# eastsword/xuanyuansword_ainuclei architecture

> Architecture diagram of the GitHub repository eastsword/xuanyuansword_ainuclei, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-21). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/eastsword/xuanyuansword_ainuclei
- Repository: https://github.com/eastsword/xuanyuansword_ainuclei

## Overview

##### Project type and purpose
- This is a developer tool (CLI pipeline) for collecting, generating, and running security proofs‐of‐concept (POCs) via GitHub and Deepseek, then scanning targets with Nuclei.
- Four Python scripts serve as sequential stages:
1. Download_POCs.py – fetches repositories/POC files from GitHub
2. POCGenerator.py – processes raw downloads into standardized POC definitions
3. Update_nuclei.py – injects or updates those POC definitions into your local Nuclei templates
4. Scan.py – launches Nuclei (external binary) against targets using the updated templates

##### File structure
- Top‐level Python scripts correspond to discrete pipeline stages.
- config.json holds API keys (Deepseek API, GitHub token) and pipeline parameters.
- nuclei_darwin_arm64 is the Nuclei binary (platform‑specific).
- nuclei_templates/ contains YAML template files (existing & newly generated).
- repo.csv is likely used to track downloaded repositories or metadata.
- No separate “src” or “lib” directories—each script is standalone but they share the same working directory and config.json.

##### Key insights from README
- User must swap out nuclei_darwin_arm64 for the correct binary for their OS.
- config.json must be populated with valid credentials.
- Step order is critical; step 4 (Download_POCs.py) can be optimized to avoid repeated full downloads.

##### Main components
a. CLI Orchestrator (could be a simple shell script or manual invocation)
b. Pipeline stages (four Python script components)
c. External Services
- GitHub API
- Deepseek API (for deep‑searching repositories/POCs)
d. External Binary
- Nuclei (nuclei_darwin_*)
e. Local Storage
- config.json (configuration data)
- repo.csv (downloaded repo metadata)
- nuclei_templates/ (YAML POC templates)
- Working directory (generated POC files)

##### Relationships and data flows
- The orchestrator triggers Download_POCs.py → calls GitHub API & Deepseek → writes raw POCs & metadata to repo.csv.
- POCGenerator.py reads repo.csv (and raw files), invokes logic to output standardized YAML POCs into nuclei_templates.
- Update_nuclei.py merges or copies new YAMLs from nuclei_templates into the main Nuclei template set.
- Scan.py calls the nuclei binary (nuclei_darwin_*) with the updated template directory against target URLs/hosts; outputs scan results.
- config.json is read by each script to access tokens and pipeline settings.

##### Architectural patterns & design principles
- Pipeline / batch‑processing pattern: clear, linear stages.
- Separation of concerns: each script does only one job.
- Externalize configuration: use config.json for secrets and thresholds.
- File‑based integration: scripts communicate by reading/writing files in a common directory.

##### Detail
- Component names, data stores, external service endpoints, and the scripts’ invocation order.
- Configuration dependencies and platform‑specific binary as separate nodes.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% External Services
    GitHubAPI["GitHub API"]:::external
    DeepseekAPI["Deepseek API"]:::external

    %% Configuration
    Config["config.json"]:::config

    %% Pipeline Scripts
    Download["Download_POCs.py"]:::script
    Generator["POCGenerator.py"]:::script
    Updater["Update_nuclei.py"]:::script
    Scanner["Scan.py"]:::script

    %% Storage and Templates
    RepoCSV["repo.csv"]:::storage
    subgraph "nuclei_templates"
        direction TB
        TemplatesDir["nuclei_templates/"]:::storage
        Template1["path-traversal-vite-project_20250418_003407.yaml"]:::storage
        Template2["path-traversal-vite-project_20250419_121618.yaml"]:::storage
    end

    %% External Binary
    NucleiBin["nuclei_darwin_arm64"]:::binary

    %% Documentation
    README["README.md"]:::doc

    %% Pipeline Flow
    GitHubAPI -->|fetch POCs| Download
    DeepseekAPI -->|search repos| Download
    Download -->|write metadata| RepoCSV
    RepoCSV -->|read metadata| Generator
    Generator -->|generate YAML| TemplatesDir
    TemplatesDir -->|new templates| Updater
    Updater -->|merge templates| NucleiBin
    Updater -->|update templates| TemplatesDir
    NucleiBin -->|invoked by| Scanner
    Scanner -->|run scans| NucleiBin
    NucleiBin -->|produce results| ScanResults["Scan Results"]:::doc

    %% Config dependencies
    Config -.-> Download
    Config -.-> Generator
    Config -.-> Updater
    Config -.-> Scanner

    %% Documentation link
    README -.-> Download
    README -.-> Scanner

    %% Click Events
    click Download "https://github.com/eastsword/xuanyuansword_ainuclei/blob/main/Download_POCs.py"
    click Generator "https://github.com/eastsword/xuanyuansword_ainuclei/blob/main/POCGenerator.py"
    click Updater "https://github.com/eastsword/xuanyuansword_ainuclei/blob/main/Update_nuclei.py"
    click Scanner "https://github.com/eastsword/xuanyuansword_ainuclei/blob/main/Scan.py"
    click Config "https://github.com/eastsword/xuanyuansword_ainuclei/blob/main/config.json"
    click NucleiBin "https://github.com/eastsword/xuanyuansword_ainuclei/tree/main/nuclei_darwin_arm64"
    click TemplatesDir "https://github.com/eastsword/xuanyuansword_ainuclei/tree/main/nuclei_templates/"
    click Template1 "https://github.com/eastsword/xuanyuansword_ainuclei/blob/main/nuclei_templates/path-traversal-vite-project_20250418_003407.yaml"
    click Template2 "https://github.com/eastsword/xuanyuansword_ainuclei/blob/main/nuclei_templates/path-traversal-vite-project_20250419_121618.yaml"
    click RepoCSV "https://github.com/eastsword/xuanyuansword_ainuclei/blob/main/repo.csv"
    click README "https://github.com/eastsword/xuanyuansword_ainuclei/blob/main/README.md"

    %% Styles
    classDef script fill:#cce5ff,stroke:#004085,color:#004085,stroke-width:2px;
    classDef storage fill:#d4edda,stroke:#155724,color:#155724,stroke-width:2px;
    classDef config fill:#fff3cd,stroke:#856404,color:#856404,stroke-width:2px,stroke-dasharray: 5 5;
    classDef external fill:#e2e3e5,stroke:#6c757d,color:#6c757d,stroke-width:2px,stroke-dasharray: 2 2;
    classDef binary fill:#f8d7da,stroke:#721c24,color:#721c24,stroke-width:2px;
    classDef doc fill:#f0f0f0,stroke:#333333,color:#333333,stroke-width:1px,stroke-dasharray: 2 2;

    %% Legend
    subgraph "Legend"
        direction TB
        L1["Python Scripts"]:::script
        L2["Storage"]:::storage
        L3["Configuration"]:::config
        L4["External Services"]:::external
        L5["Binary"]:::binary
        L6["Documents"]:::doc
    end
```
