# hartwell-labs/quantum-shield architecture

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

- Interactive diagram: https://gitdiagram.com/hartwell-labs/quantum-shield
- Repository: https://github.com/hartwell-labs/quantum-shield

## Overview

pqguard is a Rust CLI for post-quantum file encryption using ML-KEM-768 and AES-256-GCM. The user-facing workflow begins with CLI command dispatch: generate keypairs, encrypt for one or more recipients, decrypt with a private key, or inspect/verify files. File workflows load key material and use the cryptographic layer for encapsulation, derivation, encryption, parsing, and decryption. The excerpts show the main command routes and file operations; capabilities are represented at their implementing modules, without inferring unsampled internals.

Main entry points: [`src/encrypt.rs`](https://github.com/hartwell-labs/quantum-shield/blob/main/src/encrypt.rs) (File encryption), [`src/main.rs`](https://github.com/hartwell-labs/quantum-shield/blob/main/src/main.rs) (Command dispatch), [`src/decrypt.rs`](https://github.com/hartwell-labs/quantum-shield/blob/main/src/decrypt.rs) (File decryption), [`src/keygen.rs`](https://github.com/hartwell-labs/quantum-shield/blob/main/src/keygen.rs) (Key generation and info)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_cli["CLI"]
  node_command_dispatch["Command dispatch<br/>[main.rs]"]
end

subgraph group_keys["Key management"]
  node_key_management["Key generation and info<br/>[keygen.rs]"]
  node_key_loading["Key file access<br/>[keyfile.rs]"]
end

subgraph group_files["File workflows"]
  node_file_encryption["File encryption<br/>[encrypt.rs]"]
  node_file_decryption["File decryption<br/>[decrypt.rs]"]
end

subgraph group_crypto["Cryptography"]
  node_crypto_engine["KEM and envelope crypto<br/>[crypto.rs]"]
end

node_user(("CLI user"))
node_key_files["Key files"]
node_encrypted_files["Encrypted files"]

node_user -->|"selects command"| node_command_dispatch
node_command_dispatch -->|"dispatches keygen/info"| node_key_management
node_command_dispatch -->|"dispatches encrypt/verify"| node_file_encryption
node_command_dispatch -->|"dispatches decrypt"| node_file_decryption
node_key_management -->|"generates keys"| node_crypto_engine
node_key_management -->|"writes keypair"| node_key_files
node_key_loading -->|"re-exports loaders"| node_key_management
node_key_loading -->|"loads key data"| node_key_files
node_file_encryption -->|"loads recipient keys"| node_key_loading
node_file_encryption -->|"seals envelope"| node_crypto_engine
node_file_encryption -->|"writes envelope"| node_encrypted_files
node_file_encryption -->|"reads to verify"| node_encrypted_files
node_file_decryption -->|"loads private key"| node_key_loading
node_file_decryption -->|"reads envelope"| node_encrypted_files
node_file_decryption -->|"opens envelope"| node_crypto_engine

click node_command_dispatch "https://github.com/hartwell-labs/quantum-shield/blob/main/src/main.rs"
click node_key_management "https://github.com/hartwell-labs/quantum-shield/blob/main/src/keygen.rs"
click node_key_loading "https://github.com/hartwell-labs/quantum-shield/blob/main/src/keyfile.rs"
click node_file_encryption "https://github.com/hartwell-labs/quantum-shield/blob/main/src/encrypt.rs"
click node_file_decryption "https://github.com/hartwell-labs/quantum-shield/blob/main/src/decrypt.rs"
click node_crypto_engine "https://github.com/hartwell-labs/quantum-shield/blob/main/src/crypto.rs"

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_command_dispatch,node_user toneBlue
class node_key_management,node_key_loading toneAmber
class node_file_encryption,node_file_decryption toneMint
class node_crypto_engine toneRose
class node_key_files,node_encrypted_files toneIndigo
```

## Components

### CLI

- [Command dispatch](https://github.com/hartwell-labs/quantum-shield/blob/main/src/main.rs): `src/main.rs`

### Key management

- [Key generation and info](https://github.com/hartwell-labs/quantum-shield/blob/main/src/keygen.rs): `src/keygen.rs`
- [Key file access](https://github.com/hartwell-labs/quantum-shield/blob/main/src/keyfile.rs): `src/keyfile.rs`

### File workflows

- [File encryption](https://github.com/hartwell-labs/quantum-shield/blob/main/src/encrypt.rs): `src/encrypt.rs`
- [File decryption](https://github.com/hartwell-labs/quantum-shield/blob/main/src/decrypt.rs): `src/decrypt.rs`

### Cryptography

- [KEM and envelope crypto](https://github.com/hartwell-labs/quantum-shield/blob/main/src/crypto.rs): `src/crypto.rs`

### Other components

- **CLI user**
- **Key files**
- **Encrypted files**

## Connections

- CLI user → Command dispatch: selects command (evidence: `src/main.rs`)
- Command dispatch → Key generation and info: dispatches keygen/info (evidence: `src/main.rs`)
- Command dispatch → File encryption: dispatches encrypt/verify (evidence: `src/main.rs`)
- Command dispatch → File decryption: dispatches decrypt (evidence: `src/main.rs`)
- Key generation and info → KEM and envelope crypto: generates keys (evidence: `src/keygen.rs`)
- Key generation and info → Key files: writes keypair (evidence: `src/keygen.rs`)
- Key file access → Key generation and info: re-exports loaders (evidence: `src/keyfile.rs`)
- Key file access → Key files: loads key data
- File encryption → Key file access: loads recipient keys (evidence: `src/encrypt.rs`)
- File encryption → KEM and envelope crypto: seals envelope (evidence: `src/encrypt.rs`)
- File encryption → Encrypted files: writes envelope (evidence: `src/encrypt.rs`)
- File encryption → Encrypted files: reads to verify (evidence: `src/encrypt.rs`)
- File decryption → Key file access: loads private key (evidence: `src/decrypt.rs`)
- File decryption → Encrypted files: reads envelope (evidence: `src/decrypt.rs`)
- File decryption → KEM and envelope crypto: opens envelope (evidence: `src/decrypt.rs`)
