# pathwaycom/serviette architecture

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

- Interactive diagram: https://gitdiagram.com/pathwaycom/serviette
- Repository: https://github.com/pathwaycom/serviette

## Overview

Serviette is a live RAG service: configured document sources are parsed, chunked and embedded into a selected vector store; a separate API retrieves and ranks passages, then can generate cited answers. The README documents multiple source types, multimodal parsing, eight database backends, a chat UI and REST API. Source excerpts show the indexer graph and server components, but omit some wiring, so edges for documented product behavior cite the README; unsampled implementation details are not inferred.

Main entry points: [`serviette/server/main.py`](https://github.com/pathwaycom/serviette/blob/main/serviette/server/main.py) (API server), [`serviette/indexer/graph.py`](https://github.com/pathwaycom/serviette/blob/main/serviette/indexer/graph.py) (Indexing graph), [`serviette/server/accessors/abstract.py`](https://github.com/pathwaycom/serviette/blob/main/serviette/server/accessors/abstract.py) (Vector accessors), [`serviette/cli.py`](https://github.com/pathwaycom/serviette/blob/main/serviette/cli.py) (CLI)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_setup["Configuration and entrypoints"]
  node_config["Config schema<br/>[schema.py]"]
  node_cli["CLI<br/>[cli.py]"]
  node_indexer["Indexer entrypoint<br/>[main.py]"]
end

subgraph group_indexing["Live indexing"]
  node_source["Document sources<br/>[sources.py]"]
  node_graph["Indexing graph<br/>[graph.py]"]
  node_fingerprint["Config fingerprint<br/>[fingerprint.py]"]
  node_prepare["Backend preparation<br/>[prepare.py]"]
end

subgraph group_storage["Vector storage"]
  node_store[("Vector database")]
  node_accessor["Vector accessors<br/>[abstract.py]"]
  node_duckdb["DuckDB accessor<br/>[duckdb.py]"]
  node_otherdb["Other DB adapters"]
end

subgraph group_serving["Retrieval and answers"]
  node_server["API server<br/>[main.py]"]
  node_embedder["Query embedder<br/>[embedder.py]"]
  node_hybrid["Hybrid retrieval<br/>[hybrid.py]"]
  node_ranking["Result ranking<br/>[ranking.py]"]
  node_decompose["Query decomposition<br/>[decompose.py]"]
  node_llm["Answer generation<br/>[llm.py]"]
  node_reranker["Reranking<br/>[reranker.py]"]
  node_documents["Document operations<br/>[documents.py]"]
end

subgraph group_interface["User interfaces"]
  node_chat["Web chat UI<br/>[main.py]"]
end

node_user(("Operator / user"))
node_browser(("Browser"))

node_user -->|"configures and runs"| node_cli
node_cli -->|"loads config"| node_config
node_cli -->|"starts indexer"| node_indexer
node_user -->|"provides documents"| node_source
node_indexer -->|"builds graph"| node_graph
node_indexer -->|"prepares backend"| node_prepare
node_graph -->|"watches and fetches"| node_source
node_graph -->|"uses identity"| node_fingerprint
node_graph -->|"writes live updates"| node_store
node_prepare -->|"creates targets"| node_store
node_store -->|"serves indexed data"| node_accessor
node_accessor -->|"implemented by"| node_duckdb
node_accessor -->|"implemented by"| node_otherdb
node_server -->|"queries store"| node_accessor
node_server -->|"embeds queries"| node_embedder
node_server -->|"decomposes queries"| node_decompose
node_server -->|"retrieves passages"| node_hybrid
node_hybrid -->|"fuses results"| node_ranking
node_server -->|"reranks results"| node_reranker
node_server -->|"generates answers"| node_llm
node_server -->|"serves document operations"| node_documents
node_browser -->|"uses chat"| node_chat
node_chat -->|"proxies API requests"| node_server
node_browser -->|"calls REST API"| node_server

click node_config "https://github.com/pathwaycom/serviette/blob/main/serviette/config/schema.py"
click node_cli "https://github.com/pathwaycom/serviette/blob/main/serviette/cli.py"
click node_indexer "https://github.com/pathwaycom/serviette/blob/main/serviette/indexer/main.py"
click node_source "https://github.com/pathwaycom/serviette/blob/main/serviette/indexer/sources.py"
click node_graph "https://github.com/pathwaycom/serviette/blob/main/serviette/indexer/graph.py"
click node_fingerprint "https://github.com/pathwaycom/serviette/blob/main/serviette/indexer/fingerprint.py"
click node_prepare "https://github.com/pathwaycom/serviette/blob/main/serviette/indexer/prepare.py"
click node_store "https://github.com/pathwaycom/serviette/tree/main/serviette/server/accessors"
click node_accessor "https://github.com/pathwaycom/serviette/blob/main/serviette/server/accessors/abstract.py"
click node_duckdb "https://github.com/pathwaycom/serviette/blob/main/serviette/server/accessors/duckdb.py"
click node_otherdb "https://github.com/pathwaycom/serviette/tree/main/serviette/server/accessors"
click node_server "https://github.com/pathwaycom/serviette/blob/main/serviette/server/main.py"
click node_embedder "https://github.com/pathwaycom/serviette/blob/main/serviette/server/embedder.py"
click node_hybrid "https://github.com/pathwaycom/serviette/blob/main/serviette/server/hybrid.py"
click node_ranking "https://github.com/pathwaycom/serviette/blob/main/serviette/server/ranking.py"
click node_decompose "https://github.com/pathwaycom/serviette/blob/main/serviette/server/decompose.py"
click node_llm "https://github.com/pathwaycom/serviette/blob/main/serviette/server/llm.py"
click node_reranker "https://github.com/pathwaycom/serviette/blob/main/serviette/server/reranker.py"
click node_documents "https://github.com/pathwaycom/serviette/blob/main/serviette/server/documents.py"
click node_chat "https://github.com/pathwaycom/serviette/blob/main/serviette/frontend/main.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_config,node_cli,node_indexer,node_user,node_browser toneBlue
class node_source,node_graph,node_fingerprint,node_prepare toneAmber
class node_store,node_accessor,node_duckdb,node_otherdb toneMint
class node_server,node_embedder,node_hybrid,node_ranking,node_decompose,node_llm,node_reranker,node_documents toneRose
class node_chat toneIndigo
```

## Components

### Configuration and entrypoints

- [Config schema](https://github.com/pathwaycom/serviette/blob/main/serviette/config/schema.py): `serviette/config/schema.py`
- [CLI](https://github.com/pathwaycom/serviette/blob/main/serviette/cli.py): `serviette/cli.py`
- [Indexer entrypoint](https://github.com/pathwaycom/serviette/blob/main/serviette/indexer/main.py): `serviette/indexer/main.py`

### Live indexing

- [Document sources](https://github.com/pathwaycom/serviette/blob/main/serviette/indexer/sources.py): `serviette/indexer/sources.py`
- [Indexing graph](https://github.com/pathwaycom/serviette/blob/main/serviette/indexer/graph.py): `serviette/indexer/graph.py`
- [Config fingerprint](https://github.com/pathwaycom/serviette/blob/main/serviette/indexer/fingerprint.py): `serviette/indexer/fingerprint.py`
- [Backend preparation](https://github.com/pathwaycom/serviette/blob/main/serviette/indexer/prepare.py): `serviette/indexer/prepare.py`

### Vector storage

- [Vector database](https://github.com/pathwaycom/serviette/tree/main/serviette/server/accessors): `serviette/server/accessors`
- [Vector accessors](https://github.com/pathwaycom/serviette/blob/main/serviette/server/accessors/abstract.py): `serviette/server/accessors/abstract.py`
- [DuckDB accessor](https://github.com/pathwaycom/serviette/blob/main/serviette/server/accessors/duckdb.py): `serviette/server/accessors/duckdb.py`
- [Other DB adapters](https://github.com/pathwaycom/serviette/tree/main/serviette/server/accessors): `serviette/server/accessors`

### Retrieval and answers

- [API server](https://github.com/pathwaycom/serviette/blob/main/serviette/server/main.py): `serviette/server/main.py`
- [Query embedder](https://github.com/pathwaycom/serviette/blob/main/serviette/server/embedder.py): `serviette/server/embedder.py`
- [Hybrid retrieval](https://github.com/pathwaycom/serviette/blob/main/serviette/server/hybrid.py): `serviette/server/hybrid.py`
- [Result ranking](https://github.com/pathwaycom/serviette/blob/main/serviette/server/ranking.py): `serviette/server/ranking.py`
- [Query decomposition](https://github.com/pathwaycom/serviette/blob/main/serviette/server/decompose.py): `serviette/server/decompose.py`
- [Answer generation](https://github.com/pathwaycom/serviette/blob/main/serviette/server/llm.py): `serviette/server/llm.py`
- [Reranking](https://github.com/pathwaycom/serviette/blob/main/serviette/server/reranker.py): `serviette/server/reranker.py`
- [Document operations](https://github.com/pathwaycom/serviette/blob/main/serviette/server/documents.py): `serviette/server/documents.py`

### User interfaces

- [Web chat UI](https://github.com/pathwaycom/serviette/blob/main/serviette/frontend/main.py): `serviette/frontend/main.py`

### Other components

- **Operator / user**
- **Browser**

## Connections

- Operator / user → CLI: configures and runs (evidence: `README.md`)
- CLI → Config schema: loads config (evidence: `serviette/cli.py`)
- CLI → Indexer entrypoint: starts indexer (evidence: `serviette/cli.py`)
- Operator / user → Document sources: provides documents (evidence: `README.md`)
- Indexer entrypoint → Indexing graph: builds graph (evidence: `serviette/indexer/main.py`)
- Indexer entrypoint → Backend preparation: prepares backend (evidence: `serviette/indexer/main.py`)
- Indexing graph → Document sources: watches and fetches (evidence: `README.md`)
- Indexing graph → Config fingerprint: uses identity (evidence: `serviette/indexer/graph.py`)
- Indexing graph → Vector database: writes live updates (evidence: `README.md`)
- Backend preparation → Vector database: creates targets (evidence: `serviette/indexer/prepare.py`)
- Vector database → Vector accessors: serves indexed data (evidence: `README.md`)
- Vector accessors → DuckDB accessor: implemented by (evidence: `serviette/server/accessors/duckdb.py`)
- Vector accessors → Other DB adapters: implemented by (evidence: `serviette/server/accessors/__init__.py`)
- API server → Vector accessors: queries store (evidence: `serviette/server/main.py`)
- API server → Query embedder: embeds queries (evidence: `serviette/server/main.py`)
- API server → Query decomposition: decomposes queries (evidence: `serviette/server/main.py`)
- API server → Hybrid retrieval: retrieves passages
- Hybrid retrieval → Result ranking: fuses results (evidence: `serviette/server/hybrid.py`)
- API server → Reranking: reranks results (evidence: `serviette/server/main.py`)
- API server → Answer generation: generates answers (evidence: `serviette/server/main.py`)
- API server → Document operations: serves document operations (evidence: `serviette/server/main.py`)
- Browser → Web chat UI: uses chat (evidence: `serviette/frontend/main.py`)
- Web chat UI → API server: proxies API requests (evidence: `serviette/frontend/main.py`)
- Browser → API server: calls REST API (evidence: `README.md`)
