# simpsonr06/the-relay architecture

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

- Interactive diagram: https://gitdiagram.com/simpsonr06/the-relay
- Repository: https://github.com/simpsonr06/the-relay

## Overview

The Relay provides page-provenance PDF ingestion and BM25 retrieval, then uses a staged RAG pipeline to assess evidence, generate answers, and validate citations. Its separate offline serving toolkit simulates provider behavior and benchmarks concurrency. The diagram follows documented workflow relationships and source-index references; several internals were not excerpted, so their connections are limited to those references or README descriptions.

Main entry points: [`src/pipeline/orchestrator.py`](https://github.com/simpsonr06/the-relay/blob/main/src/pipeline/orchestrator.py) (RAG Orchestrator), [`src/retrieval/indexer.py`](https://github.com/simpsonr06/the-relay/blob/main/src/retrieval/indexer.py) (BM25 Index), [`src/retrieval/build_index.py`](https://github.com/simpsonr06/the-relay/blob/main/src/retrieval/build_index.py) (Index Builder), [`src/providers/groq_client.py`](https://github.com/simpsonr06/the-relay/blob/main/src/providers/groq_client.py) (Groq Provider)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ingestion["PDF Retrieval"]
  node_build_index["Index Builder<br/>[build_index.py]"]
  node_extractor["PDF Extractor<br/>[extractor.py]"]
  node_chunker["Page Chunker<br/>[chunker.py]"]
  node_retrieval_models["Retrieval Models<br/>[models.py]"]
  node_tokenizer["BM25 Tokenizer<br/>[tokenizer.py]"]
  node_bm25[("BM25 Index<br/>[indexer.py]")]
  node_retrieval_tool["Retrieval Tool<br/>[tool.py]"]
end

subgraph group_qa["Grounded QA"]
  node_orchestrator["RAG Orchestrator<br/>[orchestrator.py]"]
  node_analyzer["Query Analyzer<br/>[analyzer.py]"]
  node_assessor["Evidence Assessor<br/>[assessor.py]"]
  node_prompts["Prompt Builders<br/>[prompts.py]"]
  node_validator["Citation Validator<br/>[validator.py]"]
  node_pipeline_models["Pipeline Results<br/>[models.py]"]
end

subgraph group_serving["Inference Providers"]
  node_groq["Groq Provider<br/>[groq_client.py]"]
  node_provider_models["Provider Models<br/>[models.py]"]
  node_retry["Retry Policy<br/>[retry.py]"]
  node_config["Relay Config<br/>[config.py]"]
end

subgraph group_simulation["Serving Simulation"]
  node_mock_provider["Simulated Provider<br/>[mock_provider.py]"]
  node_simulation_models["Simulation Models<br/>[models.py]"]
  node_runner["Concurrency Runner"]
  node_faults["Fault Injector<br/>[fault_injector.py]"]
  node_profiler["Resource Profiler"]
end

node_user(("Questioner"))
node_pdfs["PDF Collection"]

node_user -->|"submits query"| node_orchestrator
node_pdfs -->|"provides PDFs"| node_build_index
node_build_index -->|"extracts pages"| node_extractor
node_build_index -->|"chunks pages"| node_chunker
node_build_index -->|"builds index"| node_bm25
node_extractor -->|"supplies page text"| node_chunker
node_chunker -->|"uses tokenizer"| node_tokenizer
node_bm25 -->|"tokenizes corpus"| node_tokenizer
node_bm25 -->|"stores and ranks chunks"| node_retrieval_models
node_retrieval_tool -->|"searches index"| node_bm25
node_orchestrator -->|"analyzes query"| node_analyzer
node_orchestrator -->|"retrieves evidence"| node_retrieval_tool
node_orchestrator -->|"assesses evidence"| node_assessor
node_orchestrator -->|"builds prompts"| node_prompts
node_orchestrator -->|"requests generation"| node_groq
node_orchestrator -->|"validates citations"| node_validator
node_orchestrator -->|"returns result"| node_pipeline_models
node_assessor -->|"guides refinement"| node_retrieval_tool
node_validator -->|"checks provenance"| node_retrieval_models
node_groq -->|"applies retries"| node_retry
node_groq -->|"loads credentials"| node_config
node_groq -->|"returns responses"| node_provider_models
node_mock_provider -->|"simulates retry policy"| node_retry
node_mock_provider -->|"yields stream chunks"| node_provider_models
node_runner -->|"runs workloads"| node_orchestrator
node_runner -->|"records results"| node_simulation_models
node_faults -->|"injects pipeline faults"| node_orchestrator
node_faults -->|"configures faults"| node_mock_provider
node_profiler -->|"profiles index"| node_bm25

click node_build_index "https://github.com/simpsonr06/the-relay/blob/main/src/retrieval/build_index.py"
click node_extractor "https://github.com/simpsonr06/the-relay/blob/main/src/retrieval/extractor.py"
click node_chunker "https://github.com/simpsonr06/the-relay/blob/main/src/retrieval/chunker.py"
click node_retrieval_models "https://github.com/simpsonr06/the-relay/blob/main/src/retrieval/models.py"
click node_tokenizer "https://github.com/simpsonr06/the-relay/blob/main/src/retrieval/tokenizer.py"
click node_bm25 "https://github.com/simpsonr06/the-relay/blob/main/src/retrieval/indexer.py"
click node_retrieval_tool "https://github.com/simpsonr06/the-relay/blob/main/src/retrieval/tool.py"
click node_orchestrator "https://github.com/simpsonr06/the-relay/blob/main/src/pipeline/orchestrator.py"
click node_analyzer "https://github.com/simpsonr06/the-relay/blob/main/src/pipeline/analyzer.py"
click node_assessor "https://github.com/simpsonr06/the-relay/blob/main/src/pipeline/assessor.py"
click node_prompts "https://github.com/simpsonr06/the-relay/blob/main/src/pipeline/prompts.py"
click node_validator "https://github.com/simpsonr06/the-relay/blob/main/src/pipeline/validator.py"
click node_pipeline_models "https://github.com/simpsonr06/the-relay/blob/main/src/pipeline/models.py"
click node_groq "https://github.com/simpsonr06/the-relay/blob/main/src/providers/groq_client.py"
click node_provider_models "https://github.com/simpsonr06/the-relay/blob/main/src/providers/models.py"
click node_retry "https://github.com/simpsonr06/the-relay/blob/main/src/providers/retry.py"
click node_config "https://github.com/simpsonr06/the-relay/blob/main/src/relay/config.py"
click node_mock_provider "https://github.com/simpsonr06/the-relay/blob/main/src/simulation/mock_provider.py"
click node_simulation_models "https://github.com/simpsonr06/the-relay/blob/main/src/simulation/models.py"
click node_runner "https://github.com/simpsonr06/the-relay/blob/main/src/simulation/concurrency_runner.py"
click node_faults "https://github.com/simpsonr06/the-relay/blob/main/src/simulation/fault_injector.py"
click node_profiler "https://github.com/simpsonr06/the-relay/blob/main/src/simulation/resource_profiler.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_build_index,node_extractor,node_chunker,node_retrieval_models,node_tokenizer,node_bm25,node_retrieval_tool toneBlue
class node_orchestrator,node_analyzer,node_assessor,node_prompts,node_validator,node_pipeline_models toneAmber
class node_groq,node_provider_models,node_retry,node_config toneMint
class node_mock_provider,node_simulation_models,node_runner,node_faults,node_profiler toneRose
class node_user,node_pdfs toneIndigo
```

## Components

### PDF Retrieval

- [Index Builder](https://github.com/simpsonr06/the-relay/blob/main/src/retrieval/build_index.py): `src/retrieval/build_index.py`
- [PDF Extractor](https://github.com/simpsonr06/the-relay/blob/main/src/retrieval/extractor.py): `src/retrieval/extractor.py`
- [Page Chunker](https://github.com/simpsonr06/the-relay/blob/main/src/retrieval/chunker.py): `src/retrieval/chunker.py`
- [Retrieval Models](https://github.com/simpsonr06/the-relay/blob/main/src/retrieval/models.py): `src/retrieval/models.py`
- [BM25 Tokenizer](https://github.com/simpsonr06/the-relay/blob/main/src/retrieval/tokenizer.py): `src/retrieval/tokenizer.py`
- [BM25 Index](https://github.com/simpsonr06/the-relay/blob/main/src/retrieval/indexer.py): `src/retrieval/indexer.py`
- [Retrieval Tool](https://github.com/simpsonr06/the-relay/blob/main/src/retrieval/tool.py): `src/retrieval/tool.py`

### Grounded QA

- [RAG Orchestrator](https://github.com/simpsonr06/the-relay/blob/main/src/pipeline/orchestrator.py): `src/pipeline/orchestrator.py`
- [Query Analyzer](https://github.com/simpsonr06/the-relay/blob/main/src/pipeline/analyzer.py): `src/pipeline/analyzer.py`
- [Evidence Assessor](https://github.com/simpsonr06/the-relay/blob/main/src/pipeline/assessor.py): `src/pipeline/assessor.py`
- [Prompt Builders](https://github.com/simpsonr06/the-relay/blob/main/src/pipeline/prompts.py): `src/pipeline/prompts.py`
- [Citation Validator](https://github.com/simpsonr06/the-relay/blob/main/src/pipeline/validator.py): `src/pipeline/validator.py`
- [Pipeline Results](https://github.com/simpsonr06/the-relay/blob/main/src/pipeline/models.py): `src/pipeline/models.py`

### Inference Providers

- [Groq Provider](https://github.com/simpsonr06/the-relay/blob/main/src/providers/groq_client.py): `src/providers/groq_client.py`
- [Provider Models](https://github.com/simpsonr06/the-relay/blob/main/src/providers/models.py): `src/providers/models.py`
- [Retry Policy](https://github.com/simpsonr06/the-relay/blob/main/src/providers/retry.py): `src/providers/retry.py`
- [Relay Config](https://github.com/simpsonr06/the-relay/blob/main/src/relay/config.py): `src/relay/config.py`

### Serving Simulation

- [Simulated Provider](https://github.com/simpsonr06/the-relay/blob/main/src/simulation/mock_provider.py): `src/simulation/mock_provider.py`
- [Simulation Models](https://github.com/simpsonr06/the-relay/blob/main/src/simulation/models.py): `src/simulation/models.py`
- [Concurrency Runner](https://github.com/simpsonr06/the-relay/blob/main/src/simulation/concurrency_runner.py): `src/simulation/concurrency_runner.py`
- [Fault Injector](https://github.com/simpsonr06/the-relay/blob/main/src/simulation/fault_injector.py): `src/simulation/fault_injector.py`
- [Resource Profiler](https://github.com/simpsonr06/the-relay/blob/main/src/simulation/resource_profiler.py): `src/simulation/resource_profiler.py`

### Other components

- **Questioner**
- **PDF Collection**

## Connections

- Questioner → RAG Orchestrator: submits query (evidence: `README.md`)
- PDF Collection → Index Builder: provides PDFs (evidence: `README.md`)
- Index Builder → PDF Extractor: extracts pages (evidence: `src/retrieval/build_index.py`)
- Index Builder → Page Chunker: chunks pages (evidence: `src/retrieval/build_index.py`)
- Index Builder → BM25 Index: builds index (evidence: `src/retrieval/build_index.py`)
- PDF Extractor → Page Chunker: supplies page text (evidence: `README.md`)
- Page Chunker → BM25 Tokenizer: uses tokenizer (evidence: `src/retrieval/chunker.py`)
- BM25 Index → BM25 Tokenizer: tokenizes corpus (evidence: `src/retrieval/indexer.py`)
- BM25 Index → Retrieval Models: stores and ranks chunks (evidence: `src/retrieval/indexer.py`)
- Retrieval Tool → BM25 Index: searches index (evidence: `src/retrieval/tool.py`)
- RAG Orchestrator → Query Analyzer: analyzes query (evidence: `README.md`)
- RAG Orchestrator → Retrieval Tool: retrieves evidence (evidence: `src/pipeline/orchestrator.py`)
- RAG Orchestrator → Evidence Assessor: assesses evidence (evidence: `src/pipeline/orchestrator.py`)
- RAG Orchestrator → Prompt Builders: builds prompts (evidence: `README.md`)
- RAG Orchestrator → Groq Provider: requests generation (evidence: `README.md`)
- RAG Orchestrator → Citation Validator: validates citations (evidence: `README.md`)
- RAG Orchestrator → Pipeline Results: returns result (evidence: `src/pipeline/orchestrator.py`)
- Evidence Assessor → Retrieval Tool: guides refinement (evidence: `src/pipeline/assessor.py`)
- Citation Validator → Retrieval Models: checks provenance (evidence: `src/pipeline/validator.py`)
- Groq Provider → Retry Policy: applies retries (evidence: `src/providers/groq_client.py`)
- Groq Provider → Relay Config: loads credentials (evidence: `src/providers/groq_client.py`)
- Groq Provider → Provider Models: returns responses (evidence: `src/providers/groq_client.py`)
- Simulated Provider → Retry Policy: simulates retry policy (evidence: `src/simulation/mock_provider.py`)
- Simulated Provider → Provider Models: yields stream chunks (evidence: `src/simulation/mock_provider.py`)
- Concurrency Runner → RAG Orchestrator: runs workloads (evidence: `src/simulation/concurrency_runner.py`)
- Concurrency Runner → Simulation Models: records results (evidence: `src/simulation/concurrency_runner.py`)
- Fault Injector → RAG Orchestrator: injects pipeline faults (evidence: `src/simulation/fault_injector.py`)
- Fault Injector → Simulated Provider: configures faults (evidence: `src/simulation/fault_injector.py`)
- Resource Profiler → BM25 Index: profiles index (evidence: `src/simulation/resource_profiler.py`)
