# lrj021029/audiokb architecture

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

- Interactive diagram: https://gitdiagram.com/lrj021029/audiokb
- Repository: https://github.com/lrj021029/audiokb

## Overview

This is an audiobook knowledge-base service: users submit documents for ingestion, then query the indexed content for answers, recommendations, or book details. HTTP endpoints start import and query graph workflows; the import graph processes documents into searchable chunks, while the query graph coordinates retrieval and response generation. The graph preserves documented import and query stages, plus persistence and model/vector-store infrastructure. Some implementation files were not sampled, so their internal calls are omitted rather than inferred.

Main entry points: [`app/process/query/agent/main_graph.py`](https://github.com/lrj021029/audiokb/blob/main/app/process/query/agent/main_graph.py) (Query workflow), [`app/process/import_/agent/main_graph.py`](https://github.com/lrj021029/audiokb/blob/main/app/process/import_/agent/main_graph.py) (Import workflow), [`app/rag/query/embedding_search_service.py`](https://github.com/lrj021029/audiokb/blob/main/app/rag/query/embedding_search_service.py) (Vector retrieval), [`app/api/http/query_server.py`](https://github.com/lrj021029/audiokb/blob/main/app/api/http/query_server.py) (Query endpoints)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["HTTP API"]
  node_import_api["Import endpoints<br/>[import_server.py]"]
  node_query_api["Query endpoints<br/>[query_server.py]"]
end

subgraph group_ingest["Knowledge Ingestion"]
  node_import_graph["Import workflow<br/>[main_graph.py]"]
  node_document_entry["Document entry<br/>[node_entry.py]"]
  node_pdf_parse["PDF conversion<br/>[node_pdf2md.py]"]
  node_image_enrichment["Image enrichment<br/>[node_md_img.py]"]
  node_document_split["Document splitting"]
  node_item_recognition["Item recognition"]
  node_metadata_extract["Metadata extraction"]
  node_chunk_embedding["Chunk embeddings"]
  node_index_import["Vector indexing"]
  node_app_rag_entry["Import entry service<br/>[entry_service.py]"]
  node_app_rag_images["Image enrichment service"]
  node_app_rag_split["Split service<br/>[split_service.py]"]
  node_app_rag_item["Item name service"]
  node_app_rag_metadata["Metadata service"]
  node_app_rag_embedding["Embedding service"]
  node_app_rag_index["Index service<br/>[index_service.py]"]
end

subgraph group_query["Query and Discovery"]
  node_query_graph["Query workflow<br/>[main_graph.py]"]
  node_query_entry["Query entry"]
  node_intent["Intent classification"]
  node_vector_search["Vector retrieval"]
  node_hyde_search["HyDE retrieval"]
  node_rrf["Rank fusion<br/>[node_rrf.py]"]
  node_rerank["Result reranking<br/>[rerank_service.py]"]
  node_answer["Answer generation<br/>[answer_service.py]"]
  node_recommend["Book recommendations"]
  node_book_detail["Book details"]
end

subgraph group_infra["Models and Storage"]
  node_llm_provider["Model provider<br/>[providers.py]"]
  node_milvus_gateway["Milvus gateway<br/>[milvus_gateway.py]"]
  node_milvus[("Milvus vector store<br/>[milvus_utils.py]")]
  node_history_repo["History repository"]
  node_mongo_history[("Mongo history client")]
end

node_user(("API client"))

node_user -->|"submits documents"| node_import_api
node_user -->|"sends queries"| node_query_api
node_import_api -->|"starts workflow"| node_import_graph
node_query_api -->|"invokes workflow"| node_query_graph
node_import_graph -->|"dispatches"| node_document_entry
node_import_graph -->|"dispatches"| node_pdf_parse
node_import_graph -->|"dispatches"| node_image_enrichment
node_import_graph -->|"dispatches"| node_document_split
node_import_graph -->|"dispatches"| node_item_recognition
node_import_graph -->|"dispatches"| node_metadata_extract
node_import_graph -->|"dispatches"| node_chunk_embedding
node_import_graph -->|"dispatches"| node_index_import
node_document_entry -->|"delegates to"| node_app_rag_entry
node_image_enrichment -->|"delegates to"| node_app_rag_images
node_document_split -->|"delegates to"| node_app_rag_split
node_item_recognition -->|"delegates to"| node_app_rag_item
node_metadata_extract -.->|"delegates to"| node_app_rag_metadata
node_chunk_embedding -->|"delegates to"| node_app_rag_embedding
node_index_import -->|"delegates to"| node_app_rag_index
node_query_graph -->|"dispatches"| node_query_entry
node_query_graph -->|"dispatches"| node_intent
node_query_graph -->|"dispatches"| node_vector_search
node_query_graph -->|"dispatches"| node_hyde_search
node_query_graph -->|"dispatches"| node_rrf
node_query_graph -->|"dispatches"| node_rerank
node_query_graph -->|"dispatches"| node_answer
node_query_graph -->|"dispatches"| node_recommend
node_query_graph -->|"dispatches"| node_book_detail
node_vector_search -->|"embeds query"| node_llm_provider
node_vector_search -->|"searches vectors"| node_milvus_gateway
node_hyde_search -->|"generates and embeds"| node_llm_provider
node_hyde_search -->|"reuses search"| node_vector_search
node_answer -->|"generates response"| node_llm_provider
node_answer -->|"persists messages"| node_history_repo
node_query_api -->|"reads or clears history"| node_history_repo
node_history_repo -->|"delegates persistence"| node_mongo_history
node_milvus_gateway -->|"uses client"| node_milvus

click node_import_api "https://github.com/lrj021029/audiokb/blob/main/app/api/http/import_server.py"
click node_query_api "https://github.com/lrj021029/audiokb/blob/main/app/api/http/query_server.py"
click node_import_graph "https://github.com/lrj021029/audiokb/blob/main/app/process/import_/agent/main_graph.py"
click node_document_entry "https://github.com/lrj021029/audiokb/blob/main/app/process/import_/agent/nodes/node_entry.py"
click node_pdf_parse "https://github.com/lrj021029/audiokb/blob/main/app/process/import_/agent/nodes/node_pdf2md.py"
click node_image_enrichment "https://github.com/lrj021029/audiokb/blob/main/app/process/import_/agent/nodes/node_md_img.py"
click node_document_split "https://github.com/lrj021029/audiokb/blob/main/app/process/import_/agent/nodes/node_document_split.py"
click node_item_recognition "https://github.com/lrj021029/audiokb/blob/main/app/process/import_/agent/nodes/node_item_name_recognition.py"
click node_metadata_extract "https://github.com/lrj021029/audiokb/blob/main/app/process/import_/agent/nodes/node_metadata_extract.py"
click node_chunk_embedding "https://github.com/lrj021029/audiokb/blob/main/app/process/import_/agent/nodes/node_bge_embedding.py"
click node_index_import "https://github.com/lrj021029/audiokb/blob/main/app/process/import_/agent/nodes/node_import_milvus.py"
click node_query_graph "https://github.com/lrj021029/audiokb/blob/main/app/process/query/agent/main_graph.py"
click node_query_entry "https://github.com/lrj021029/audiokb/blob/main/app/process/query/agent/nodes/node_query_entry.py"
click node_intent "https://github.com/lrj021029/audiokb/blob/main/app/process/query/agent/nodes/node_intent_classify.py"
click node_vector_search "https://github.com/lrj021029/audiokb/blob/main/app/rag/query/embedding_search_service.py"
click node_hyde_search "https://github.com/lrj021029/audiokb/blob/main/app/rag/query/hyde_search_service.py"
click node_rrf "https://github.com/lrj021029/audiokb/blob/main/app/process/query/agent/nodes/node_rrf.py"
click node_rerank "https://github.com/lrj021029/audiokb/blob/main/app/rag/query/rerank_service.py"
click node_answer "https://github.com/lrj021029/audiokb/blob/main/app/rag/query/answer_service.py"
click node_recommend "https://github.com/lrj021029/audiokb/blob/main/app/rag/query/book_recommend_service.py"
click node_book_detail "https://github.com/lrj021029/audiokb/blob/main/app/rag/query/book_detail_service.py"
click node_llm_provider "https://github.com/lrj021029/audiokb/blob/main/app/infra/llm/providers.py"
click node_milvus_gateway "https://github.com/lrj021029/audiokb/blob/main/app/infra/vectorstore/milvus_gateway.py"
click node_milvus "https://github.com/lrj021029/audiokb/blob/main/app/shared/clients/milvus_utils.py"
click node_history_repo "https://github.com/lrj021029/audiokb/blob/main/app/infra/persistence/history_repository.py"
click node_mongo_history "https://github.com/lrj021029/audiokb/blob/main/app/shared/clients/mongo_history_utils.py"
click node_app_rag_entry "https://github.com/lrj021029/audiokb/blob/main/app/rag/import_/entry_service.py"
click node_app_rag_images "https://github.com/lrj021029/audiokb/blob/main/app/rag/import_/enrich_markdown_images.py"
click node_app_rag_split "https://github.com/lrj021029/audiokb/blob/main/app/rag/import_/split_service.py"
click node_app_rag_item "https://github.com/lrj021029/audiokb/blob/main/app/rag/import_/item_name_service.py"
click node_app_rag_metadata "https://github.com/lrj021029/audiokb/blob/main/app/rag/import_/metadata_extract_service.py"
click node_app_rag_embedding "https://github.com/lrj021029/audiokb/blob/main/app/rag/import_/embedding_service.py"
click node_app_rag_index "https://github.com/lrj021029/audiokb/blob/main/app/rag/import_/index_service.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_import_api,node_query_api,node_user toneBlue
class node_import_graph,node_document_entry,node_pdf_parse,node_image_enrichment,node_document_split,node_item_recognition,node_metadata_extract,node_chunk_embedding,node_index_import,node_app_rag_entry,node_app_rag_images,node_app_rag_split,node_app_rag_item,node_app_rag_metadata,node_app_rag_embedding,node_app_rag_index toneAmber
class node_query_graph,node_query_entry,node_intent,node_vector_search,node_hyde_search,node_rrf,node_rerank,node_answer,node_recommend,node_book_detail toneMint
class node_llm_provider,node_milvus_gateway,node_milvus,node_history_repo,node_mongo_history toneRose
```

## Components

### HTTP API

- [Import endpoints](https://github.com/lrj021029/audiokb/blob/main/app/api/http/import_server.py): `app/api/http/import_server.py`
- [Query endpoints](https://github.com/lrj021029/audiokb/blob/main/app/api/http/query_server.py): `app/api/http/query_server.py`

### Knowledge Ingestion

- [Import workflow](https://github.com/lrj021029/audiokb/blob/main/app/process/import_/agent/main_graph.py): `app/process/import_/agent/main_graph.py`
- [Document entry](https://github.com/lrj021029/audiokb/blob/main/app/process/import_/agent/nodes/node_entry.py): `app/process/import_/agent/nodes/node_entry.py`
- [PDF conversion](https://github.com/lrj021029/audiokb/blob/main/app/process/import_/agent/nodes/node_pdf2md.py): `app/process/import_/agent/nodes/node_pdf2md.py`
- [Image enrichment](https://github.com/lrj021029/audiokb/blob/main/app/process/import_/agent/nodes/node_md_img.py): `app/process/import_/agent/nodes/node_md_img.py`
- [Document splitting](https://github.com/lrj021029/audiokb/blob/main/app/process/import_/agent/nodes/node_document_split.py): `app/process/import_/agent/nodes/node_document_split.py`
- [Item recognition](https://github.com/lrj021029/audiokb/blob/main/app/process/import_/agent/nodes/node_item_name_recognition.py): `app/process/import_/agent/nodes/node_item_name_recognition.py`
- [Metadata extraction](https://github.com/lrj021029/audiokb/blob/main/app/process/import_/agent/nodes/node_metadata_extract.py): `app/process/import_/agent/nodes/node_metadata_extract.py`
- [Chunk embeddings](https://github.com/lrj021029/audiokb/blob/main/app/process/import_/agent/nodes/node_bge_embedding.py): `app/process/import_/agent/nodes/node_bge_embedding.py`
- [Vector indexing](https://github.com/lrj021029/audiokb/blob/main/app/process/import_/agent/nodes/node_import_milvus.py): `app/process/import_/agent/nodes/node_import_milvus.py`
- [Import entry service](https://github.com/lrj021029/audiokb/blob/main/app/rag/import_/entry_service.py): `app/rag/import_/entry_service.py`
- [Image enrichment service](https://github.com/lrj021029/audiokb/blob/main/app/rag/import_/enrich_markdown_images.py): `app/rag/import_/enrich_markdown_images.py`
- [Split service](https://github.com/lrj021029/audiokb/blob/main/app/rag/import_/split_service.py): `app/rag/import_/split_service.py`
- [Item name service](https://github.com/lrj021029/audiokb/blob/main/app/rag/import_/item_name_service.py): `app/rag/import_/item_name_service.py`
- [Metadata service](https://github.com/lrj021029/audiokb/blob/main/app/rag/import_/metadata_extract_service.py): `app/rag/import_/metadata_extract_service.py`
- [Embedding service](https://github.com/lrj021029/audiokb/blob/main/app/rag/import_/embedding_service.py): `app/rag/import_/embedding_service.py`
- [Index service](https://github.com/lrj021029/audiokb/blob/main/app/rag/import_/index_service.py): `app/rag/import_/index_service.py`

### Query and Discovery

- [Query workflow](https://github.com/lrj021029/audiokb/blob/main/app/process/query/agent/main_graph.py): `app/process/query/agent/main_graph.py`
- [Query entry](https://github.com/lrj021029/audiokb/blob/main/app/process/query/agent/nodes/node_query_entry.py): `app/process/query/agent/nodes/node_query_entry.py`
- [Intent classification](https://github.com/lrj021029/audiokb/blob/main/app/process/query/agent/nodes/node_intent_classify.py): `app/process/query/agent/nodes/node_intent_classify.py`
- [Vector retrieval](https://github.com/lrj021029/audiokb/blob/main/app/rag/query/embedding_search_service.py): `app/rag/query/embedding_search_service.py`
- [HyDE retrieval](https://github.com/lrj021029/audiokb/blob/main/app/rag/query/hyde_search_service.py): `app/rag/query/hyde_search_service.py`
- [Rank fusion](https://github.com/lrj021029/audiokb/blob/main/app/process/query/agent/nodes/node_rrf.py): `app/process/query/agent/nodes/node_rrf.py`
- [Result reranking](https://github.com/lrj021029/audiokb/blob/main/app/rag/query/rerank_service.py): `app/rag/query/rerank_service.py`
- [Answer generation](https://github.com/lrj021029/audiokb/blob/main/app/rag/query/answer_service.py): `app/rag/query/answer_service.py`
- [Book recommendations](https://github.com/lrj021029/audiokb/blob/main/app/rag/query/book_recommend_service.py): `app/rag/query/book_recommend_service.py`
- [Book details](https://github.com/lrj021029/audiokb/blob/main/app/rag/query/book_detail_service.py): `app/rag/query/book_detail_service.py`

### Models and Storage

- [Model provider](https://github.com/lrj021029/audiokb/blob/main/app/infra/llm/providers.py): `app/infra/llm/providers.py`
- [Milvus gateway](https://github.com/lrj021029/audiokb/blob/main/app/infra/vectorstore/milvus_gateway.py): `app/infra/vectorstore/milvus_gateway.py`
- [Milvus vector store](https://github.com/lrj021029/audiokb/blob/main/app/shared/clients/milvus_utils.py): `app/shared/clients/milvus_utils.py`
- [History repository](https://github.com/lrj021029/audiokb/blob/main/app/infra/persistence/history_repository.py): `app/infra/persistence/history_repository.py`
- [Mongo history client](https://github.com/lrj021029/audiokb/blob/main/app/shared/clients/mongo_history_utils.py): `app/shared/clients/mongo_history_utils.py`

### Other components

- **API client**

## Connections

- API client → Import endpoints: submits documents (evidence: `app/api/http/import_server.py`)
- API client → Query endpoints: sends queries (evidence: `app/api/http/query_server.py`)
- Import endpoints → Import workflow: starts workflow (evidence: `app/api/http/import_server.py`)
- Query endpoints → Query workflow: invokes workflow (evidence: `app/api/http/query_server.py`)
- Import workflow → Document entry: dispatches (evidence: `app/process/import_/agent/main_graph.py`)
- Import workflow → PDF conversion: dispatches (evidence: `app/process/import_/agent/main_graph.py`)
- Import workflow → Image enrichment: dispatches (evidence: `app/process/import_/agent/main_graph.py`)
- Import workflow → Document splitting: dispatches (evidence: `app/process/import_/agent/main_graph.py`)
- Import workflow → Item recognition: dispatches (evidence: `app/process/import_/agent/main_graph.py`)
- Import workflow → Metadata extraction: dispatches (evidence: `app/process/import_/agent/main_graph.py`)
- Import workflow → Chunk embeddings: dispatches (evidence: `app/process/import_/agent/main_graph.py`)
- Import workflow → Vector indexing: dispatches (evidence: `app/process/import_/agent/main_graph.py`)
- Document entry → Import entry service: delegates to (evidence: `app/process/import_/agent/nodes/node_entry.py`)
- Image enrichment → Image enrichment service: delegates to (evidence: `app/process/import_/agent/nodes/node_md_img.py`)
- Document splitting → Split service: delegates to (evidence: `app/process/import_/agent/nodes/node_document_split.py`)
- Item recognition → Item name service: delegates to (evidence: `app/process/import_/agent/nodes/node_item_name_recognition.py`)
- Metadata extraction → Metadata service: delegates to
- Chunk embeddings → Embedding service: delegates to (evidence: `app/process/import_/agent/nodes/node_bge_embedding.py`)
- Vector indexing → Index service: delegates to (evidence: `app/process/import_/agent/nodes/node_import_milvus.py`)
- Query workflow → Query entry: dispatches (evidence: `app/process/query/agent/main_graph.py`)
- Query workflow → Intent classification: dispatches (evidence: `app/process/query/agent/main_graph.py`)
- Query workflow → Vector retrieval: dispatches (evidence: `app/process/query/agent/main_graph.py`)
- Query workflow → HyDE retrieval: dispatches (evidence: `app/process/query/agent/main_graph.py`)
- Query workflow → Rank fusion: dispatches (evidence: `app/process/query/agent/main_graph.py`)
- Query workflow → Result reranking: dispatches (evidence: `app/process/query/agent/main_graph.py`)
- Query workflow → Answer generation: dispatches (evidence: `app/process/query/agent/main_graph.py`)
- Query workflow → Book recommendations: dispatches (evidence: `app/process/query/agent/main_graph.py`)
- Query workflow → Book details: dispatches (evidence: `app/process/query/agent/main_graph.py`)
- Vector retrieval → Model provider: embeds query (evidence: `app/rag/query/embedding_search_service.py`)
- Vector retrieval → Milvus gateway: searches vectors (evidence: `app/rag/query/embedding_search_service.py`)
- HyDE retrieval → Model provider: generates and embeds (evidence: `app/rag/query/hyde_search_service.py`)
- HyDE retrieval → Vector retrieval: reuses search (evidence: `app/rag/query/hyde_search_service.py`)
- Answer generation → Model provider: generates response (evidence: `app/rag/query/answer_service.py`)
- Answer generation → History repository: persists messages (evidence: `app/rag/query/answer_service.py`)
- Query endpoints → History repository: reads or clears history (evidence: `app/api/http/query_server.py`)
- History repository → Mongo history client: delegates persistence (evidence: `app/infra/persistence/history_repository.py`)
- Milvus gateway → Milvus vector store: uses client (evidence: `app/infra/vectorstore/milvus_gateway.py`)
