# prnig/pullei architecture

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

- Interactive diagram: https://gitdiagram.com/prnig/pullei
- Repository: https://github.com/prnig/pullei

## Overview

##### Project Type and Purpose
- Type: Command-line interface (CLI) utility written in Python
- Purpose:
– Connect to the GitHub API to fetch pull requests from projectdiscovery/nuclei-templates
– Filter out templates already present locally
– Download new templates into a “pullei” folder under ~/nuclei-templates (or a custom path)

##### File Structure
- Top-level files only:
– pullei.py (main script containing CLI parser, GitHub client, file-IO logic)
– README.md (usage & feature overview)
– LICENSE
- No subdirectories or microservices—this is a single-process, script-based tool

##### README for Architectural Clues
- The tool uses:
– argparse (for CLI flags: –cves-only, –github-token, etc.)
– GitHub REST API (60 unauthenticated calls/hour, token support for higher rate)
– Filesystem operations (creating directories, writing .yaml template files)

##### Main Components
a. CLI Parser Module (argparse)
b. GitHub API Client (requests or built-in HTTP library)
c. Template Filter Logic (identifies which PR files are new)
d. Local Filesystem Interface (folder creation, file writes)
e. Optional Authentication Layer (GitHub token)

##### Relationships and Data Flow
- User invokes `python3 pullei.py [flags]` → CLI Parser
- CLI Parser configures:
– GitHub token (if provided)
– Path to nuclei-templates
– Download directory
- GitHub API Client authenticates (optional) → queries PRs endpoint
- Template Filter examines each PR’s file list → compares to local folder contents
- Filtered templates are downloaded → Local Filesystem writes files into “pullei” folder
- Errors and progress messages returned back to CLI for user feedback

##### Architectural Patterns & Principles
- Single responsibility: separate parsing, API access, filtering, and file I/O into distinct functions or modules
- Layered design:
– Presentation layer (CLI)
– Service layer (GitHub HTTP client)
– Business logic (filtering new templates)
– Persistence (filesystem)
- Optional configuration injection via CLI flags

##### Technologies and Libraries
- Python 3.x standard library: argparse, os, pathlib, logging
- HTTP library (requests or urllib) for GitHub REST calls
- GitHub REST API v3 (PRs endpoint)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Main Entities
    User["User"]:::external

    %% External Service
    GitHubAPI["GitHub REST API"]:::external

    %% Documentation
    README["README.md"]:::docs
    LICENSE["LICENSE"]:::docs

    %% Core Script Boundary
    subgraph "pullei.py" 
        direction TB
        Parser["CLI Parser Module"]:::internal
        Auth["Authentication Layer"]:::internal
        Client["GitHub API Client"]:::internal
        Filter["Template Filter Logic"]:::internal
        FS["Local Filesystem Interface"]:::storage
    end

    %% Data Flow
    User -->|"invoke pullei.py with flags"| Parser
    Parser -->|"set token, path, flags"| Auth
    Auth -->|"authenticate requests"| Client
    Parser -->|"--cves-only, paths"| Filter
    Client -->|"GET /repos/projectdiscovery/nuclei-templates/pulls"| GitHubAPI
    GitHubAPI -->|"PR list JSON"| Client
    Client -->|"PR file list"| Filter
    Filter -->|"compare with existing files"| FS
    FS -->|"write .yaml files"| FS
    FS -->|"progress & errors"| User

    %% Documentation Links
    README -->|"usage & overview"| Parser
    LICENSE -->|"license info"| Parser

    %% Click Events
    click Parser "https://github.com/prnig/pullei/blob/main/pullei.py"
    click Auth "https://github.com/prnig/pullei/blob/main/pullei.py"
    click Client "https://github.com/prnig/pullei/blob/main/pullei.py"
    click Filter "https://github.com/prnig/pullei/blob/main/pullei.py"
    click FS "https://github.com/prnig/pullei/blob/main/pullei.py"
    click README "https://github.com/prnig/pullei/blob/main/README.md"
    click LICENSE "https://github.com/prnig/pullei/tree/main/LICENSE"

    %% Styles
    classDef external fill:#cce5ff,stroke:#3399ff,color:#003366;
    classDef internal fill:#d4edda,stroke:#28a745,color:#155724;
    classDef storage fill:#fff3cd,stroke:#ffc107,color:#856404;
    classDef docs fill:#e2e3e5,stroke:#6c757d,color:#383d41;
```
