# vxfemboy/purrcrypt architecture

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

- Interactive diagram: https://gitdiagram.com/vxfemboy/purrcrypt
- Repository: https://github.com/vxfemboy/purrcrypt

## Overview

##### Main Components
- CLI Interface: Highlight the entry point (src/main.rs) that parses commands (genkey, encrypt, decrypt, import-key, list-keys, set-dialect) and directs them to the appropriate modules.
- Library/Business Logic: Represent the core logic inside src/lib.rs that manages the interplay between cryptographic functions and the “pet” encoding.
- Cryptography Module: Include src/crypto.rs, which handles the elliptic curve crypto algorithms, indicating that it’s responsible for the secure encryption/decryption processes.
- Cipher Module: Focus on the src/cipher/ directory (with mod.rs and patterns.rs) where the conversion of data to and from “cat speak” or “dog speak” (i.e., the “fluffy disguise”) is implemented.
- Key Management: Identify src/keys.rs and src/keystore.rs as responsible for key generation, storage, and retrieval. This component is critical in managing secure keys and ensuring that private keys are never leaked.
- Configuration & Debug: Include src/config.rs and src/debug.rs to denote configuration handling and debugging/logging functionalities that assist in running and troubleshooting the tool.

##### Relationships & Interactions
- The CLI (main.rs) acts as the controller: it processes user inputs (commands) and then calls into the shared library in lib.rs.
- lib.rs acts as a facade coordinating between the cryptography routines (crypto.rs), the transformation provided by the cipher module (cipher/mod.rs and patterns.rs), and key management (keys.rs and keystore.rs).
- Data flow is such that when a user runs an encryption command, the input file is passed to the encryption module (via crypto.rs) which then calls the cipher module to wrap the secure data in pet-speak. A similar reverse flow happens during decryption.
- Configuration parameters from config.rs and logging functionality from debug.rs help in managing runtime behavior and diagnosing issues.

##### Architectural Patterns & Design Principles
- Separation of Concerns is clearly applied: the CLI is separate from the business logic; cryptographic functions are separate from the presentation transformation (pet-speak ciphering).
- Modularity: Each key part of the encryption process (parsing, key management, crypto, and encoding) is implemented in its own module.

##### Technologies, Frameworks, & Tools
- Rust is the language; highlight that it uses Cargo (via Cargo.toml) for dependency and build management.
- The design might reference the secp256k1 elliptic curve cryptography (as mentioned in the README).

##### Instructing the Principal Software Engineer – What
- Use clear, labeled blocks for each component (CLI, Lib, Crypto Module, Cipher Module, Key Management, Config, Debug).
- That all core processes (key generation, encryption, decryption, key import) are detailed, noting that although the pet-speak is playful, it rests on robust cryptography.

## Diagram (Mermaid)

```mermaid
flowchart TD
    CMD["User Command"]

    subgraph "CLI Layer"
        CLI["CLI Interface (main.rs)"]:::infrastructure
    end

    subgraph "Business Logic Layer"
        LIB["Library/Business Logic (lib.rs)"]:::business
        CRYPTO["Cryptography Module (crypto.rs)"]:::business

        subgraph "Cipher Module"
            CIPHER1["Cipher mod.rs"]:::business
            CIPHER2["Cipher patterns.rs"]:::business
        end

        subgraph "Key Management"
            KEYS["Keys (keys.rs)"]:::business
            KEYSTORE["Keystore (keystore.rs)"]:::business
        end

        CONFIG["Configuration (config.rs)"]:::infrastructure
        DEBUG["Debug / Logging (debug.rs)"]:::infrastructure
    end

    CMD --> CLI
    CLI --> LIB
    LIB --> CRYPTO
    LIB --> CIPHER1
    LIB --> CIPHER2
    LIB --> KEYS
    LIB --> KEYSTORE
    LIB --> CONFIG
    LIB --> DEBUG

    click CLI "https://github.com/vxfemboy/purrcrypt/blob/main/src/main.rs"
    click LIB "https://github.com/vxfemboy/purrcrypt/blob/main/src/lib.rs"
    click CRYPTO "https://github.com/vxfemboy/purrcrypt/blob/main/src/crypto.rs"
    click CIPHER1 "https://github.com/vxfemboy/purrcrypt/blob/main/src/cipher/mod.rs"
    click CIPHER2 "https://github.com/vxfemboy/purrcrypt/blob/main/src/cipher/patterns.rs"
    click KEYS "https://github.com/vxfemboy/purrcrypt/blob/main/src/keys.rs"
    click KEYSTORE "https://github.com/vxfemboy/purrcrypt/blob/main/src/keystore.rs"
    click CONFIG "https://github.com/vxfemboy/purrcrypt/blob/main/src/config.rs"
    click DEBUG "https://github.com/vxfemboy/purrcrypt/blob/main/src/debug.rs"

    classDef infrastructure fill:#f9c,stroke:#333,stroke-width:2px;
    classDef business fill:#cfc,stroke:#333,stroke-width:2px;
```
