# maanrachid/sof architecture

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

- Interactive diagram: https://gitdiagram.com/maanrachid/sof
- Repository: https://github.com/maanrachid/sof

## Overview

SOF is a command-line tool for finding suffix–prefix overlaps among DNA sequences. A user supplies newline-separated sequences and selects thread count, minimum match length, sorting, distribution, and output format. The main workflow reads and encodes the sequences, optionally sorts them, builds a compact prefix tree, searches for overlaps, and reports the requested results. The README also documents FASTA conversion and random-input generation. Some orchestration calls and the generator implementation were not sampled, so those relationships are shown only where documented.

Main entry points: [`Apsp.cpp`](https://github.com/maanrachid/sof/blob/master/Apsp.cpp) (SOF CLI and workflow), [`converter_fasta_to_plain.cpp`](https://github.com/maanrachid/sof/blob/master/converter_fasta_to_plain.cpp) (FASTA converter), [`gen`](https://github.com/maanrachid/sof/blob/master/gen) (Random input generator), [`Ctree.cpp`](https://github.com/maanrachid/sof/blob/master/Ctree.cpp) (Parallel overlap search)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_input["Input preparation"]
  node_fasta_converter["FASTA converter"]
  node_random_generator["Random input generator"]
end

subgraph group_engine["Overlap engine"]
  node_apsp["SOF CLI and workflow<br/>[Apsp.cpp]"]
  node_encoded_data["Encoded sequences<br/>[Apsp.cpp]"]
  node_sequence_sort["Sequence sorting<br/>[Apsp.cpp]"]
  node_prefix_tree["Compact prefix tree<br/>[Ctree.cpp]"]
  node_overlap_search["Parallel overlap search<br/>[Ctree.cpp]"]
  node_overlap_results["Overlap results<br/>[Ctree.cpp]"]
end

subgraph group_support["Runtime support"]
  node_bit_tools["Encoding and bit tools<br/>[Tools.cpp]"]
  node_timing["Timing utilities<br/>[testutils.cpp]"]
end

node_user(("CLI user"))
node_sequence_file["Sequence file"]

node_user -->|"runs"| node_apsp
node_user -->|"provides"| node_sequence_file
node_sequence_file -->|"reads"| node_apsp
node_apsp -->|"encodes"| node_encoded_data
node_apsp -->|"optionally sorts"| node_sequence_sort
node_apsp -->|"constructs"| node_prefix_tree
node_apsp -.->|"runs"| node_overlap_search
node_overlap_search -->|"reports"| node_overlap_results
node_user -->|"runs"| node_fasta_converter
node_fasta_converter -->|"converts to"| node_sequence_file
node_user -->|"runs"| node_random_generator
node_random_generator -->|"generates"| node_sequence_file
node_apsp -->|"measures with"| node_timing

click node_apsp "https://github.com/maanrachid/sof/blob/master/Apsp.cpp"
click node_encoded_data "https://github.com/maanrachid/sof/blob/master/Apsp.cpp"
click node_sequence_sort "https://github.com/maanrachid/sof/blob/master/Apsp.cpp"
click node_prefix_tree "https://github.com/maanrachid/sof/blob/master/Ctree.cpp"
click node_overlap_search "https://github.com/maanrachid/sof/blob/master/Ctree.cpp"
click node_overlap_results "https://github.com/maanrachid/sof/blob/master/Ctree.cpp"
click node_fasta_converter "https://github.com/maanrachid/sof/blob/master/converter_fasta_to_plain.cpp"
click node_random_generator "https://github.com/maanrachid/sof/blob/master/gen"
click node_bit_tools "https://github.com/maanrachid/sof/blob/master/Tools.cpp"
click node_timing "https://github.com/maanrachid/sof/blob/master/testutils.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_fasta_converter,node_random_generator,node_user toneBlue
class node_apsp,node_encoded_data,node_sequence_sort,node_prefix_tree,node_overlap_search,node_overlap_results toneAmber
class node_bit_tools,node_timing toneMint
class node_sequence_file toneIndigo
```

## Components

### Input preparation

- [FASTA converter](https://github.com/maanrachid/sof/blob/master/converter_fasta_to_plain.cpp): `converter_fasta_to_plain.cpp`
- [Random input generator](https://github.com/maanrachid/sof/blob/master/gen): `gen`

### Overlap engine

- [SOF CLI and workflow](https://github.com/maanrachid/sof/blob/master/Apsp.cpp): `Apsp.cpp`
- [Encoded sequences](https://github.com/maanrachid/sof/blob/master/Apsp.cpp): `Apsp.cpp`
- [Sequence sorting](https://github.com/maanrachid/sof/blob/master/Apsp.cpp): `Apsp.cpp`
- [Compact prefix tree](https://github.com/maanrachid/sof/blob/master/Ctree.cpp): `Ctree.cpp`
- [Parallel overlap search](https://github.com/maanrachid/sof/blob/master/Ctree.cpp): `Ctree.cpp`
- [Overlap results](https://github.com/maanrachid/sof/blob/master/Ctree.cpp): `Ctree.cpp`

### Runtime support

- [Encoding and bit tools](https://github.com/maanrachid/sof/blob/master/Tools.cpp): `Tools.cpp`
- [Timing utilities](https://github.com/maanrachid/sof/blob/master/testutils.cpp): `testutils.cpp`

### Other components

- **CLI user**
- **Sequence file**

## Connections

- CLI user → SOF CLI and workflow: runs (evidence: `README.txt`)
- CLI user → Sequence file: provides (evidence: `README.txt`)
- Sequence file → SOF CLI and workflow: reads (evidence: `Apsp.cpp`)
- SOF CLI and workflow → Encoded sequences: encodes (evidence: `Apsp.cpp`)
- SOF CLI and workflow → Sequence sorting: optionally sorts (evidence: `Apsp.cpp`)
- SOF CLI and workflow → Compact prefix tree: constructs (evidence: `Apsp.cpp`)
- SOF CLI and workflow → Parallel overlap search: runs (evidence: `README.txt`)
- Parallel overlap search → Overlap results: reports (evidence: `Ctree.cpp`)
- CLI user → FASTA converter: runs (evidence: `README.txt`)
- FASTA converter → Sequence file: converts to (evidence: `README.txt`)
- CLI user → Random input generator: runs (evidence: `README.txt`)
- Random input generator → Sequence file: generates (evidence: `README.txt`)
- SOF CLI and workflow → Timing utilities: measures with (evidence: `Apsp.cpp`)
