# znwng/morese_cpp architecture

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

- Interactive diagram: https://gitdiagram.com/znwng/morese_cpp
- Repository: https://github.com/znwng/morese_cpp

## Overview

#### Purpose and Entry Points
Morese is a C++ command-line Morse code encoder/decoder. Its core model is a binary tree mirroring Morse dot/dash traversal. The executable entry point is `src/main.cpp`; build orchestration is provided by `Makefile`.

#### CLI Coordination
`src/main.cpp` owns command-line input handling and selects encode/decode behavior for direct command-line text or file-based input. It is the boundary between user-facing arguments/files and the Morse transformation classes.

#### Morse Tree as Shared Translation Model
`src/morse_tree.hpp` and `src/morse_tree.cpp` define the binary Morse tree. Tree traversal represents Morse symbols: dot and dash select branches, while node values represent decoded characters. This structure is the central dependency for decoding and likely supports encoding lookup construction.

#### Encoding Stage
`src/encoder.hpp` and `src/encoder.cpp` implement character/text-to-Morse conversion. Input text is transformed into Morse token sequences using the repository’s Morse mapping/tree model, then returned or emitted through the CLI layer.

#### Decoding Stage
`src/decoder.hpp` and `src/decoder.cpp` implement Morse-to-text conversion. Morse dot/dash sequences are traversed through the binary tree, with token boundaries determining when a decoded character is produced.

#### Data and Control Flow
For direct input, control flows from `src/main.cpp` to either encoder or decoder, then back to the CLI for output. For file input, `main.cpp` reads source content, passes it through the selected transformation, and writes transformed output. The encoder/decoder boundary isolates direction-specific parsing rules; `morse_tree` isolates symbol representation and traversal.

#### Runtime and External Boundaries
The project is a native C++ program with no indicated web runtime, database, or network service. External interaction is limited to the command shell, standard input arguments, filesystem reads/writes, and console output. `sample_big.txt` is a repository-provided large input example for file-oriented usage.

