# securisec/chepy architecture

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

- Interactive diagram: https://gitdiagram.com/securisec/chepy
- Repository: https://github.com/securisec/chepy

## Overview

##### Project type and purpose
- Chepy is an open‐source Python library plus a CLI tool that mimics CyberChef’s data‐transformation “stacking” capabilities.
- Its purpose is to provide a pipeline‐based engine in pure Python, letting users load files or strings, apply a chain of modules (encoding, hashing, parsing, etc.), and emit results.

##### File structure
- Top‐level:
- cli.py – CLI entrypoint
- chepy/ – core package
– config.py – configuration loader
– core.py – pipeline orchestrator
– modules/ – built‐in operations (e.g., aritmeticlogic, compression, hashing)
– extras/ – additional utility recipes (e.g., bruteforce, crypto extras)
– chepy_plugins/ – extension folder for third‐party plugins
- tests/ & tests_plugins/ – unit and plugin tests
- docs/ – documentation sources
- Dockerfile, Makefile, setup.py, requirements.txt – build & deployment

##### README for additional insights
- Confirms a “stacking” pipeline pattern.
- Highlights plugin extensibility, CLI with autocompletion, pure‐Python speed, and optional standalone binary via PyInstaller.

##### Main components & their relationships
a. CLI layer (cli.py)
- Parses user arguments, autocompletes commands
- Invokes the Core Engine with an initial Chepy object (file path or input string)
b. Core Engine (chepy/core.py)
- Loads config (chepy/config.py), discovers built‐in modules and plugins
- Maintains a pipeline (chain of operations)
- Exposes fluent API (.load_file(), .reverse(), .rot_13(), …)
c. Module Library (chepy/modules/)
- Each module implements a single transformation
- Modules follow a consistent interface so the pipeline can invoke them generically
d. Extras Library (chepy/extras/)
- Higher‐level recipes or utilities that combine modules or provide specialized functionality
e. Plugin Manager (chepy/chepy_plugins/)
- Dynamically loads external plugin packages at startup
- Extends both the CLI and the core pipeline
f. Configuration subsystem (config.py)
- Reads default settings, plugin paths, user‐overrides
g. I/O and External Services
- File loader/saver modules (in core/modules)
- Networking modules support HTTP/S operations
h. Packaging & Deployment
- setup.py / setup.cfg for PyPI installation
- Dockerfile and Makefile for containerized builds
- PyInstaller for standalone binary

