# sam-sims/fastalign architecture

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

- Interactive diagram: https://gitdiagram.com/sam-sims/fastalign
- Repository: https://github.com/sam-sims/fastalign

## Overview

##### Input/Output Components
- Input FASTA file (query sequences)
- Reference FASTA file
- Output aligned FASTA file

##### Core Processing Components
- FASTA Parser
- Minimap2 Binding Interface
- Alignment Processor
- Thread Pool Manager
- Output Formatter

**Input Layer**

**Processing Layer**

**Output Layer**

##### Component Details

a) Input Layer (Top):

b) Processing Layer (Middle):
- A "Minimap2 Interface" component that connects to each worker
- Sequence processing pipeline:
- FASTA Parser → Alignment Worker → Result Collector

c) Output Layer (Bottom):

##### Important Flows to Highlight

**Reference FASTA → FASTA Parser → Thread Pool Manager**
- ↓
**Query FASTA → FASTA Parser → Alignment Workers (parallel) → Result Collector → Output FASTA**
- ↑
- Minimap2 Interface

##### Additional Elements
- Annotations for key processes like:
- "Parallel Processing"
- "Deletion Handling (-)"
- "Insertion Omission"
- Thread count configuration

##### Technical Details to Note
- Rust implementation
- Minimap2-rs binding integration point
- CLI interface entry points

- The linear flow from input to output
- The parallel processing capability
- The integration with minimap2
- The sequence transformation process

Remember to include a small metadata section showing:
- Version information
- Thread configuration options
- File format specifications

This will give other engineers a clear understanding of both the high-level architecture and the specific implementation details of the fastalign tool.

## Diagram (Mermaid)

```mermaid
graph TB
    %% Input Layer
    subgraph Input
        QF[Query FASTA]:::input
        RF[Reference FASTA]:::input
    end

    %% Processing Layer
    subgraph Processing
        CLI[CLI Interface]:::core
        FP[FASTA Parser]:::core
        TPM[Thread Pool Manager]:::manager
        
        subgraph Workers
            AW1[Alignment Worker 1]:::worker
            AW2[Alignment Worker 2]:::worker
            AW3[Alignment Worker N]:::worker
        end
        
        MM2[Minimap2 Interface]:::external
        RC[Result Collector]:::core
    end

    %% Output Layer
    subgraph Output
        OF[Aligned FASTA]:::output
    end

    %% Connections
    QF --> CLI
    RF --> CLI
    CLI --> FP
    FP --> TPM
    TPM --> AW1 & AW2 & AW3
    MM2 --> AW1 & AW2 & AW3
    AW1 & AW2 & AW3 --> RC
    RC --> OF

    %% Component Click Events
    click CLI "https://github.com/Sam-Sims/fastalign/blob/main/src/cli.rs"
    click TPM "https://github.com/Sam-Sims/fastalign/blob/main/src/main.rs"
    click MM2 "https://github.com/Sam-Sims/fastalign/blob/main/Cargo.toml"

    %% Styling
    classDef input fill:#a8d1ff,stroke:#333
    classDef output fill:#a8d1ff,stroke:#333
    classDef core fill:#90EE90,stroke:#333
    classDef worker fill:#90EE90,stroke:#333
    classDef manager fill:#D3D3D3,stroke:#333
    classDef external fill:#FFE5B4,stroke:#333

    %% Legend
    subgraph Legend
        L1[Input/Output]:::input
        L2[Processing Components]:::core
        L3[Thread Manager]:::manager
        L4[External Dependencies]:::external
    end

    %% Notes
    note["
        - Parallel sequence processing
        - Deletion handling (-)
        - Insertion omission
        - Thread count configurable
    "]:::note
    classDef note fill:#fff,stroke:#333,stroke-dasharray: 5 5
```
