# astrorick/cloak architecture

> Architecture diagram of the GitHub repository astrorick/cloak, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-14). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/astrorick/cloak
- Repository: https://github.com/astrorick/cloak

## Overview

Cloak is a command-line file encryption and decryption tool, with key-generation and password-generation utilities. The main command handler validates inputs and selects credentials and crypto options, then handles file output; password-based operations derive a key, while key-based operations load or generate one. The README also documents algorithm/method listing and version commands. Source excerpts show several calls, but omit parts of the command handlers, so some documented feature links are grounded in the README rather than inspected handler code.

Main entry points: [`cmd/cloak/main.go`](https://github.com/astrorick/cloak/blob/main/cmd/cloak/main.go) (Command workflows), [`pkg/keygen/keygen.go`](https://github.com/astrorick/cloak/blob/main/pkg/keygen/keygen.go) (Password KDF registry), [`pkg/algos/algos.go`](https://github.com/astrorick/cloak/blob/main/pkg/algos/algos.go) (Algorithm registry), [`pkg/utils/utils.go`](https://github.com/astrorick/cloak/blob/main/pkg/utils/utils.go) (File and prompt helpers)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_cli["CLI workflows"]
  node_commands["Command workflows<br/>[main.go]"]
  node_passwords["Password generation<br/>[pswgen.go]"]
end

subgraph group_keys["Key management"]
  node_keygen["Key generation<br/>[keygen.go]"]
  node_kdf["Password KDF registry<br/>[keygen.go]"]
  node_argon2["Argon2id<br/>[argon2.go]"]
  node_pbkdf2["PBKDF2<br/>[pbkdf2.go]"]
end

subgraph group_crypto["Encryption algorithms"]
  node_algoreg["Algorithm registry<br/>[algos.go]"]
  node_aesgcm["AES-GCM<br/>[aesgcm.go]"]
  node_chacha["ChaCha20-Poly1305"]
end

subgraph group_helpers["Input utilities"]
  node_utils["File and prompt helpers<br/>[utils.go]"]
end

node_user(("CLI user"))
node_files["Input and output files"]

node_user -->|"runs commands"| node_commands
node_commands -->|"reads and writes"| node_files
node_commands -->|"checks and prompts"| node_utils
node_commands -->|"generates keys"| node_keygen
node_commands -->|"derives keys"| node_kdf
node_commands -->|"selects algorithm"| node_algoreg
node_commands -->|"generates passwords"| node_passwords
node_utils -->|"validates passwords"| node_passwords
node_kdf -->|"registers"| node_argon2
node_kdf -->|"registers"| node_pbkdf2
node_algoreg -->|"registers"| node_aesgcm
node_algoreg -->|"registers"| node_chacha

click node_commands "https://github.com/astrorick/cloak/blob/main/cmd/cloak/main.go"
click node_passwords "https://github.com/astrorick/cloak/blob/main/pkg/pswgen/pswgen.go"
click node_keygen "https://github.com/astrorick/cloak/blob/main/pkg/keygen/keygen.go"
click node_kdf "https://github.com/astrorick/cloak/blob/main/pkg/keygen/keygen.go"
click node_argon2 "https://github.com/astrorick/cloak/blob/main/pkg/keygen/methods/argon2.go"
click node_pbkdf2 "https://github.com/astrorick/cloak/blob/main/pkg/keygen/methods/pbkdf2.go"
click node_algoreg "https://github.com/astrorick/cloak/blob/main/pkg/algos/algos.go"
click node_aesgcm "https://github.com/astrorick/cloak/blob/main/pkg/algos/aead/aesgcm.go"
click node_chacha "https://github.com/astrorick/cloak/blob/main/pkg/algos/aead/chacha20poly1305.go"
click node_utils "https://github.com/astrorick/cloak/blob/main/pkg/utils/utils.go"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_commands,node_passwords,node_user toneBlue
class node_keygen,node_kdf,node_argon2,node_pbkdf2 toneAmber
class node_algoreg,node_aesgcm,node_chacha toneMint
class node_utils toneRose
class node_files toneIndigo
```

## Components

### CLI workflows

- [Command workflows](https://github.com/astrorick/cloak/blob/main/cmd/cloak/main.go): `cmd/cloak/main.go`
- [Password generation](https://github.com/astrorick/cloak/blob/main/pkg/pswgen/pswgen.go): `pkg/pswgen/pswgen.go`

### Key management

- [Key generation](https://github.com/astrorick/cloak/blob/main/pkg/keygen/keygen.go): `pkg/keygen/keygen.go`
- [Password KDF registry](https://github.com/astrorick/cloak/blob/main/pkg/keygen/keygen.go): `pkg/keygen/keygen.go`
- [Argon2id](https://github.com/astrorick/cloak/blob/main/pkg/keygen/methods/argon2.go): `pkg/keygen/methods/argon2.go`
- [PBKDF2](https://github.com/astrorick/cloak/blob/main/pkg/keygen/methods/pbkdf2.go): `pkg/keygen/methods/pbkdf2.go`

### Encryption algorithms

- [Algorithm registry](https://github.com/astrorick/cloak/blob/main/pkg/algos/algos.go): `pkg/algos/algos.go`
- [AES-GCM](https://github.com/astrorick/cloak/blob/main/pkg/algos/aead/aesgcm.go): `pkg/algos/aead/aesgcm.go`
- [ChaCha20-Poly1305](https://github.com/astrorick/cloak/blob/main/pkg/algos/aead/chacha20poly1305.go): `pkg/algos/aead/chacha20poly1305.go`

### Input utilities

- [File and prompt helpers](https://github.com/astrorick/cloak/blob/main/pkg/utils/utils.go): `pkg/utils/utils.go`

### Other components

- **CLI user**
- **Input and output files**

## Connections

- CLI user → Command workflows: runs commands (evidence: `README.md`)
- Command workflows → Input and output files: reads and writes (evidence: `cmd/cloak/main.go`)
- Command workflows → File and prompt helpers: checks and prompts (evidence: `cmd/cloak/main.go`)
- Command workflows → Key generation: generates keys (evidence: `cmd/cloak/main.go`)
- Command workflows → Password KDF registry: derives keys (evidence: `cmd/cloak/main.go`)
- Command workflows → Algorithm registry: selects algorithm (evidence: `README.md`)
- Command workflows → Password generation: generates passwords (evidence: `README.md`)
- File and prompt helpers → Password generation: validates passwords (evidence: `pkg/utils/utils.go`)
- Password KDF registry → Argon2id: registers (evidence: `pkg/keygen/keygen.go`)
- Password KDF registry → PBKDF2: registers (evidence: `pkg/keygen/keygen.go`)
- Algorithm registry → AES-GCM: registers (evidence: `pkg/algos/algos.go`)
- Algorithm registry → ChaCha20-Poly1305: registers (evidence: `pkg/algos/algos.go`)
