# bioinformatics-centre/kaiju architecture

> Architecture diagram of the GitHub repository bioinformatics-centre/kaiju, 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/bioinformatics-centre/kaiju
- Repository: https://github.com/bioinformatics-centre/kaiju

## Overview

##### Main Components Identification

The system should be divided into these primary components:

a) Input Processing Layer
- Supports FASTQ/FASTA formats (including gzip-compressed)
- Handles both single-end and paired-end reads
- Input validation and preprocessing

b) Core Processing Engine
- BWT/FM-Index Search Component
- Translation Engine (6 reading frames)
- Classification Engine (Greedy and MEM modes)
- Multi-threading Component

c) Database Management
- Index Creation System
- Reference Database Handler
- NCBI Taxonomy Integration

d) Output Processing Layer
- Results Formatter
- Summary Generation
- Integration with External Tools (like Krona)

##### Component Relationships

**[Input Files] → [Input Processing Layer]**
- ↓
**[Reference DB] → [Database Management] → [BWT/FM-Index]**
- ↓                      ↓
- [Core Processing Engine] ← [Taxonomy Data]
- ↓
- [Output Processing Layer]
- ↓
**[Output Files] ← [Results & Visualization]**

##### Detailed Component Breakdown

**[Read Translation] → [Sequence Matching]**
- ↓                    ↓
**[SEG Filtering] ← [Score Calculation] → [Taxonomic Assignment]**

Database Management (right side):
**[NCBI Taxonomy] → [nodes.dmp/names.dmp]**
- ↓
**[Reference DB] → [BWT Creation] → [FM-Index]**

##### Implementation Details

- Memory management for large-scale processing
- File I/O points and compression handling
- Integration points with NCBI BLAST+ components

##### Technical Specifications

- Memory requirements for different databases
- Threading capabilities
- File format specifications
- Version compatibility

##### Integration Points

Connections to:
- NCBI taxonomy database
- Krona visualization tool
- Custom database integration points
- External tool interfaces

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Input
        IF[("Input Files")]
        IPL["Input Processing Layer"]:::input
    end

    subgraph Core
        CPE["Core Processing Engine"]:::core
        BWT["BWT/FM-Index Search"]:::core
        TE["Translation Engine"]:::core
        CE["Classification Engine"]:::core
        MT["Multi-threading"]:::core
    end

    subgraph Database
        DM["Database Management"]:::db
        IC["Index Creation"]:::db
        RH["Reference DB Handler"]:::db
        TI["NCBI Taxonomy Integration"]:::db
    end

    subgraph Output
        OPL["Output Processing Layer"]:::output
        RF["Results Formatter"]:::output
        SG["Summary Generator"]:::output
        KI["Krona Integration"]:::output
        OF[("Output Files")]
    end

    IF --> IPL
    IPL --> CPE

    CPE --> BWT
    CPE --> TE
    CPE --> CE
    CPE --> MT

    DM --> IC
    DM --> RH
    DM --> TI
    DM --> CPE

    CPE --> OPL
    OPL --> RF
    OPL --> SG
    OPL --> KI
    RF --> OF
    SG --> OF
    KI --> OF

    %% Click Events
    click CPE "https://github.com/bioinformatics-centre/kaiju/blob/master/src/kaiju.cpp"
    click IPL "https://github.com/bioinformatics-centre/kaiju/blob/master/src/ReadItem.cpp"
    click MT "https://github.com/bioinformatics-centre/kaiju/blob/master/src/ConsumerThread.cpp"
    click BWT "https://github.com/bioinformatics-centre/kaiju/tree/master/src/bwt/"
    click DM "https://github.com/bioinformatics-centre/kaiju/tree/master/util/kaiju-makedb"
    click RF "https://github.com/bioinformatics-centre/kaiju/blob/master/src/kaiju2table.cpp"
    click KI "https://github.com/bioinformatics-centre/kaiju/blob/master/src/kaiju2krona.cpp"

    %% Styles
    classDef core fill:#90EE90,stroke:#333,stroke-width:2px
    classDef input fill:#ADD8E6,stroke:#333,stroke-width:2px
    classDef db fill:#FFD700,stroke:#333,stroke-width:2px
    classDef output fill:#FFA07A,stroke:#333,stroke-width:2px

    %% Legend
    subgraph Legend
        L1["Core Components"]:::core
        L2["Input Processing"]:::input
        L3["Database Components"]:::db
        L4["Output Processing"]:::output
    end
```
