# tlemane/kmindex architecture

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

- Interactive diagram: https://gitdiagram.com/tlemane/kmindex
- Repository: https://github.com/tlemane/kmindex

## Overview

kmindex builds and queries k-mer indexes for sequencing datasets, reporting shared-k-mer results; its findere-style query uses (s+z)-mers to reduce false positives. The CLI also supports index registration, merging, metadata, compression, and summarized indexes. A separate HTTP server exposes query and index-information endpoints, with a Python client for synchronous or asynchronous requests. The excerpts show the ordinary query’s FASTX batching and index solving, and the server’s routes; several other CLI capabilities are documented by the command registry but their implementations were not sampled, so their internal links are omitted.

Main entry points: [`app/kmindex/cli.hpp`](https://github.com/tlemane/kmindex/blob/main/app/kmindex/cli.hpp) (Command registry), [`lib/src/index/index.cpp`](https://github.com/tlemane/kmindex/blob/main/lib/src/index/index.cpp) (Global index), [`app/kmindex/query.cpp`](https://github.com/tlemane/kmindex/blob/main/app/kmindex/query.cpp) (FASTX query), [`app/kmindex/query2.cpp`](https://github.com/tlemane/kmindex/blob/main/app/kmindex/query2.cpp) (Multi-index query)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_cli["CLI workflows"]
  node_cli_entry["CLI entry<br/>[main.cpp]"]
  node_command_registry["Command registry<br/>[cli.hpp]"]
  node_index_build["Index build<br/>[build.hpp]"]
  node_query_workflow["FASTX query<br/>[query.cpp]"]
  node_multi_query["Multi-index query<br/>[query2.cpp]"]
  node_summary_workflows["Summary indexes<br/>[query_sum.cpp]"]
  node_index_management["Index management"]
end

subgraph group_engine["Index and query engine"]
  node_index_catalog["Index catalog<br/>[index_infos.cpp]"]
  node_global_index["Global index<br/>[index.cpp]"]
  node_kmer_index["K-mer index<br/>[kindex.cpp]"]
  node_query_engine["Query engine<br/>[query.cpp]"]
  node_query_results["Result formatting<br/>[query_results.cpp]"]
  node_summary_index["Summary index<br/>[sum_index.hpp]"]
end

subgraph group_service["HTTP service"]
  node_http_server["HTTP server<br/>[server.cpp]"]
  node_http_request["Request handling<br/>[request.hpp]"]
end

subgraph group_client["Python client"]
  node_python_api["Python API client<br/>[server.py]"]
  node_python_queries["Query payloads<br/>[query.py]"]
end

node_user(("Sequencing user"))
node_http_user(("HTTP client"))

node_user -->|"runs"| node_cli_entry
node_cli_entry -->|"parses commands"| node_command_registry
node_command_registry -->|"registers build"| node_index_build
node_command_registry -->|"registers query"| node_query_workflow
node_command_registry -->|"registers query2"| node_multi_query
node_command_registry -->|"registers sum query"| node_summary_workflows
node_user -->|"sends requests"| node_http_server
node_http_server -->|"dispatches POST"| node_http_request
node_http_server -->|"loads index"| node_global_index
node_python_api -->|"uses payloads"| node_python_queries
node_http_user -->|"submits queries"| node_python_api
node_query_workflow -->|"solves batches"| node_kmer_index
node_query_workflow -->|"formats results"| node_query_results
node_multi_query -->|"loads and merges"| node_global_index
node_multi_query -->|"queries batches"| node_query_engine
node_summary_workflows -->|"searches partitions"| node_summary_index
node_index_build -.->|"builds index"| node_global_index
node_index_management -.->|"manages indexes"| node_global_index
node_http_request -.->|"solves request"| node_query_engine

click node_cli_entry "https://github.com/tlemane/kmindex/blob/main/app/kmindex/main.cpp"
click node_command_registry "https://github.com/tlemane/kmindex/blob/main/app/kmindex/cli.hpp"
click node_index_build "https://github.com/tlemane/kmindex/blob/main/app/kmindex/build.hpp"
click node_query_workflow "https://github.com/tlemane/kmindex/blob/main/app/kmindex/query.cpp"
click node_multi_query "https://github.com/tlemane/kmindex/blob/main/app/kmindex/query2.cpp"
click node_summary_workflows "https://github.com/tlemane/kmindex/blob/main/app/kmindex/query_sum.cpp"
click node_index_management "https://github.com/tlemane/kmindex/tree/main/app/kmindex"
click node_index_catalog "https://github.com/tlemane/kmindex/blob/main/lib/src/index/index_infos.cpp"
click node_global_index "https://github.com/tlemane/kmindex/blob/main/lib/src/index/index.cpp"
click node_kmer_index "https://github.com/tlemane/kmindex/blob/main/lib/src/index/kindex.cpp"
click node_query_engine "https://github.com/tlemane/kmindex/blob/main/lib/src/query/query.cpp"
click node_query_results "https://github.com/tlemane/kmindex/blob/main/lib/src/query/query_results.cpp"
click node_summary_index "https://github.com/tlemane/kmindex/blob/main/lib/include/kmindex/index/sum_index.hpp"
click node_http_server "https://github.com/tlemane/kmindex/blob/main/app/kmindex-server/server.cpp"
click node_http_request "https://github.com/tlemane/kmindex/blob/main/app/kmindex-server/request.hpp"
click node_python_api "https://github.com/tlemane/kmindex/blob/main/pykmindex/pykmindex/server.py"
click node_python_queries "https://github.com/tlemane/kmindex/blob/main/pykmindex/pykmindex/query.py"

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_cli_entry,node_command_registry,node_index_build,node_query_workflow,node_multi_query,node_summary_workflows,node_index_management,node_user,node_http_user toneBlue
class node_index_catalog,node_global_index,node_kmer_index,node_query_engine,node_query_results,node_summary_index toneAmber
class node_http_server,node_http_request toneMint
class node_python_api,node_python_queries toneRose
```

## Components

### CLI workflows

- [CLI entry](https://github.com/tlemane/kmindex/blob/main/app/kmindex/main.cpp): `app/kmindex/main.cpp`
- [Command registry](https://github.com/tlemane/kmindex/blob/main/app/kmindex/cli.hpp): `app/kmindex/cli.hpp`
- [Index build](https://github.com/tlemane/kmindex/blob/main/app/kmindex/build.hpp): `app/kmindex/build.hpp`
- [FASTX query](https://github.com/tlemane/kmindex/blob/main/app/kmindex/query.cpp): `app/kmindex/query.cpp`
- [Multi-index query](https://github.com/tlemane/kmindex/blob/main/app/kmindex/query2.cpp): `app/kmindex/query2.cpp`
- [Summary indexes](https://github.com/tlemane/kmindex/blob/main/app/kmindex/query_sum.cpp): `app/kmindex/query_sum.cpp`
- [Index management](https://github.com/tlemane/kmindex/tree/main/app/kmindex): `app/kmindex`

### Index and query engine

- [Index catalog](https://github.com/tlemane/kmindex/blob/main/lib/src/index/index_infos.cpp): `lib/src/index/index_infos.cpp`
- [Global index](https://github.com/tlemane/kmindex/blob/main/lib/src/index/index.cpp): `lib/src/index/index.cpp`
- [K-mer index](https://github.com/tlemane/kmindex/blob/main/lib/src/index/kindex.cpp): `lib/src/index/kindex.cpp`
- [Query engine](https://github.com/tlemane/kmindex/blob/main/lib/src/query/query.cpp): `lib/src/query/query.cpp`
- [Result formatting](https://github.com/tlemane/kmindex/blob/main/lib/src/query/query_results.cpp): `lib/src/query/query_results.cpp`
- [Summary index](https://github.com/tlemane/kmindex/blob/main/lib/include/kmindex/index/sum_index.hpp): `lib/include/kmindex/index/sum_index.hpp`

### HTTP service

- [HTTP server](https://github.com/tlemane/kmindex/blob/main/app/kmindex-server/server.cpp): `app/kmindex-server/server.cpp`
- [Request handling](https://github.com/tlemane/kmindex/blob/main/app/kmindex-server/request.hpp): `app/kmindex-server/request.hpp`

### Python client

- [Python API client](https://github.com/tlemane/kmindex/blob/main/pykmindex/pykmindex/server.py): `pykmindex/pykmindex/server.py`
- [Query payloads](https://github.com/tlemane/kmindex/blob/main/pykmindex/pykmindex/query.py): `pykmindex/pykmindex/query.py`

### Other components

- **Sequencing user**
- **HTTP client**

## Connections

- Sequencing user → CLI entry: runs
- CLI entry → Command registry: parses commands (evidence: `app/kmindex/main.cpp`)
- Command registry → Index build: registers build (evidence: `app/kmindex/cli.hpp`)
- Command registry → FASTX query: registers query (evidence: `app/kmindex/cli.hpp`)
- Command registry → Multi-index query: registers query2 (evidence: `app/kmindex/cli.hpp`)
- Command registry → Summary indexes: registers sum query (evidence: `app/kmindex/cli.hpp`)
- Sequencing user → HTTP server: sends requests
- HTTP server → Request handling: dispatches POST (evidence: `app/kmindex-server/server.cpp`)
- HTTP server → Global index: loads index (evidence: `app/kmindex-server/server.cpp`)
- Python API client → Query payloads: uses payloads (evidence: `pykmindex/pykmindex/server.py`)
- HTTP client → Python API client: submits queries (evidence: `pykmindex/pykmindex/server.py`)
- FASTX query → K-mer index: solves batches (evidence: `app/kmindex/query.cpp`)
- FASTX query → Result formatting: formats results (evidence: `app/kmindex/query.cpp`)
- Multi-index query → Global index: loads and merges (evidence: `app/kmindex/query2.cpp`)
- Multi-index query → Query engine: queries batches (evidence: `app/kmindex/query2.cpp`)
- Summary indexes → Summary index: searches partitions (evidence: `app/kmindex/query_sum.cpp`)
- Index build → Global index: builds index
- Index management → Global index: manages indexes
- Request handling → Query engine: solves request
