# ot-kartoshka/rabbitcipher architecture

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

- Interactive diagram: https://gitdiagram.com/ot-kartoshka/rabbitcipher
- Repository: https://github.com/ot-kartoshka/rabbitcipher

## Overview

RabbitCipher is a C++ CLI for encrypting and decrypting files with the Rabbit stream cipher. The main workflow parses options, resolves paths, and delegates file processing to RabbitManager, which obtains key material, selects or generates an IV, handles the encrypted-file header, and streams bytes through the cipher in 4 MB chunks. Key generation and persistence are separate from the cipher core. The README documents interactive and quiet modes, IV conflict handling, and headerless operation; implementation relationships below are cited only where shown in the supplied excerpts.

Main entry points: [`src/RabbitManager.cpp`](https://github.com/ot-kartoshka/rabbitcipher/blob/master/src/RabbitManager.cpp) (Processing Coordinator), [`main.cpp`](https://github.com/ot-kartoshka/rabbitcipher/blob/master/main.cpp) (CLI Arguments and Paths), [`src/KeyManager.cpp`](https://github.com/ot-kartoshka/rabbitcipher/blob/master/src/KeyManager.cpp) (Key and IV Management), [`src/Rabbit.cpp`](https://github.com/ot-kartoshka/rabbitcipher/blob/master/src/Rabbit.cpp) (Rabbit Keystream)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_cli["CLI"]
  node_cli["CLI Arguments and Paths<br/>[main.cpp]"]
  node_errors["Error Messages<br/>[Errors.cpp]"]
end

subgraph group_processing["File Processing"]
  node_manager["Processing Coordinator<br/>[RabbitManager.cpp]"]
  node_stream["Buffered Stream XOR<br/>[RabbitManager.cpp]"]
  node_header["IV Header Handling<br/>[RabbitManager.cpp]"]
end

subgraph group_keys["Key and IV"]
  node_keymanager["Key and IV Management<br/>[KeyManager.cpp]"]
end

subgraph group_cipher["Cipher Core"]
  node_rabbit["Rabbit Keystream<br/>[Rabbit.cpp]"]
end

node_user(("User"))
node_input["Input File"]
node_output["Output File"]
node_keyfile["Key File"]

node_user -->|"provides options"| node_cli
node_cli -->|"calls processing"| node_manager
node_cli -->|"formats errors"| node_errors
node_manager -->|"loads or generates keys"| node_keymanager
node_keymanager -->|"reads and writes"| node_keyfile
node_manager -->|"reads file"| node_input
node_manager -->|"handles IV metadata"| node_header
node_manager -->|"writes file"| node_output
node_manager -->|"processes file chunks"| node_stream
node_stream -->|"XORs with keystream"| node_rabbit
node_manager -->|"initializes cipher"| node_rabbit

click node_cli "https://github.com/ot-kartoshka/rabbitcipher/blob/master/main.cpp"
click node_errors "https://github.com/ot-kartoshka/rabbitcipher/blob/master/src/Errors.cpp"
click node_manager "https://github.com/ot-kartoshka/rabbitcipher/blob/master/src/RabbitManager.cpp"
click node_stream "https://github.com/ot-kartoshka/rabbitcipher/blob/master/src/RabbitManager.cpp"
click node_header "https://github.com/ot-kartoshka/rabbitcipher/blob/master/src/RabbitManager.cpp"
click node_keymanager "https://github.com/ot-kartoshka/rabbitcipher/blob/master/src/KeyManager.cpp"
click node_rabbit "https://github.com/ot-kartoshka/rabbitcipher/blob/master/src/Rabbit.cpp"

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_cli,node_errors,node_user toneBlue
class node_manager,node_stream,node_header toneAmber
class node_keymanager toneMint
class node_rabbit toneRose
class node_input,node_output,node_keyfile toneIndigo
```

## Components

### CLI

- [CLI Arguments and Paths](https://github.com/ot-kartoshka/rabbitcipher/blob/master/main.cpp): `main.cpp`
- [Error Messages](https://github.com/ot-kartoshka/rabbitcipher/blob/master/src/Errors.cpp): `src/Errors.cpp`

### File Processing

- [Processing Coordinator](https://github.com/ot-kartoshka/rabbitcipher/blob/master/src/RabbitManager.cpp): `src/RabbitManager.cpp`
- [Buffered Stream XOR](https://github.com/ot-kartoshka/rabbitcipher/blob/master/src/RabbitManager.cpp): `src/RabbitManager.cpp`
- [IV Header Handling](https://github.com/ot-kartoshka/rabbitcipher/blob/master/src/RabbitManager.cpp): `src/RabbitManager.cpp`

### Key and IV

- [Key and IV Management](https://github.com/ot-kartoshka/rabbitcipher/blob/master/src/KeyManager.cpp): `src/KeyManager.cpp`

### Cipher Core

- [Rabbit Keystream](https://github.com/ot-kartoshka/rabbitcipher/blob/master/src/Rabbit.cpp): `src/Rabbit.cpp`

### Other components

- **User**
- **Input File**
- **Output File**
- **Key File**

## Connections

- User → CLI Arguments and Paths: provides options (evidence: `README.md`)
- CLI Arguments and Paths → Processing Coordinator: calls processing (evidence: `main.cpp`)
- CLI Arguments and Paths → Error Messages: formats errors (evidence: `main.cpp`)
- Processing Coordinator → Key and IV Management: loads or generates keys (evidence: `src/RabbitManager.cpp`)
- Key and IV Management → Key File: reads and writes (evidence: `src/KeyManager.cpp`)
- Processing Coordinator → Input File: reads file (evidence: `src/RabbitManager.cpp`)
- Processing Coordinator → IV Header Handling: handles IV metadata (evidence: `src/RabbitManager.cpp`)
- Processing Coordinator → Output File: writes file (evidence: `src/RabbitManager.cpp`)
- Processing Coordinator → Buffered Stream XOR: processes file chunks (evidence: `src/RabbitManager.cpp`)
- Buffered Stream XOR → Rabbit Keystream: XORs with keystream (evidence: `src/RabbitManager.cpp`)
- Processing Coordinator → Rabbit Keystream: initializes cipher (evidence: `src/RabbitManager.cpp`)
