# sam-sims/kractor architecture

> Architecture diagram of the GitHub repository sam-sims/kractor, 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/kractor
- Repository: https://github.com/sam-sims/kractor

## Overview

##### Main Components

a) Input Processing Layer:
- FASTQ/FASTA file handlers (supporting .gz and .bz2 compression)
- Kraken2 output parser
- Kraken2 report parser (optional)

b) Core Processing Layer:
- Taxonomic Classification Processor
- Read Extraction Engine
- Parent/Child Taxonomy Handler

c) Output Processing Layer:
- FASTQ/FASTA Writers
- Compression Handler
- JSON Report Generator

**[Input Layer] -> [Processing Layer] -> [Output Layer]**

##### Specific Elements

a) Input Components (Left side):
- FASTQ/FASTA Input (with compression support)
- Kraken2 Output

b) Core Processing (Center):
- Read ID Matcher
- Taxonomy Processor (for parent/child relationships)
- Extraction Logic

c) Output Components (Right side):
- Parallel output channels:
- FASTQ/FASTA Output (with compression options)
- JSON Report Output

##### Important Flows to Highlight

- How the paired-end reads flow through the system
- Where compression/decompression occurs
- Taxonomic classification process
- Optional parent/child taxonomy processing

##### Additional Details

- File format support (.fastq, .fasta, .gz, .bz2)
- Compression levels (1-9)
- Optional features (parent/child taxonomy, exclusion)

##### Technical Specifications

A technical notes section showing:
- Built with Rust
- CLI-based interface
- Supported platforms (Linux, MacOS, Windows)
- Docker support

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Styles
    classDef input fill:#a8d1f0,stroke:#333
    classDef process fill:#90EE90,stroke:#333
    classDef output fill:#FFB347,stroke:#333
    classDef optional stroke-dasharray: 5 5
    classDef container fill:#d3d3d3,stroke:#333
    classDef ci fill:#f0e68c,stroke:#333

    %% Input Layer
    subgraph Input
        FASTQ["FASTQ/FASTA Input\n(.gz, .bz2)"]:::input
        KrakenOut["Kraken2 Output"]:::input
        KrakenReport["Kraken2 Report"]:::input
    end

    %% Core Processing Layer
    subgraph Processing
        CLI["Command Line Interface"]:::process
        Core["Core Application Logic"]:::process
        ReadMatcher["Read ID Matcher"]:::process
        TaxProcessor["Taxonomy Processor"]:::process
        ExtractEngine["Extraction Engine"]:::process
    end

    %% Output Layer
    subgraph Output
        FastqOut["FASTQ/FASTA Output\n(.gz, .bz2)"]:::output
        JsonReport["JSON Report"]:::output
    end

    %% Infrastructure Components
    subgraph Infrastructure
        Docker["Container Runtime"]:::container
        CI["CI/CD Pipeline"]:::ci
        Deps["Dependencies"]:::process
        Bench["Performance Benchmarks"]:::process
    end

    %% Connections
    FASTQ --> CLI
    KrakenOut --> CLI
    KrakenReport -.-> CLI
    CLI --> Core
    Core --> ReadMatcher
    ReadMatcher --> TaxProcessor
    TaxProcessor --> ExtractEngine
    ExtractEngine --> FastqOut
    ExtractEngine --> JsonReport

    %% Infrastructure Connections
    Core --> Docker
    Docker --> CI
    Deps --> Core
    Core --> Bench

    %% Click Events
    click CLI "https://github.com/Sam-Sims/kractor/blob/main/src/cli.rs"
    click Core "https://github.com/Sam-Sims/kractor/blob/main/src/main.rs"
    click Deps "https://github.com/Sam-Sims/kractor/blob/main/Cargo.toml"
    click Bench "https://github.com/Sam-Sims/kractor/blob/main/benchmarks/benchmarks.md"
    click Docker "https://github.com/Sam-Sims/kractor/tree/main/Dockerfile"
    click CI "https://github.com/Sam-Sims/kractor/blob/main/.github/workflows/release.yaml"

    %% Legend
    subgraph Legend
        L1["Input Files"]:::input
        L2["Processing"]:::process
        L3["Output Files"]:::output
        L4["Optional Flow"]:::optional
        L5["Infrastructure"]:::container
        L6["CI/CD"]:::ci
    end
```
