# oakkaya/prince-ransomware architecture

> Architecture diagram of the GitHub repository oakkaya/prince-ransomware, 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/oakkaya/prince-ransomware
- Repository: https://github.com/oakkaya/prince-ransomware

## Overview

##### Project type and purpose
- This is a Go-based monorepo containing three related CLI tools:
a. Builder – generates or prepares configuration/keys
b. Encryptor – walks a directory tree and encrypts files
c. Decryptor – walks a directory tree and decrypts files
- There is no web/UI layer; it’s a file-system-oriented, pipeline-style encryption suite.

##### File structure
- Top-level: Build.bat, LICENSE, README.md
- Three submodules (each its own go.mod):
- Builder/…
- Encryptor/…
- Decryptor/…
- Encryptor has packages: configuration, filewalker, encryption
- Decryptor has packages: configuration, iterator, decryption
- Builder likely has a configuration/templating or key-gen logic in main.go

##### No README details → infer from filenames
- “configuration” packages parse config files or flags
- “filewalker”/“iterator” traverse directories and enumerate files
- “encryption”/“decryption” implement the cryptographic operations

##### Main components
a. CLI User (entry point)
b. Builder Service
- Config Generator
- (Optional) Key Management
→ Outputs: configuration file(s) and key artifacts
c. Encryptor Service
- Config Loader
- FileWalker
- Encryption Engine
→ Inputs: plaintext directory + config/keys
→ Outputs: encrypted files to target directory
d. Decryptor Service
- Config Loader
- Iterator
- Decryption Engine
→ Inputs: encrypted files + config/keys
→ Outputs: decrypted files
e. File System (source and target directories)

##### Relationships and dataflow
- User invokes Builder → produces config.json / key files
- User invokes Encryptor with config → FileWalker reads plaintext files → Encryption Engine uses keys → writes encrypted output
- User invokes Decryptor with config → Iterator reads encrypted files → Decryption Engine restores original → writes decrypted output

##### Architectural patterns and design principles
- Modular CLI tools (separation of concerns by function)
- Layered structure within each module:
- Configuration layer (parsing)
- Traversal layer (filewalker/iterator)
- Core crypto engine (encrypt/decrypt)
- Monorepo approach for shared conventions but isolated go.mod per tool

##### Technologies, frameworks, libraries
- Go (Go modules)
- Standard library for file I/O and crypto, or third-party crypto libs if imported
- Build.bat for Windows convenience

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Global Actor
    CLIUser["CLI User"]:::user

    %% Auxiliary Artifact
    BuildBat["Build.bat"]:::artifact
    CLIUser -->|"runs build"| BuildBat
    click BuildBat "https://github.com/oakkaya/prince-ransomware/blob/main/Build.bat"

    %% Config/Keys Artifact
    ConfigKeys["Config & Key Files"]:::artifact

    %% Plaintext and Encrypted/Decrypted FS
    PlainFS["Plaintext File System"]:::fs
    EncryptedFS["Encrypted File System"]:::fs
    DecryptedFS["Decrypted File System"]:::fs

    %% Builder Service
    subgraph "Builder Service"
        direction TB
        BuilderMain["CLI Entry & Key/Config Generator"]:::builder
        ConfigGen["Config Generator"]:::builder
        KeyMgmt["Key Management"]:::builder
        BuilderMain --> ConfigGen
        BuilderMain --> KeyMgmt
        ConfigGen --> ConfigKeys
        KeyMgmt --> ConfigKeys
    end
    CLIUser -->|"invoke builder"| BuilderMain
    click BuilderMain "https://github.com/oakkaya/prince-ransomware/blob/main/Builder/main.go"

    %% Encryptor Service
    subgraph "Encryptor Service"
        direction TB
        EncryptMain["CLI Entry"]:::encrypt
        EncryptGoMod["go.mod"]:::encrypt
        ConfigLoader["Configuration Loader"]:::encrypt
        FileWalker["FileWalker (traversal)"]:::encrypt
        EncryptEngine["Encryption Engine"]:::encrypt

        EncryptMain --> EncryptGoMod
        EncryptMain --> ConfigLoader
        ConfigLoader --> FileWalker
        FileWalker --> EncryptEngine
        EncryptEngine --> EncryptedFS
    end
    CLIUser -->|"invoke encryptor"| EncryptMain
    ConfigKeys -->|"config.json & keys"| ConfigLoader
    PlainFS -->|"plaintext files"| FileWalker

    click EncryptMain "https://github.com/oakkaya/prince-ransomware/blob/main/Encryptor/main.go"
    click EncryptGoMod "https://github.com/oakkaya/prince-ransomware/blob/main/Encryptor/go.mod"
    click ConfigLoader "https://github.com/oakkaya/prince-ransomware/blob/main/Encryptor/configuration/configuration.go"
    click FileWalker "https://github.com/oakkaya/prince-ransomware/blob/main/Encryptor/filewalker/filewalker.go"
    click EncryptEngine "https://github.com/oakkaya/prince-ransomware/blob/main/Encryptor/encryption/encryption.go"

    %% Decryptor Service
    subgraph "Decryptor Service"
        direction TB
        DecryptMain["CLI Entry"]:::decrypt
        DecryptGoMod["go.mod"]:::decrypt
        DecryptConfigLoader["Configuration Loader"]:::decrypt
        Iterator["Iterator (traversal)"]:::decrypt
        DecryptEngine["Decryption Engine"]:::decrypt

        DecryptMain --> DecryptGoMod
        DecryptMain --> DecryptConfigLoader
        DecryptConfigLoader --> Iterator
        Iterator --> DecryptEngine
        DecryptEngine --> DecryptedFS
    end
    CLIUser -->|"invoke decryptor"| DecryptMain
    ConfigKeys -->|"config.json & keys"| DecryptConfigLoader
    EncryptedFS -->|"encrypted files"| Iterator

    click DecryptMain "https://github.com/oakkaya/prince-ransomware/blob/main/Decryptor/main.go"
    click DecryptGoMod "https://github.com/oakkaya/prince-ransomware/blob/main/Decryptor/go.mod"
    click DecryptConfigLoader "https://github.com/oakkaya/prince-ransomware/blob/main/Decryptor/configuration/configuration.go"
    click Iterator "https://github.com/oakkaya/prince-ransomware/blob/main/Decryptor/iterator/filewalker.go"
    click DecryptEngine "https://github.com/oakkaya/prince-ransomware/blob/main/Decryptor/decryption/decryption.go"

    %% Styles
    classDef builder fill:#ADD8E6,stroke:#000,color:#000
    classDef encrypt fill:#90EE90,stroke:#000,color:#000
    classDef decrypt fill:#FF7F7F,stroke:#000,color:#000
    classDef artifact fill:#D3D3D3,stroke:#000,color:#000
    classDef fs fill:#FFFACD,stroke:#000,color:#000
    classDef user fill:#FFC0CB,stroke:#000,color:#000
```
