# feliziris/early-io-hnsw architecture

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

- Interactive diagram: https://gitdiagram.com/feliziris/early-io-hnsw
- Repository: https://github.com/feliziris/early-io-hnsw

## Overview

Faiss is a C++ library, with Python/NumPy and C interfaces, for dense-vector similarity search and clustering. A typical workflow is to train or configure an index, add identified vectors, then search with L2 or dot-product similarity; index families trade search speed, quality, and memory, and may store compressed vectors or graph structures. The README documents CPU and optional GPU search, while the source index identifies additional tuning, persistence, and distributed-search capabilities. Several subsystem links below are dashed because their implementation call paths were not sampled.

Main entry points: [`faiss/Index.cpp`](https://github.com/feliziris/early-io-hnsw/blob/main/faiss/Index.cpp) (Index interface), [`faiss/gpu/GpuIndex.h`](https://github.com/feliziris/early-io-hnsw/blob/main/faiss/gpu/GpuIndex.h) (GPU indexes), [`benchs/distributed_ondisk/search_server.py`](https://github.com/feliziris/early-io-hnsw/blob/main/benchs/distributed_ondisk/search_server.py) (Distributed search), [`faiss/python/class_wrappers.py`](https://github.com/feliziris/early-io-hnsw/blob/main/faiss/python/class_wrappers.py) (Python wrappers)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interfaces["Language interfaces"]
  node_python["Python wrappers<br/>[class_wrappers.py]"]
  node_c_api["C API<br/>[IndexIVF_c.h]"]
end

subgraph group_indexing["Index families"]
  node_index_core["Index interface<br/>[Index.cpp]"]
  node_flat["Exact flat indexes<br/>[IndexFlat.cpp]"]
  node_ivf["IVF indexes<br/>[IndexIVF.cpp]"]
  node_graph["Graph indexes<br/>[IndexHNSW.cpp]"]
  node_binary["Binary indexes<br/>[IndexBinary.cpp]"]
  node_quantized["Quantized indexes<br/>[IndexPQ.cpp]"]
  node_transforms["Vector transforms"]
  node_factory["Index factory<br/>[index_factory.cpp]"]
end

subgraph group_search["Search internals"]
  node_invlists[("Inverted lists<br/>[InvertedLists.cpp]")]
  node_distance["Distance kernels<br/>[distances.cpp]"]
  node_result["Result selection<br/>[ResultHandler.h]"]
  node_cpu_search["CPU search<br/>[Index.cpp]"]
end

subgraph group_platform["Execution platforms"]
  node_gpu["GPU indexes<br/>[GpuIndex.h]"]
  node_gpu_resources["GPU resources"]
end

subgraph group_operations["Operations and extensions"]
  node_clustering["Clustering<br/>[Clustering.cpp]"]
  node_persistence["Index persistence<br/>[index_write.cpp]"]
  node_autotune["Parameter tuning<br/>[AutoTune.cpp]"]
  node_rpc["RPC transport<br/>[rpc.py]"]
  node_distributed["Distributed search<br/>[search_server.py]"]
end

node_caller(("Application"))

node_caller -.->|"uses API"| node_python
node_caller -.->|"uses API"| node_c_api
node_python -.->|"exposes indexes"| node_index_core
node_c_api -.->|"exposes indexes"| node_index_core
node_factory -.->|"creates indexes"| node_index_core
node_index_core -.->|"supports exact search"| node_flat
node_index_core -.->|"supports approximate search"| node_ivf
node_index_core -.->|"supports graph search"| node_graph
node_index_core -.->|"supports binary search"| node_binary
node_index_core -.->|"supports compressed search"| node_quantized
node_transforms -.->|"wraps indexes"| node_index_core
node_clustering -.->|"trains indexes"| node_index_core
node_ivf -.->|"stores postings"| node_invlists
node_cpu_search -.->|"computes distances"| node_distance
node_cpu_search -.->|"selects neighbors"| node_result
node_cpu_search -.->|"searches indexes"| node_index_core
node_gpu -.->|"uses resources"| node_gpu_resources
node_gpu -.->|"accelerates search"| node_index_core
node_persistence -.->|"serializes indexes"| node_index_core
node_autotune -.->|"tunes parameters"| node_index_core
node_distributed -->|"serves requests"| node_rpc
node_distributed -.->|"combines postings"| node_invlists

click node_python "https://github.com/feliziris/early-io-hnsw/blob/main/faiss/python/class_wrappers.py"
click node_c_api "https://github.com/feliziris/early-io-hnsw/blob/main/c_api/IndexIVF_c.h"
click node_index_core "https://github.com/feliziris/early-io-hnsw/blob/main/faiss/Index.cpp"
click node_flat "https://github.com/feliziris/early-io-hnsw/blob/main/faiss/IndexFlat.cpp"
click node_ivf "https://github.com/feliziris/early-io-hnsw/blob/main/faiss/IndexIVF.cpp"
click node_graph "https://github.com/feliziris/early-io-hnsw/blob/main/faiss/IndexHNSW.cpp"
click node_binary "https://github.com/feliziris/early-io-hnsw/blob/main/faiss/IndexBinary.cpp"
click node_quantized "https://github.com/feliziris/early-io-hnsw/blob/main/faiss/IndexPQ.cpp"
click node_transforms "https://github.com/feliziris/early-io-hnsw/blob/main/faiss/VectorTransform.cpp"
click node_factory "https://github.com/feliziris/early-io-hnsw/blob/main/faiss/index_factory.cpp"
click node_clustering "https://github.com/feliziris/early-io-hnsw/blob/main/faiss/Clustering.cpp"
click node_invlists "https://github.com/feliziris/early-io-hnsw/blob/main/faiss/invlists/InvertedLists.cpp"
click node_distance "https://github.com/feliziris/early-io-hnsw/blob/main/faiss/utils/distances.cpp"
click node_result "https://github.com/feliziris/early-io-hnsw/blob/main/faiss/impl/ResultHandler.h"
click node_cpu_search "https://github.com/feliziris/early-io-hnsw/blob/main/faiss/Index.cpp"
click node_gpu "https://github.com/feliziris/early-io-hnsw/blob/main/faiss/gpu/GpuIndex.h"
click node_gpu_resources "https://github.com/feliziris/early-io-hnsw/blob/main/faiss/gpu/StandardGpuResources.cpp"
click node_persistence "https://github.com/feliziris/early-io-hnsw/blob/main/faiss/impl/index_write.cpp"
click node_autotune "https://github.com/feliziris/early-io-hnsw/blob/main/faiss/AutoTune.cpp"
click node_rpc "https://github.com/feliziris/early-io-hnsw/blob/main/contrib/rpc.py"
click node_distributed "https://github.com/feliziris/early-io-hnsw/blob/main/benchs/distributed_ondisk/search_server.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_python,node_c_api toneBlue
class node_index_core,node_flat,node_ivf,node_graph,node_binary,node_quantized,node_transforms,node_factory toneAmber
class node_invlists,node_distance,node_result,node_cpu_search toneMint
class node_gpu,node_gpu_resources toneRose
class node_clustering,node_persistence,node_autotune,node_rpc,node_distributed,node_caller toneIndigo
```

## Components

### Language interfaces

- [Python wrappers](https://github.com/feliziris/early-io-hnsw/blob/main/faiss/python/class_wrappers.py): `faiss/python/class_wrappers.py`
- [C API](https://github.com/feliziris/early-io-hnsw/blob/main/c_api/IndexIVF_c.h): `c_api/IndexIVF_c.h`

### Index families

- [Index interface](https://github.com/feliziris/early-io-hnsw/blob/main/faiss/Index.cpp): `faiss/Index.cpp`
- [Exact flat indexes](https://github.com/feliziris/early-io-hnsw/blob/main/faiss/IndexFlat.cpp): `faiss/IndexFlat.cpp`
- [IVF indexes](https://github.com/feliziris/early-io-hnsw/blob/main/faiss/IndexIVF.cpp): `faiss/IndexIVF.cpp`
- [Graph indexes](https://github.com/feliziris/early-io-hnsw/blob/main/faiss/IndexHNSW.cpp): `faiss/IndexHNSW.cpp`
- [Binary indexes](https://github.com/feliziris/early-io-hnsw/blob/main/faiss/IndexBinary.cpp): `faiss/IndexBinary.cpp`
- [Quantized indexes](https://github.com/feliziris/early-io-hnsw/blob/main/faiss/IndexPQ.cpp): `faiss/IndexPQ.cpp`
- [Vector transforms](https://github.com/feliziris/early-io-hnsw/blob/main/faiss/VectorTransform.cpp): `faiss/VectorTransform.cpp`
- [Index factory](https://github.com/feliziris/early-io-hnsw/blob/main/faiss/index_factory.cpp): `faiss/index_factory.cpp`

### Search internals

- [Inverted lists](https://github.com/feliziris/early-io-hnsw/blob/main/faiss/invlists/InvertedLists.cpp): `faiss/invlists/InvertedLists.cpp`
- [Distance kernels](https://github.com/feliziris/early-io-hnsw/blob/main/faiss/utils/distances.cpp): `faiss/utils/distances.cpp`
- [Result selection](https://github.com/feliziris/early-io-hnsw/blob/main/faiss/impl/ResultHandler.h): `faiss/impl/ResultHandler.h`
- [CPU search](https://github.com/feliziris/early-io-hnsw/blob/main/faiss/Index.cpp): `faiss/Index.cpp`

### Execution platforms

- [GPU indexes](https://github.com/feliziris/early-io-hnsw/blob/main/faiss/gpu/GpuIndex.h): `faiss/gpu/GpuIndex.h`
- [GPU resources](https://github.com/feliziris/early-io-hnsw/blob/main/faiss/gpu/StandardGpuResources.cpp): `faiss/gpu/StandardGpuResources.cpp`

### Operations and extensions

- [Clustering](https://github.com/feliziris/early-io-hnsw/blob/main/faiss/Clustering.cpp): `faiss/Clustering.cpp`
- [Index persistence](https://github.com/feliziris/early-io-hnsw/blob/main/faiss/impl/index_write.cpp): `faiss/impl/index_write.cpp`
- [Parameter tuning](https://github.com/feliziris/early-io-hnsw/blob/main/faiss/AutoTune.cpp): `faiss/AutoTune.cpp`
- [RPC transport](https://github.com/feliziris/early-io-hnsw/blob/main/contrib/rpc.py): `contrib/rpc.py`
- [Distributed search](https://github.com/feliziris/early-io-hnsw/blob/main/benchs/distributed_ondisk/search_server.py): `benchs/distributed_ondisk/search_server.py`

### Other components

- **Application**

## Connections

- Application → Python wrappers: uses API (evidence: `README.md`)
- Application → C API: uses API (evidence: `README.md`)
- Python wrappers → Index interface: exposes indexes (evidence: `README.md`)
- C API → Index interface: exposes indexes (evidence: `c_api/IndexIVF_c.h`)
- Index factory → Index interface: creates indexes (evidence: `README.md`)
- Index interface → Exact flat indexes: supports exact search (evidence: `README.md`)
- Index interface → IVF indexes: supports approximate search (evidence: `README.md`)
- Index interface → Graph indexes: supports graph search (evidence: `README.md`)
- Index interface → Binary indexes: supports binary search (evidence: `README.md`)
- Index interface → Quantized indexes: supports compressed search (evidence: `README.md`)
- Vector transforms → Index interface: wraps indexes
- Clustering → Index interface: trains indexes (evidence: `README.md`)
- IVF indexes → Inverted lists: stores postings
- CPU search → Distance kernels: computes distances (evidence: `README.md`)
- CPU search → Result selection: selects neighbors (evidence: `faiss/impl/ResultHandler.h`)
- CPU search → Index interface: searches indexes (evidence: `README.md`)
- GPU indexes → GPU resources: uses resources (evidence: `faiss/gpu/StandardGpuResources.cpp`)
- GPU indexes → Index interface: accelerates search (evidence: `README.md`)
- Index persistence → Index interface: serializes indexes
- Parameter tuning → Index interface: tunes parameters (evidence: `README.md`)
- Distributed search → RPC transport: serves requests (evidence: `benchs/distributed_ondisk/search_server.py`)
- Distributed search → Inverted lists: combines postings
