# ldele/doc_assistant architecture

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

- Interactive diagram: https://gitdiagram.com/ldele/doc_assistant
- Repository: https://github.com/ldele/doc_assistant

## Overview

Provenote is a local-first research assistant for searching a personal document library, producing cited answers, and examining answer quality. The main workflow runs from adding documents through indexing, hybrid retrieval, reranking, and answer synthesis to citation inspection and optional review. The desktop client talks to a FastAPI/SSE backend; SQLite and Chroma hold document and vector data. The README documents the broader ingestion and capability branches; unsampled implementation details are represented at subsystem level rather than inferred call-by-call.

Main entry points: [`src/doc_assistant/ingest/__init__.py`](https://github.com/ldele/doc_assistant/blob/main/src/doc_assistant/ingest/__init__.py) (Ingest runner), [`apps/desktop/src/App.svelte`](https://github.com/ldele/doc_assistant/blob/main/apps/desktop/src/App.svelte) (Desktop workspace), [`src/doc_assistant/chat_controller/controller.py`](https://github.com/ldele/doc_assistant/blob/main/src/doc_assistant/chat_controller/controller.py) (Chat orchestration), [`src/doc_assistant/pipeline.py`](https://github.com/ldele/doc_assistant/blob/main/src/doc_assistant/pipeline.py) (Retrieve and synthesize)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Desktop and API"]
  node_desktop["Desktop workspace<br/>[App.svelte]"]
  node_api["FastAPI service<br/>[main.py]"]
  node_api_services["API job services<br/>[services.py]"]
end

subgraph group_ingest["Document ingestion"]
  node_ingest_entry["Ingest runner<br/>[__init__.py]"]
  node_extractors["Format extraction<br/>[extractors.py]"]
  node_ingest_registry["Ingest registry<br/>[registry.py]"]
  node_ingest_cache["Extraction cache<br/>[cache.py]"]
  node_embedding["Embedding models<br/>[embeddings.py]"]
  node_figure_sidecar["Figure sidecar<br/>[figures.py]"]
end

subgraph group_answer["Question answering"]
  node_chat["Chat orchestration<br/>[controller.py]"]
  node_rag["Retrieve and synthesize<br/>[pipeline.py]"]
  node_llm["LLM providers<br/>[llm.py]"]
  node_provenance["Answer provenance<br/>[provenance.py]"]
  node_chroma[("Chroma vectors")]
end

subgraph group_library["Library and knowledge"]
  node_library_data["Library data access<br/>[__init__.py]"]
  node_sqlite[("SQLite records<br/>[session.py]")]
  node_db_models["Document models<br/>[models.py]"]
  node_add_documents["Document import<br/>[add.py]"]
  node_catalogue["Zotero catalogue<br/>[catalogue.py]"]
  node_knowledge["Concept graph and gaps"]
end

subgraph group_quality["Quality and review"]
  node_reviewer["Answer reviewer<br/>[reviewer.py]"]
  node_eval["Evaluation harness<br/>[runner.py]"]
end

node_researcher(("Researcher"))

node_researcher -->|"uses"| node_desktop
node_desktop -->|"requests"| node_api
node_api -->|"wires jobs"| node_api_services
node_api_services -->|"runs ingest"| node_ingest_entry
node_ingest_entry -.->|"extracts formats"| node_extractors
node_ingest_entry -.->|"registers ingestion"| node_ingest_registry
node_ingest_entry -.->|"caches extraction"| node_ingest_cache
node_ingest_entry -.->|"builds vectors"| node_embedding
node_embedding -.->|"writes vectors"| node_chroma
node_ingest_entry -.->|"stores documents"| node_sqlite
node_ingest_entry -.->|"derives figures"| node_figure_sidecar
node_desktop -.->|"starts chat"| node_chat
node_chat -->|"retrieves and streams"| node_rag
node_rag -->|"retrieves vectors"| node_chroma
node_rag -.->|"generates answers"| node_llm
node_chat -.->|"records provenance"| node_provenance
node_desktop -.->|"browses library"| node_library_data
node_library_data -.->|"reads and writes"| node_sqlite
node_sqlite -.->|"maps records"| node_db_models
node_desktop -.->|"adds documents"| node_add_documents
node_add_documents -.->|"imports Zotero"| node_catalogue
node_desktop -.->|"explores concepts"| node_knowledge
node_chat -.->|"flags for review"| node_reviewer
node_eval -.->|"evaluates pipeline"| node_rag

click node_desktop "https://github.com/ldele/doc_assistant/blob/main/apps/desktop/src/App.svelte"
click node_api "https://github.com/ldele/doc_assistant/blob/main/apps/api/main.py"
click node_api_services "https://github.com/ldele/doc_assistant/blob/main/apps/api/services.py"
click node_ingest_entry "https://github.com/ldele/doc_assistant/blob/main/src/doc_assistant/ingest/__init__.py"
click node_extractors "https://github.com/ldele/doc_assistant/blob/main/src/doc_assistant/extractors.py"
click node_ingest_registry "https://github.com/ldele/doc_assistant/blob/main/src/doc_assistant/ingest/registry.py"
click node_ingest_cache "https://github.com/ldele/doc_assistant/blob/main/src/doc_assistant/ingest/cache.py"
click node_embedding "https://github.com/ldele/doc_assistant/blob/main/src/doc_assistant/embeddings.py"
click node_figure_sidecar "https://github.com/ldele/doc_assistant/blob/main/src/doc_assistant/ingest/figures.py"
click node_chat "https://github.com/ldele/doc_assistant/blob/main/src/doc_assistant/chat_controller/controller.py"
click node_rag "https://github.com/ldele/doc_assistant/blob/main/src/doc_assistant/pipeline.py"
click node_llm "https://github.com/ldele/doc_assistant/blob/main/src/doc_assistant/llm.py"
click node_provenance "https://github.com/ldele/doc_assistant/blob/main/src/doc_assistant/provenance.py"
click node_library_data "https://github.com/ldele/doc_assistant/blob/main/src/doc_assistant/library/__init__.py"
click node_sqlite "https://github.com/ldele/doc_assistant/blob/main/src/doc_assistant/db/session.py"
click node_db_models "https://github.com/ldele/doc_assistant/blob/main/src/doc_assistant/db/models.py"
click node_add_documents "https://github.com/ldele/doc_assistant/blob/main/src/doc_assistant/library/add.py"
click node_catalogue "https://github.com/ldele/doc_assistant/blob/main/src/doc_assistant/adapters/catalogue.py"
click node_knowledge "https://github.com/ldele/doc_assistant/blob/main/src/doc_assistant/knowledge/concept_skeleton.py"
click node_reviewer "https://github.com/ldele/doc_assistant/blob/main/src/doc_assistant/reviewer.py"
click node_eval "https://github.com/ldele/doc_assistant/blob/main/src/doc_assistant/eval/runner.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_desktop,node_api,node_api_services toneBlue
class node_ingest_entry,node_extractors,node_ingest_registry,node_ingest_cache,node_embedding,node_figure_sidecar toneAmber
class node_chat,node_rag,node_llm,node_provenance,node_chroma toneMint
class node_library_data,node_sqlite,node_db_models,node_add_documents,node_catalogue,node_knowledge toneRose
class node_reviewer,node_eval,node_researcher toneIndigo
```

## Components

### Desktop and API

- [Desktop workspace](https://github.com/ldele/doc_assistant/blob/main/apps/desktop/src/App.svelte): `apps/desktop/src/App.svelte`
- [FastAPI service](https://github.com/ldele/doc_assistant/blob/main/apps/api/main.py): `apps/api/main.py`
- [API job services](https://github.com/ldele/doc_assistant/blob/main/apps/api/services.py): `apps/api/services.py`

### Document ingestion

- [Ingest runner](https://github.com/ldele/doc_assistant/blob/main/src/doc_assistant/ingest/__init__.py): `src/doc_assistant/ingest/__init__.py`
- [Format extraction](https://github.com/ldele/doc_assistant/blob/main/src/doc_assistant/extractors.py): `src/doc_assistant/extractors.py`
- [Ingest registry](https://github.com/ldele/doc_assistant/blob/main/src/doc_assistant/ingest/registry.py): `src/doc_assistant/ingest/registry.py`
- [Extraction cache](https://github.com/ldele/doc_assistant/blob/main/src/doc_assistant/ingest/cache.py): `src/doc_assistant/ingest/cache.py`
- [Embedding models](https://github.com/ldele/doc_assistant/blob/main/src/doc_assistant/embeddings.py): `src/doc_assistant/embeddings.py`
- [Figure sidecar](https://github.com/ldele/doc_assistant/blob/main/src/doc_assistant/ingest/figures.py): `src/doc_assistant/ingest/figures.py`

### Question answering

- [Chat orchestration](https://github.com/ldele/doc_assistant/blob/main/src/doc_assistant/chat_controller/controller.py): `src/doc_assistant/chat_controller/controller.py`
- [Retrieve and synthesize](https://github.com/ldele/doc_assistant/blob/main/src/doc_assistant/pipeline.py): `src/doc_assistant/pipeline.py`
- [LLM providers](https://github.com/ldele/doc_assistant/blob/main/src/doc_assistant/llm.py): `src/doc_assistant/llm.py`
- [Answer provenance](https://github.com/ldele/doc_assistant/blob/main/src/doc_assistant/provenance.py): `src/doc_assistant/provenance.py`
- **Chroma vectors**

### Library and knowledge

- [Library data access](https://github.com/ldele/doc_assistant/blob/main/src/doc_assistant/library/__init__.py): `src/doc_assistant/library/__init__.py`
- [SQLite records](https://github.com/ldele/doc_assistant/blob/main/src/doc_assistant/db/session.py): `src/doc_assistant/db/session.py`
- [Document models](https://github.com/ldele/doc_assistant/blob/main/src/doc_assistant/db/models.py): `src/doc_assistant/db/models.py`
- [Document import](https://github.com/ldele/doc_assistant/blob/main/src/doc_assistant/library/add.py): `src/doc_assistant/library/add.py`
- [Zotero catalogue](https://github.com/ldele/doc_assistant/blob/main/src/doc_assistant/adapters/catalogue.py): `src/doc_assistant/adapters/catalogue.py`
- [Concept graph and gaps](https://github.com/ldele/doc_assistant/blob/main/src/doc_assistant/knowledge/concept_skeleton.py): `src/doc_assistant/knowledge/concept_skeleton.py`

### Quality and review

- [Answer reviewer](https://github.com/ldele/doc_assistant/blob/main/src/doc_assistant/reviewer.py): `src/doc_assistant/reviewer.py`
- [Evaluation harness](https://github.com/ldele/doc_assistant/blob/main/src/doc_assistant/eval/runner.py): `src/doc_assistant/eval/runner.py`

### Other components

- **Researcher**

## Connections

- Researcher → Desktop workspace: uses (evidence: `README.md`)
- Desktop workspace → FastAPI service: requests (evidence: `README.md`)
- FastAPI service → API job services: wires jobs (evidence: `apps/api/main.py`)
- API job services → Ingest runner: runs ingest (evidence: `apps/api/services.py`)
- Ingest runner → Format extraction: extracts formats (evidence: `README.md`)
- Ingest runner → Ingest registry: registers ingestion (evidence: `README.md`)
- Ingest runner → Extraction cache: caches extraction (evidence: `README.md`)
- Ingest runner → Embedding models: builds vectors (evidence: `README.md`)
- Embedding models → Chroma vectors: writes vectors (evidence: `README.md`)
- Ingest runner → SQLite records: stores documents (evidence: `README.md`)
- Ingest runner → Figure sidecar: derives figures (evidence: `README.md`)
- Desktop workspace → Chat orchestration: starts chat (evidence: `README.md`)
- Chat orchestration → Retrieve and synthesize: retrieves and streams (evidence: `src/doc_assistant/chat_controller/controller.py`)
- Retrieve and synthesize → Chroma vectors: retrieves vectors (evidence: `README.md`)
- Retrieve and synthesize → LLM providers: generates answers (evidence: `README.md`)
- Chat orchestration → Answer provenance: records provenance (evidence: `README.md`)
- Desktop workspace → Library data access: browses library (evidence: `README.md`)
- Library data access → SQLite records: reads and writes (evidence: `src/doc_assistant/library/__init__.py`)
- SQLite records → Document models: maps records (evidence: `src/doc_assistant/db/session.py`)
- Desktop workspace → Document import: adds documents (evidence: `README.md`)
- Document import → Zotero catalogue: imports Zotero
- Desktop workspace → Concept graph and gaps: explores concepts (evidence: `README.md`)
- Chat orchestration → Answer reviewer: flags for review (evidence: `README.md`)
- Evaluation harness → Retrieve and synthesize: evaluates pipeline (evidence: `README.md`)