##### Architectural patterns & design principles
- Pipeline / Chain of Responsibility: each operation is a node in a linear chain.
- Plugin/Extension pattern: core package discovers and registers modules and extras as commands.
- Separation of concerns: CLI vs engine vs modules vs config vs plugins.
- Pure‐Python, single‐process, in‐memory transformation flow.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% User & CLI Layer
    subgraph "User & CLI"
        User["User Input"]:::external
        CLI["CLI Parser (cli.py)"]:::internal
        Main["CLI Entrypoint (__main__.py)"]:::internal
    end

    %% Engine Layer
    subgraph "Engine"
        Core["Core Engine"]:::internal
        Config(("Configuration")):::external
        Pipeline["Pipeline Manager"]:::internal
    end

    %% Module Library
    subgraph "Module Library"
        Arit["aritmeticlogic.py"]:::internal
        Comp["compression.py"]:::internal
        Hash["hashing.py"]:::internal
        DataFmt["dataformat.py"]:::internal
        NetMod["networking.py"]:::internal
    end

    %% Internal Module Support
    subgraph "Internal Module Support"
        IM_CLI["cli.py"]:::internal
        Helpers["helpers.py"]:::internal
        Const["constants.py"]:::internal
        Colors["colors.py"]:::internal
    end

    %% Extras Library
    subgraph "Extras Library"
        Bruteforce["bruteforce.py"]:::internal
        Characters["characters.py"]:::internal
        Combinatons["combinatons.py"]:::internal
        Crypto["crypto.py"]:::internal
        Misc["misc.py"]:::internal
    end

    %% Plugin Manager
    subgraph "Extensions"
        Plugins["Plugin Manager"]:::plugin
    end

    %% Packaging & Deployment
    subgraph "Packaging & Deployment"
        SetupPy["setup.py"]:::external
        SetupCfg["setup.cfg"]:::external
        Dockerfile["Dockerfile"]:::external
        Makefile["Makefile"]:::external
        Req["requirements.txt"]:::external
        Manifest["MANIFEST.in"]:::external
        Readthedocs[".readthedocs.yml"]:::external
    end

    %% Data Flow
    User -->|"args"| CLI
    CLI -->|"invoke"| Main
    Main -->|"initialize"| Core
    Core -->|"reads"| Config
    Core -->|"manages"| Pipeline
    Pipeline -->|"executes"| Arit
    Pipeline -->|"executes"| Comp
    Pipeline -->|"executes"| Hash
    Pipeline -->|"executes"| DataFmt
    Pipeline -->|"executes"| NetMod
    Arit -->|"uses"| IM_CLI
    Comp -->|"uses"| Helpers
    Hash -->|"uses"| Const
    DataFmt -->|"uses"| Colors
    Pipeline -->|"executes"| Bruteforce
    Pipeline -->|"executes"| Characters
    Pipeline -->|"executes"| Combinatons
    Pipeline -->|"executes"| Crypto
    Pipeline -->|"executes"| Misc
    Core -.->|"discovers"| Plugins
    Core -->|"bundled modules"| Arit
    Core -->|"bundled modules"| Comp
    Core -->|"bundled modules"| Hash
    Core -->|"bundled modules"| DataFmt
    Core -->|"bundled modules"| NetMod

    %% Packaging arrows
    Core -->|"packaged by"| SetupPy
    Core -->|"packaged by"| SetupCfg
    Core -->|"container build"| Dockerfile
    Core -->|"container build"| Makefile
    Core -->|"deps"| Req
    Core -->|"manifest"| Manifest
    Core -->|"docs config"| Readthedocs

    %% Click Events
    click CLI "https://github.com/securisec/chepy/blob/master/cli.py"
    click Main "https://github.com/securisec/chepy/blob/master/chepy/__main__.py"
    click Core "https://github.com/securisec/chepy/blob/master/chepy/core.py"
    click Config "https://github.com/securisec/chepy/blob/master/chepy/config.py"
    click Arit "https://github.com/securisec/chepy/blob/master/chepy/modules/aritmeticlogic.py"
    click Comp "https://github.com/securisec/chepy/blob/master/chepy/modules/compression.py"
    click Hash "https://github.com/securisec/chepy/blob/master/chepy/modules/hashing.py"
    click DataFmt "https://github.com/securisec/chepy/blob/master/chepy/modules/dataformat.py"
    click NetMod "https://github.com/securisec/chepy/blob/master/chepy/modules/networking.py"
    click IM_CLI "https://github.com/securisec/chepy/blob/master/chepy/modules/internal/cli.py"
    click Helpers "https://github.com/securisec/chepy/blob/master/chepy/modules/internal/helpers.py"
    click Const "https://github.com/securisec/chepy/blob/master/chepy/modules/internal/constants.py"
    click Colors "https://github.com/securisec/chepy/blob/master/chepy/modules/internal/colors.py"
    click Bruteforce "https://github.com/securisec/chepy/blob/master/chepy/extras/bruteforce.py"
    click Characters "https://github.com/securisec/chepy/blob/master/chepy/extras/characters.py"
    click Combinatons "https://github.com/securisec/chepy/blob/master/chepy/extras/combinatons.py"
    click Crypto "https://github.com/securisec/chepy/blob/master/chepy/extras/crypto.py"
    click Misc "https://github.com/securisec/chepy/blob/master/chepy/extras/misc.py"
    click Plugins "https://github.com/securisec/chepy/tree/master/chepy/chepy_plugins/"
    click SetupPy "https://github.com/securisec/chepy/blob/master/setup.py"
    click SetupCfg "https://github.com/securisec/chepy/blob/master/setup.cfg"
    click Dockerfile "https://github.com/securisec/chepy/tree/master/Dockerfile"
    click Makefile "https://github.com/securisec/chepy/tree/master/Makefile"
    click Req "https://github.com/securisec/chepy/blob/master/requirements.txt"
    click Manifest "https://github.com/securisec/chepy/blob/master/MANIFEST.in"
    click Readthedocs "https://github.com/securisec/chepy/blob/master/.readthedocs.yml"

    %% Styles
    classDef internal fill:#C6DBEF,stroke:#2B56C6,color:#000
    classDef plugin fill:#D3E4CD,stroke:#2E7D32,color:#000
    classDef external fill:#FDE0DC,stroke:#C62828,color:#000
```
