# sakiir/fuzzy architecture

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

- Interactive diagram: https://gitdiagram.com/sakiir/fuzzy
- Repository: https://github.com/sakiir/fuzzy

## Overview

##### Project type and purpose
- This is a Python‐based command-line web fuzzer (“Fuzzy”) designed to drive HTTP requests against a target URL template using a wordlist. It is not a multi-service system, but rather a single executable tool built around an asynchronous worker‐pool pattern.

##### File structure
- Top‐level files:
- `fuzzy.py` – entry point wrapper invoking `fuzzy/__main__.py`
- `setup.py` & `requirements.txt` – packaging and dependencies (e.g., `aiohttp`, `click` or `argparse`)
- Package directory `fuzzy/`:
- `__main__.py` – module executed when `fuzzy` is run
- `cli.py` – command line parsing and option handling
- `request.py` – HTTP client layer using `aiohttp`
- `matching.py` & `utils.py` – response filtering and utility functions
- `printer.py` – formatted output to stdout
- `logging.py` – log abstraction
- Other artifacts:
- `images/` – documentation assets
- `.gitignore`

##### Key insights from README
- The fuzzer:
- Parses CLI args (`--url`, `--wordlist`, `--limit`, `--delay`, filter flags)
- Builds a task queue of URL requests with the fuzz tag replaced by each wordlist entry
- Spawns N asynchronous workers (default 1) that pick tasks from the queue, issue HTTP requests (via `aiohttp`), then pipe responses through matchers/filters and printers.
- Supports custom headers, proxies, safe‐mode delays, and HTTP response filtering.

a. **User / CLI Layer**
- Terminal → `fuzzy` command → `cli.py`
b. **Core Fuzzer Engine**
- Task Scheduler / Queue (in‐memory)
- Worker Pool (asyncio tasks in `request.py`)
c. **HTTP Client Layer**
- `aiohttp` session configured via `request.py`
d. **Processing Pipeline**
- Response filters (`matching.py`)
- Printers (`printer.py`)
- Logging (`logging.py`)
e. **External Systems**
- Wordlist file (filesystem)
- Target web server (HTTP endpoint)

##### Relationships and data flow
1. CLI parses arguments → constructs “task generator.”
2. Wordlist reader feeds URLs into the Task Queue.
3. Worker Pool asynchronously pulls tasks from the Queue.
4. Each worker issues an HTTP request to the Target via `aiohttp`.
5. Responses pass through Matching/Filtering → decide if to display.
6. Printer formats results → stdout; Logging publishes to log file or console as configured.

##### Architectural patterns and technologies
- **Asynchronous Worker‐Pool** (asyncio + task queue)
- **Modular CLI** (click/argparse in `cli.py`)
- **Layered Processing** (request → match → print → log)
- **Python Packaging** (`setup.py`, entry point via `__main__.py`)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% User / CLI Layer
    subgraph "User / CLI Layer"
        fuzzy_py["fuzzy.py"]:::internal
        main_py["fuzzy/__main__.py"]:::internal
        cli_py["fuzzy/cli.py"]:::internal
    end

    %% Core Fuzzer Engine
    subgraph "Core Fuzzer Engine"
        engine["fuzzy/fuzzy.py"]:::internal
        queue["Task Queue"]:::internal
        workers["Worker Pool"]:::internal
    end

    %% HTTP Client Layer
    subgraph "HTTP Client Layer"
        http_client["fuzzy/request.py"]:::library
        aiohttp["aiohttp"]:::thirdparty
    end

    %% Processing Pipeline
    subgraph "Processing Pipeline"
        matching["fuzzy/matching.py"]:::internal
        utils["fuzzy/utils.py"]:::internal
        printer["fuzzy/printer.py"]:::internal
        logger["fuzzy/logging.py"]:::internal
    end

    %% Packaging & Dependencies
    subgraph "Packaging & Dependencies"
        setup["setup.py"]:::internal
        reqs["requirements.txt"]:::internal
    end

    %% External Systems
    subgraph "External Systems"
        wordlist[(Wordlist File)]:::external
        web["Target Web Server"]:::external
    end

    %% Connections
    fuzzy_py --> main_py
    main_py --> cli_py
    cli_py --> engine
    wordlist --> queue
    queue --> workers
    workers --> http_client
    http_client --> aiohttp
    http_client --> web
    web --> http_client
    http_client --> matching
    matching --> printer
    matching --> logger
    utils --> engine

    %% Click Events
    click fuzzy_py "https://github.com/sakiir/fuzzy/blob/master/fuzzy.py"
    click main_py "https://github.com/sakiir/fuzzy/blob/master/fuzzy/__main__.py"
    click cli_py "https://github.com/sakiir/fuzzy/blob/master/fuzzy/cli.py"
    click engine "https://github.com/sakiir/fuzzy/blob/master/fuzzy/fuzzy.py"
    click http_client "https://github.com/sakiir/fuzzy/blob/master/fuzzy/request.py"
    click matching "https://github.com/sakiir/fuzzy/blob/master/fuzzy/matching.py"
    click utils "https://github.com/sakiir/fuzzy/blob/master/fuzzy/utils.py"
    click printer "https://github.com/sakiir/fuzzy/blob/master/fuzzy/printer.py"
    click logger "https://github.com/sakiir/fuzzy/blob/master/fuzzy/logging.py"
    click setup "https://github.com/sakiir/fuzzy/blob/master/setup.py"
    click reqs "https://github.com/sakiir/fuzzy/blob/master/requirements.txt"

    %% Styles
    classDef internal fill:#cce5ff,stroke:#333,stroke-width:1px
    classDef external fill:#d4edda,stroke:#333,stroke-width:1px
    classDef thirdparty fill:#fff3cd,stroke:#333,stroke-width:1px
    classDef library fill:#d1ecf1,stroke:#333,stroke-width:1px
```
