# honeybadger-rex/advance-rag architecture

> Architecture diagram of the GitHub repository honeybadger-rex/advance-rag, 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/honeybadger-rex/advance-rag
- Repository: https://github.com/honeybadger-rex/advance-rag

## Overview

This is a PDF question-answering RAG application: users upload a document, then ask questions answered from its contents. The backend loads and chunks PDFs, embeds and persists chunks, retrieves and reranks relevant passages, evaluates retrieval quality, optionally tries corrective retrieval, then builds context and generates an answer. The graph includes the React interface and the backend’s distinct processing stages. The README is empty; frontend upload wiring is not visible in the excerpt, so that connection is left unverified.

Main entry points: [`src/main.py`](https://github.com/honeybadger-rex/advance-rag/blob/main/src/main.py) (FastAPI endpoints), [`frontend/src/App.jsx`](https://github.com/honeybadger-rex/advance-rag/blob/main/frontend/src/App.jsx) (RAG interface), [`src/retrieval/retriever.py`](https://github.com/honeybadger-rex/advance-rag/blob/main/src/retrieval/retriever.py) (Vector retrieval), [`src/indexing/vector_storage.py`](https://github.com/honeybadger-rex/advance-rag/blob/main/src/indexing/vector_storage.py) (FAISS indexing)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["Web interface"]
  node_frontend["RAG interface<br/>[App.jsx]"]
end

subgraph group_api["API orchestration"]
  node_api["FastAPI endpoints<br/>[main.py]"]
end

subgraph group_ingest["Document indexing"]
  node_loader["PDF loading<br/>[loader.py]"]
  node_chunker["Text chunking<br/>[chunker.py]"]
  node_embedding["Text embeddings<br/>[embedding.py]"]
  node_indexing["FAISS indexing<br/>[vector_storage.py]"]
  node_vectorstore[("Index and chunks")]
end

subgraph group_search["Retrieval and evaluation"]
  node_retriever["Vector retrieval<br/>[retriever.py]"]
  node_reranker["Result reranking<br/>[reranker.py]"]
  node_evaluation["Retrieval evaluation"]
  node_correction["Corrective reranking"]
  node_corrective_retrieval["Query expansion"]
end

subgraph group_answer["Answer generation"]
  node_context["Context assembly<br/>[context_builder.py]"]
  node_generator["Answer generation<br/>[genrater.py]"]
end

node_user(("User"))

node_user -->|"uses"| node_frontend
node_frontend -->|"posts question"| node_api
node_frontend -.->|"uploads PDF"| node_api
node_api -->|"loads PDF"| node_loader
node_api -->|"chunks pages"| node_chunker
node_api -->|"embeds chunks"| node_embedding
node_api -->|"builds and saves"| node_indexing
node_indexing -->|"writes index and chunks"| node_vectorstore
node_api -->|"retrieves passages"| node_retriever
node_api -->|"reranks results"| node_reranker
node_api -->|"evaluates results"| node_evaluation
node_api -->|"requests correction"| node_correction
node_correction -.->|"uses query expansion"| node_corrective_retrieval
node_api -->|"builds context"| node_context
node_api -->|"generates answer"| node_generator
node_retriever -->|"reads index and chunks"| node_vectorstore
node_corrective_retrieval -->|"repeats retrieval"| node_retriever
node_generator -.->|"uses context builder"| node_context

click node_frontend "https://github.com/honeybadger-rex/advance-rag/blob/main/frontend/src/App.jsx"
click node_api "https://github.com/honeybadger-rex/advance-rag/blob/main/src/main.py"
click node_loader "https://github.com/honeybadger-rex/advance-rag/blob/main/src/ingestion/loader.py"
click node_chunker "https://github.com/honeybadger-rex/advance-rag/blob/main/src/ingestion/chunker.py"
click node_embedding "https://github.com/honeybadger-rex/advance-rag/blob/main/src/indexing/embedding.py"
click node_indexing "https://github.com/honeybadger-rex/advance-rag/blob/main/src/indexing/vector_storage.py"
click node_vectorstore "https://github.com/honeybadger-rex/advance-rag/tree/main/src/vector_store"
click node_retriever "https://github.com/honeybadger-rex/advance-rag/blob/main/src/retrieval/retriever.py"
click node_reranker "https://github.com/honeybadger-rex/advance-rag/blob/main/src/retrieval/reranker.py"
click node_evaluation "https://github.com/honeybadger-rex/advance-rag/blob/main/src/evaluator/evaluate_retrieval.py"
click node_correction "https://github.com/honeybadger-rex/advance-rag/blob/main/src/evaluator/corrective_reranking.py"
click node_corrective_retrieval "https://github.com/honeybadger-rex/advance-rag/blob/main/src/evaluator/coracttive_retrieval.py"
click node_context "https://github.com/honeybadger-rex/advance-rag/blob/main/src/generation/context_builder.py"
click node_generator "https://github.com/honeybadger-rex/advance-rag/blob/main/src/generation/genrater.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_frontend,node_user toneBlue
class node_api toneAmber
class node_loader,node_chunker,node_embedding,node_indexing,node_vectorstore toneMint
class node_retriever,node_reranker,node_evaluation,node_correction,node_corrective_retrieval toneRose
class node_context,node_generator toneIndigo
```

## Components

### Web interface

- [RAG interface](https://github.com/honeybadger-rex/advance-rag/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`

### API orchestration

- [FastAPI endpoints](https://github.com/honeybadger-rex/advance-rag/blob/main/src/main.py): `src/main.py`

### Document indexing

- [PDF loading](https://github.com/honeybadger-rex/advance-rag/blob/main/src/ingestion/loader.py): `src/ingestion/loader.py`
- [Text chunking](https://github.com/honeybadger-rex/advance-rag/blob/main/src/ingestion/chunker.py): `src/ingestion/chunker.py`
- [Text embeddings](https://github.com/honeybadger-rex/advance-rag/blob/main/src/indexing/embedding.py): `src/indexing/embedding.py`
- [FAISS indexing](https://github.com/honeybadger-rex/advance-rag/blob/main/src/indexing/vector_storage.py): `src/indexing/vector_storage.py`
- [Index and chunks](https://github.com/honeybadger-rex/advance-rag/tree/main/src/vector_store): `src/vector_store`

### Retrieval and evaluation

- [Vector retrieval](https://github.com/honeybadger-rex/advance-rag/blob/main/src/retrieval/retriever.py): `src/retrieval/retriever.py`
- [Result reranking](https://github.com/honeybadger-rex/advance-rag/blob/main/src/retrieval/reranker.py): `src/retrieval/reranker.py`
- [Retrieval evaluation](https://github.com/honeybadger-rex/advance-rag/blob/main/src/evaluator/evaluate_retrieval.py): `src/evaluator/evaluate_retrieval.py`
- [Corrective reranking](https://github.com/honeybadger-rex/advance-rag/blob/main/src/evaluator/corrective_reranking.py): `src/evaluator/corrective_reranking.py`
- [Query expansion](https://github.com/honeybadger-rex/advance-rag/blob/main/src/evaluator/coracttive_retrieval.py): `src/evaluator/coracttive_retrieval.py`

### Answer generation

- [Context assembly](https://github.com/honeybadger-rex/advance-rag/blob/main/src/generation/context_builder.py): `src/generation/context_builder.py`
- [Answer generation](https://github.com/honeybadger-rex/advance-rag/blob/main/src/generation/genrater.py): `src/generation/genrater.py`

### Other components

- **User**

## Connections

- User → RAG interface: uses (evidence: `frontend/src/App.jsx`)
- RAG interface → FastAPI endpoints: posts question (evidence: `frontend/src/App.jsx`)
- RAG interface → FastAPI endpoints: uploads PDF
- FastAPI endpoints → PDF loading: loads PDF (evidence: `src/main.py`)
- FastAPI endpoints → Text chunking: chunks pages (evidence: `src/main.py`)
- FastAPI endpoints → Text embeddings: embeds chunks (evidence: `src/main.py`)
- FastAPI endpoints → FAISS indexing: builds and saves (evidence: `src/main.py`)
- FAISS indexing → Index and chunks: writes index and chunks (evidence: `src/indexing/vector_storage.py`)
- FastAPI endpoints → Vector retrieval: retrieves passages (evidence: `src/main.py`)
- FastAPI endpoints → Result reranking: reranks results (evidence: `src/main.py`)
- FastAPI endpoints → Retrieval evaluation: evaluates results (evidence: `src/main.py`)
- FastAPI endpoints → Corrective reranking: requests correction (evidence: `src/main.py`)
- Corrective reranking → Query expansion: uses query expansion (evidence: `src/evaluator/corrective_reranking.py`)
- FastAPI endpoints → Context assembly: builds context (evidence: `src/main.py`)
- FastAPI endpoints → Answer generation: generates answer (evidence: `src/main.py`)
- Vector retrieval → Index and chunks: reads index and chunks (evidence: `src/retrieval/retriever.py`)
- Query expansion → Vector retrieval: repeats retrieval (evidence: `src/evaluator/coracttive_retrieval.py`)
- Answer generation → Context assembly: uses context builder (evidence: `src/generation/genrater.py`)
