# smsmaydi/mode-of-operation architecture

> Architecture diagram of the GitHub repository smsmaydi/mode-of-operation, 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/smsmaydi/mode-of-operation
- Repository: https://github.com/smsmaydi/mode-of-operation

## Overview

This is a ReactFlow educational visualizer for ECB, CBC, and CTR block-cipher modes, with XOR/AES routing, image encryption and decryption, and encrypted-file output. Users enter plaintext, keys, and mode parameters, then build or use a preset data-flow graph; the app evaluates the graph or dispatches image work to cipher handlers, which update graph-node results. The graph preserves the documented AES-step visualization and mode presets. Relationships are limited to README statements and source references or excerpts; unsampled wiring is omitted.

Main entry points: [`src/App.js`](https://github.com/smsmaydi/mode-of-operation/blob/main/src/App.js) (Graph app), [`src/utils/cipherHandlers/aesHandler.js`](https://github.com/smsmaydi/mode-of-operation/blob/main/src/utils/cipherHandlers/aesHandler.js) (AES handler), [`src/utils/cipherHandlers/index.js`](https://github.com/smsmaydi/mode-of-operation/blob/main/src/utils/cipherHandlers/index.js) (Cipher dispatch), [`src/utils/cipherHandlers/xorHandler.js`](https://github.com/smsmaydi/mode-of-operation/blob/main/src/utils/cipherHandlers/xorHandler.js) (XOR handler)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interaction["Graph interaction"]
  node_app["Graph app<br/>[App.js]"]
  node_inputs["Graph inputs"]
  node_palette["Node palette<br/>[NodePalette.jsx]"]
  node_mode_menu["Mode selection<br/>[ModeMenu.jsx]"]
  node_presets["Mode presets<br/>[presets.js]"]
  node_plaintext["Plaintext input<br/>[PlaintextNode.jsx]"]
  node_cipher_node["Cipher node"]
  node_ciphertext["Ciphertext output<br/>[CiphertextNode.jsx]"]
end

subgraph group_evaluation["Graph evaluation"]
  node_graph_compute["Graph evaluation<br/>[computeGraph.js]"]
  node_dynamic_graph["Dynamic blocks"]
  node_ecb_trace["ECB trace<br/>[ecbTrace.js]"]
  node_validators["Connection checks<br/>[validators.js]"]
end

subgraph group_crypto["Cipher operations"]
  node_cipher_dispatch["Cipher dispatch<br/>[index.js]"]
  node_xor_handler["XOR handler<br/>[xorHandler.js]"]
  node_aes_handler["AES handler<br/>[aesHandler.js]"]
  node_image_bytes["Image conversion<br/>[imageToBytes.js]"]
  node_image_xor["Image XOR<br/>[imageXor.js]"]
  node_aes_file["AES file crypto<br/>[aesFile.js]"]
  node_aes_ecb["AES ECB images<br/>[aesEcbImage.js]"]
  node_aes_cbc["AES CBC images<br/>[aesCbcImage.js]"]
end

subgraph group_visualization["AES visualization"]
  node_aes_view["AES step view<br/>[SubBytesView.jsx]"]
  node_aes_view_data["AES graph data<br/>[aesViewData.js]"]
end

node_user(("Learner"))

node_user -->|"uses"| node_app
node_app -->|"renders"| node_inputs
node_app -->|"renders"| node_palette
node_app -->|"renders"| node_mode_menu
node_app -->|"builds preset"| node_presets
node_app -->|"evaluates graph"| node_graph_compute
node_app -->|"dispatches cipher"| node_cipher_dispatch
node_app -->|"checks connections"| node_validators
node_user -->|"enters data"| node_plaintext
node_app -->|"renders"| node_cipher_node
node_app -->|"renders"| node_ciphertext
node_cipher_dispatch -->|"evaluates XOR"| node_graph_compute
node_cipher_dispatch -->|"runs image XOR"| node_xor_handler
node_cipher_dispatch -->|"runs image AES"| node_aes_handler
node_xor_handler -->|"decodes image"| node_image_bytes
node_xor_handler -->|"XORs pixels"| node_image_xor
node_aes_handler -->|"decodes image"| node_image_bytes
node_aes_handler -->|"encrypts files"| node_aes_file
node_aes_handler -->|"handles ECB images"| node_aes_ecb
node_aes_handler -->|"handles CBC images"| node_aes_cbc
node_aes_view -->|"reads graph data"| node_aes_view_data
node_aes_view_data -->|"derives graph state"| node_graph_compute

click node_app "https://github.com/smsmaydi/mode-of-operation/blob/main/src/App.js"
click node_inputs "https://github.com/smsmaydi/mode-of-operation/blob/main/src/components/layout/GraphInputsPanel.jsx"
click node_palette "https://github.com/smsmaydi/mode-of-operation/blob/main/src/components/palette/NodePalette.jsx"
click node_mode_menu "https://github.com/smsmaydi/mode-of-operation/blob/main/src/components/layout/ModeMenu.jsx"
click node_presets "https://github.com/smsmaydi/mode-of-operation/blob/main/src/utils/presets.js"
click node_plaintext "https://github.com/smsmaydi/mode-of-operation/blob/main/src/components/nodes/PlaintextNode.jsx"
click node_cipher_node "https://github.com/smsmaydi/mode-of-operation/blob/main/src/components/nodes/BlockCipherNode.jsx"
click node_ciphertext "https://github.com/smsmaydi/mode-of-operation/blob/main/src/components/nodes/CiphertextNode.jsx"
click node_graph_compute "https://github.com/smsmaydi/mode-of-operation/blob/main/src/utils/computeGraph.js"
click node_dynamic_graph "https://github.com/smsmaydi/mode-of-operation/blob/main/src/utils/dynamicBlockGraph.js"
click node_ecb_trace "https://github.com/smsmaydi/mode-of-operation/blob/main/src/utils/ecbTrace.js"
click node_validators "https://github.com/smsmaydi/mode-of-operation/blob/main/src/utils/validators.js"
click node_cipher_dispatch "https://github.com/smsmaydi/mode-of-operation/blob/main/src/utils/cipherHandlers/index.js"
click node_xor_handler "https://github.com/smsmaydi/mode-of-operation/blob/main/src/utils/cipherHandlers/xorHandler.js"
click node_aes_handler "https://github.com/smsmaydi/mode-of-operation/blob/main/src/utils/cipherHandlers/aesHandler.js"
click node_image_bytes "https://github.com/smsmaydi/mode-of-operation/blob/main/src/components/crypto/imageToBytes.js"
click node_image_xor "https://github.com/smsmaydi/mode-of-operation/blob/main/src/utils/imageXor.js"
click node_aes_file "https://github.com/smsmaydi/mode-of-operation/blob/main/src/utils/aesFile.js"
click node_aes_ecb "https://github.com/smsmaydi/mode-of-operation/blob/main/src/utils/aesEcbImage.js"
click node_aes_cbc "https://github.com/smsmaydi/mode-of-operation/blob/main/src/utils/aesCbcImage.js"
click node_aes_view "https://github.com/smsmaydi/mode-of-operation/blob/main/src/components/aes/SubBytesView.jsx"
click node_aes_view_data "https://github.com/smsmaydi/mode-of-operation/blob/main/src/utils/aesViewData.js"

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_app,node_inputs,node_palette,node_mode_menu,node_presets,node_plaintext,node_cipher_node,node_ciphertext toneBlue
class node_graph_compute,node_dynamic_graph,node_ecb_trace,node_validators toneAmber
class node_cipher_dispatch,node_xor_handler,node_aes_handler,node_image_bytes,node_image_xor,node_aes_file,node_aes_ecb,node_aes_cbc toneMint
class node_aes_view,node_aes_view_data toneRose
class node_user toneIndigo
```

## Components

### Graph interaction

- [Graph app](https://github.com/smsmaydi/mode-of-operation/blob/main/src/App.js): `src/App.js`
- [Graph inputs](https://github.com/smsmaydi/mode-of-operation/blob/main/src/components/layout/GraphInputsPanel.jsx): `src/components/layout/GraphInputsPanel.jsx`
- [Node palette](https://github.com/smsmaydi/mode-of-operation/blob/main/src/components/palette/NodePalette.jsx): `src/components/palette/NodePalette.jsx`
- [Mode selection](https://github.com/smsmaydi/mode-of-operation/blob/main/src/components/layout/ModeMenu.jsx): `src/components/layout/ModeMenu.jsx`
- [Mode presets](https://github.com/smsmaydi/mode-of-operation/blob/main/src/utils/presets.js): `src/utils/presets.js`
- [Plaintext input](https://github.com/smsmaydi/mode-of-operation/blob/main/src/components/nodes/PlaintextNode.jsx): `src/components/nodes/PlaintextNode.jsx`
- [Cipher node](https://github.com/smsmaydi/mode-of-operation/blob/main/src/components/nodes/BlockCipherNode.jsx): `src/components/nodes/BlockCipherNode.jsx`
- [Ciphertext output](https://github.com/smsmaydi/mode-of-operation/blob/main/src/components/nodes/CiphertextNode.jsx): `src/components/nodes/CiphertextNode.jsx`

### Graph evaluation

- [Graph evaluation](https://github.com/smsmaydi/mode-of-operation/blob/main/src/utils/computeGraph.js): `src/utils/computeGraph.js`
- [Dynamic blocks](https://github.com/smsmaydi/mode-of-operation/blob/main/src/utils/dynamicBlockGraph.js): `src/utils/dynamicBlockGraph.js`
- [ECB trace](https://github.com/smsmaydi/mode-of-operation/blob/main/src/utils/ecbTrace.js): `src/utils/ecbTrace.js`
- [Connection checks](https://github.com/smsmaydi/mode-of-operation/blob/main/src/utils/validators.js): `src/utils/validators.js`

### Cipher operations

- [Cipher dispatch](https://github.com/smsmaydi/mode-of-operation/blob/main/src/utils/cipherHandlers/index.js): `src/utils/cipherHandlers/index.js`
- [XOR handler](https://github.com/smsmaydi/mode-of-operation/blob/main/src/utils/cipherHandlers/xorHandler.js): `src/utils/cipherHandlers/xorHandler.js`
- [AES handler](https://github.com/smsmaydi/mode-of-operation/blob/main/src/utils/cipherHandlers/aesHandler.js): `src/utils/cipherHandlers/aesHandler.js`
- [Image conversion](https://github.com/smsmaydi/mode-of-operation/blob/main/src/components/crypto/imageToBytes.js): `src/components/crypto/imageToBytes.js`
- [Image XOR](https://github.com/smsmaydi/mode-of-operation/blob/main/src/utils/imageXor.js): `src/utils/imageXor.js`
- [AES file crypto](https://github.com/smsmaydi/mode-of-operation/blob/main/src/utils/aesFile.js): `src/utils/aesFile.js`
- [AES ECB images](https://github.com/smsmaydi/mode-of-operation/blob/main/src/utils/aesEcbImage.js): `src/utils/aesEcbImage.js`
- [AES CBC images](https://github.com/smsmaydi/mode-of-operation/blob/main/src/utils/aesCbcImage.js): `src/utils/aesCbcImage.js`

### AES visualization

- [AES step view](https://github.com/smsmaydi/mode-of-operation/blob/main/src/components/aes/SubBytesView.jsx): `src/components/aes/SubBytesView.jsx`
- [AES graph data](https://github.com/smsmaydi/mode-of-operation/blob/main/src/utils/aesViewData.js): `src/utils/aesViewData.js`

### Other components

- **Learner**

## Connections

- Learner → Graph app: uses (evidence: `README.md`)
- Graph app → Graph inputs: renders (evidence: `src/App.js`)
- Graph app → Node palette: renders (evidence: `src/App.js`)
- Graph app → Mode selection: renders (evidence: `src/App.js`)
- Graph app → Mode presets: builds preset (evidence: `src/App.js`)
- Graph app → Graph evaluation: evaluates graph (evidence: `src/App.js`)
- Graph app → Cipher dispatch: dispatches cipher (evidence: `src/App.js`)
- Graph app → Connection checks: checks connections (evidence: `src/App.js`)
- Learner → Plaintext input: enters data (evidence: `README.md`)
- Graph app → Cipher node: renders (evidence: `src/App.js`)
- Graph app → Ciphertext output: renders (evidence: `src/App.js`)
- Cipher dispatch → Graph evaluation: evaluates XOR (evidence: `src/utils/cipherHandlers/index.js`)
- Cipher dispatch → XOR handler: runs image XOR (evidence: `src/utils/cipherHandlers/index.js`)
- Cipher dispatch → AES handler: runs image AES (evidence: `src/utils/cipherHandlers/index.js`)
- XOR handler → Image conversion: decodes image (evidence: `src/utils/cipherHandlers/xorHandler.js`)
- XOR handler → Image XOR: XORs pixels (evidence: `src/utils/cipherHandlers/xorHandler.js`)
- AES handler → Image conversion: decodes image (evidence: `src/utils/cipherHandlers/aesHandler.js`)
- AES handler → AES file crypto: encrypts files (evidence: `src/utils/cipherHandlers/aesHandler.js`)
- AES handler → AES ECB images: handles ECB images (evidence: `src/utils/cipherHandlers/aesHandler.js`)
- AES handler → AES CBC images: handles CBC images (evidence: `src/utils/cipherHandlers/aesHandler.js`)
- AES step view → AES graph data: reads graph data (evidence: `src/components/aes/SubBytesView.jsx`)
- AES graph data → Graph evaluation: derives graph state (evidence: `src/utils/aesViewData.js`)