Main entry points: [`src/main.cpp`](https://github.com/znwng/morese_cpp/blob/main/src/main.cpp) (CLI Coordinator), [`src/encoder.cpp`](https://github.com/znwng/morese_cpp/blob/main/src/encoder.cpp) (Morse Encoder), [`src/decoder.cpp`](https://github.com/znwng/morese_cpp/blob/main/src/decoder.cpp) (Morse Decoder), [`src/morse_tree.hpp`](https://github.com/znwng/morese_cpp/blob/main/src/morse_tree.hpp) (Morse Tree Interface)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Native CLI Runtime"]
  node_shell["Command Shell<br/>external interface"]
  node_main["CLI Coordinator<br/>C++ entry point<br/>[main.cpp]"]
  node_filesystem["Filesystem<br/>external storage"]
  node_console["Console Output<br/>external interface"]
  node_sample_input["Large Input Example<br/>sample data<br/>[sample_big.txt]"]
end

subgraph group_translation["Morse Translation"]
  node_encoder_api["Encoder Interface<br/>C++ header<br/>[encoder.hpp]"]
  node_encoder["Morse Encoder<br/>C++ transformation<br/>[encoder.cpp]"]
  node_decoder_api["Decoder Interface<br/>C++ header<br/>[decoder.hpp]"]
  node_decoder["Morse Decoder<br/>C++ transformation<br/>[decoder.cpp]"]
  node_tree_api["Morse Tree Interface<br/>C++ header<br/>[morse_tree.hpp]"]
  node_tree{{"Binary Morse Tree<br/>shared translation model<br/>[morse_tree.cpp]"}}
end

node_makefile["Makefile<br/>build orchestration"]

node_makefile -->|"builds"| node_main
node_shell -->|"arguments / direct text"| node_main
node_main -->|"reads input / writes output"| node_filesystem
node_sample_input -.->|"example input"| node_filesystem
node_main -->|"encode mode"| node_encoder_api
node_encoder_api -.->|"declares"| node_encoder
node_main -->|"decode mode"| node_decoder_api
node_decoder_api -.->|"declares"| node_decoder
node_encoder -->|"uses mapping model"| node_tree_api
node_decoder -->|"uses traversal model"| node_tree_api
node_tree_api -.->|"declares"| node_tree
node_encoder -->|"Morse tokens"| node_main
node_decoder -->|"decoded text"| node_main
node_main -->|"prints result"| node_console

click node_makefile "https://github.com/znwng/morese_cpp/blob/main/Makefile"
click node_main "https://github.com/znwng/morese_cpp/blob/main/src/main.cpp"
click node_sample_input "https://github.com/znwng/morese_cpp/blob/main/sample_big.txt"
click node_encoder_api "https://github.com/znwng/morese_cpp/blob/main/src/encoder.hpp"
click node_encoder "https://github.com/znwng/morese_cpp/blob/main/src/encoder.cpp"
click node_decoder_api "https://github.com/znwng/morese_cpp/blob/main/src/decoder.hpp"
click node_decoder "https://github.com/znwng/morese_cpp/blob/main/src/decoder.cpp"
click node_tree_api "https://github.com/znwng/morese_cpp/blob/main/src/morse_tree.hpp"
click node_tree "https://github.com/znwng/morese_cpp/blob/main/src/morse_tree.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_shell,node_main,node_filesystem,node_console,node_sample_input toneBlue
class node_encoder_api,node_encoder,node_decoder_api,node_decoder,node_tree_api,node_tree toneAmber
class node_makefile toneNeutral
```

## Components

### Native CLI Runtime

- **Command Shell**: external interface
- [CLI Coordinator](https://github.com/znwng/morese_cpp/blob/main/src/main.cpp): C++ entry point · Parses arguments, selects direction, and coordinates file or direct input. · `src/main.cpp`
- **Filesystem**: external storage · Supplies file input and receives transformed output.
- **Console Output**: external interface
- [Large Input Example](https://github.com/znwng/morese_cpp/blob/main/sample_big.txt): sample data · Repository-provided file-input example. · `sample_big.txt`

### Morse Translation

- [Encoder Interface](https://github.com/znwng/morese_cpp/blob/main/src/encoder.hpp): C++ header · `src/encoder.hpp`
- [Morse Encoder](https://github.com/znwng/morese_cpp/blob/main/src/encoder.cpp): C++ transformation · Converts characters and text into Morse tokens. · `src/encoder.cpp`
- [Decoder Interface](https://github.com/znwng/morese_cpp/blob/main/src/decoder.hpp): C++ header · `src/decoder.hpp`
- [Morse Decoder](https://github.com/znwng/morese_cpp/blob/main/src/decoder.cpp): C++ transformation · Converts Morse tokens into text. · `src/decoder.cpp`
- [Morse Tree Interface](https://github.com/znwng/morese_cpp/blob/main/src/morse_tree.hpp): C++ header · `src/morse_tree.hpp`
- [Binary Morse Tree](https://github.com/znwng/morese_cpp/blob/main/src/morse_tree.cpp): shared translation model · Dot and dash branches map Morse paths to character values. · `src/morse_tree.cpp`

### Other components

- [Makefile](https://github.com/znwng/morese_cpp/blob/main/Makefile): build orchestration · Builds the native executable. · `Makefile`

## Connections

- Makefile → CLI Coordinator: builds
- Command Shell → CLI Coordinator: arguments / direct text
- CLI Coordinator → Filesystem: reads input / writes output
- Large Input Example → Filesystem: example input
- CLI Coordinator → Encoder Interface: encode mode
- Encoder Interface → Morse Encoder: declares
- CLI Coordinator → Decoder Interface: decode mode
- Decoder Interface → Morse Decoder: declares
- Morse Encoder → Morse Tree Interface: uses mapping model
- Morse Decoder → Morse Tree Interface: uses traversal model
- Morse Tree Interface → Binary Morse Tree: declares
- Morse Encoder → CLI Coordinator: Morse tokens
- Morse Decoder → CLI Coordinator: decoded text
- CLI Coordinator → Console Output: prints result
