# q-fis/finforge-vanilla architecture

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

- Interactive diagram: https://gitdiagram.com/q-fis/finforge-vanilla
- Repository: https://github.com/q-fis/finforge-vanilla

## Overview

Vanilla RAG answers questions about Indian companies’ annual reports. A run loads configuration and the report registry, processes PDFs into searchable chunks, retrieves evidence for each question, builds a tagged context, generates an answer, checks citations, and scores and traces results. Retrieval supports dense and TF-IDF search; the README also documents evaluation and run comparison. The run excerpt is partial, so stage links also rely on its indexed references and README workflow; unsampled implementations are not inferred beyond those documented relationships.

Main entry points: [`src/rag/run.py`](https://github.com/q-fis/finforge-vanilla/blob/main/src/rag/run.py) (Run orchestrator), [`src/rag/ret/retrieve.py`](https://github.com/q-fis/finforge-vanilla/blob/main/src/rag/ret/retrieve.py) (Retrieval coordinator), [`src/rag/registry.py`](https://github.com/q-fis/finforge-vanilla/blob/main/src/rag/registry.py) (Report registry), [`src/rag/rep/chunking.py`](https://github.com/q-fis/finforge-vanilla/blob/main/src/rag/rep/chunking.py) (Chunking)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_corpus["Corpus preparation"]
  node_registry["Report registry<br/>[registry.py]"]
  node_reports["Annual report PDFs"]
  node_parser["PDF parser<br/>[parse.py]"]
  node_cleaner["Text cleaning<br/>[clean.py]"]
  node_metadata["Chunk metadata<br/>[metadata.py]"]
  node_chunker["Chunking<br/>[chunking.py]"]
  node_tokens["Token counting<br/>[tokens.py]"]
end

subgraph group_search["Retrieval"]
  node_embedder["Text embeddings<br/>[embed.py]"]
  node_retriever["Retrieval coordinator<br/>[retrieve.py]"]
  node_dense["Dense index<br/>[retrieve.py]"]
  node_tfidf["TF-IDF index<br/>[tfidf.py]"]
  node_filters["Hit deduplication<br/>[filters.py]"]
end

subgraph group_answer["Answer generation"]
  node_context["Context builder<br/>[context.py]"]
  node_generator["Answer generator<br/>[generate.py]"]
  node_llm["Language model<br/>[llm.py]"]
  node_citation["Citation validation<br/>[citations.py]"]
end

subgraph group_evaluation["Evaluation"]
  node_runner["Run orchestrator<br/>[run.py]"]
  node_config["Run configuration<br/>[config.py]"]
  node_score["Answer scoring<br/>[score.py]"]
  node_metrics["Retrieval metrics<br/>[metrics.py]"]
  node_trace["Failure tracing<br/>[failure_trace.py]"]
  node_compare["Run comparison<br/>[compare.py]"]
  node_runresults["Run outputs<br/>[run.py]"]
  node_questions["Evaluation questions<br/>[questions.jsonl]"]
  node_sharedtypes["Pipeline data types<br/>[schema.py]"]
end

node_user(("Questioner"))

node_user -->|"starts run"| node_runner
node_runner -->|"loads settings"| node_config
node_runner -->|"loads registry"| node_registry
node_registry -->|"locates PDFs"| node_reports
node_runner -->|"parses reports"| node_parser
node_runner -->|"cleans text"| node_cleaner
node_runner -->|"adds metadata"| node_metadata
node_runner -->|"chunks documents"| node_chunker
node_chunker -->|"counts tokens"| node_tokens
node_runner -->|"embeds chunks"| node_embedder
node_runner -->|"builds index"| node_dense
node_runner -->|"builds index"| node_tfidf
node_runner -->|"retrieves evidence"| node_retriever
node_retriever -->|"embeds query"| node_embedder
node_retriever -->|"searches dense"| node_dense
node_retriever -->|"searches terms"| node_tfidf
node_retriever -->|"deduplicates hits"| node_filters
node_runner -->|"builds context"| node_context
node_runner -->|"generates answer"| node_generator
node_generator -->|"requests completion"| node_llm
node_runner -->|"checks citations"| node_citation
node_runner -->|"scores answer"| node_score
node_runner -->|"measures retrieval"| node_metrics
node_runner -->|"labels failures"| node_trace
node_runner -->|"loads questions"| node_questions
node_runner -->|"writes results"| node_runresults
node_compare -.->|"compares runs"| node_runresults

click node_runner "https://github.com/q-fis/finforge-vanilla/blob/main/src/rag/run.py"
click node_config "https://github.com/q-fis/finforge-vanilla/blob/main/src/rag/config.py"
click node_registry "https://github.com/q-fis/finforge-vanilla/blob/main/src/rag/registry.py"
click node_reports "https://github.com/q-fis/finforge-vanilla/tree/main/data/pdfs"
click node_parser "https://github.com/q-fis/finforge-vanilla/blob/main/src/rag/rep/parse.py"
click node_cleaner "https://github.com/q-fis/finforge-vanilla/blob/main/src/rag/rep/clean.py"
click node_metadata "https://github.com/q-fis/finforge-vanilla/blob/main/src/rag/rep/metadata.py"
click node_chunker "https://github.com/q-fis/finforge-vanilla/blob/main/src/rag/rep/chunking.py"
click node_tokens "https://github.com/q-fis/finforge-vanilla/blob/main/src/rag/rep/tokens.py"
click node_embedder "https://github.com/q-fis/finforge-vanilla/blob/main/src/rag/rep/embed.py"
click node_retriever "https://github.com/q-fis/finforge-vanilla/blob/main/src/rag/ret/retrieve.py"
click node_dense "https://github.com/q-fis/finforge-vanilla/blob/main/src/rag/ret/retrieve.py"
click node_tfidf "https://github.com/q-fis/finforge-vanilla/blob/main/src/rag/ret/tfidf.py"
click node_filters "https://github.com/q-fis/finforge-vanilla/blob/main/src/rag/ret/filters.py"
click node_context "https://github.com/q-fis/finforge-vanilla/blob/main/src/rag/gen/context.py"
click node_generator "https://github.com/q-fis/finforge-vanilla/blob/main/src/rag/gen/generate.py"
click node_llm "https://github.com/q-fis/finforge-vanilla/blob/main/src/rag/gen/llm.py"
click node_citation "https://github.com/q-fis/finforge-vanilla/blob/main/src/rag/gen/citations.py"
click node_score "https://github.com/q-fis/finforge-vanilla/blob/main/src/rag/score.py"
click node_metrics "https://github.com/q-fis/finforge-vanilla/blob/main/src/rag/ret/metrics.py"
click node_trace "https://github.com/q-fis/finforge-vanilla/blob/main/src/rag/failure_trace.py"
click node_compare "https://github.com/q-fis/finforge-vanilla/blob/main/src/rag/compare.py"
click node_runresults "https://github.com/q-fis/finforge-vanilla/blob/main/src/rag/run.py"
click node_questions "https://github.com/q-fis/finforge-vanilla/blob/main/eval/questions.jsonl"
click node_sharedtypes "https://github.com/q-fis/finforge-vanilla/blob/main/src/rag/schema.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_registry,node_reports,node_parser,node_cleaner,node_metadata,node_chunker,node_tokens toneBlue
class node_embedder,node_retriever,node_dense,node_tfidf,node_filters toneAmber
class node_context,node_generator,node_llm,node_citation toneMint
class node_runner,node_config,node_score,node_metrics,node_trace,node_compare,node_runresults,node_questions,node_sharedtypes toneRose
class node_user toneIndigo
```

## Components

### Corpus preparation

- [Report registry](https://github.com/q-fis/finforge-vanilla/blob/main/src/rag/registry.py): `src/rag/registry.py`
- [Annual report PDFs](https://github.com/q-fis/finforge-vanilla/tree/main/data/pdfs): `data/pdfs`
- [PDF parser](https://github.com/q-fis/finforge-vanilla/blob/main/src/rag/rep/parse.py): `src/rag/rep/parse.py`
- [Text cleaning](https://github.com/q-fis/finforge-vanilla/blob/main/src/rag/rep/clean.py): `src/rag/rep/clean.py`
- [Chunk metadata](https://github.com/q-fis/finforge-vanilla/blob/main/src/rag/rep/metadata.py): `src/rag/rep/metadata.py`
- [Chunking](https://github.com/q-fis/finforge-vanilla/blob/main/src/rag/rep/chunking.py): `src/rag/rep/chunking.py`
- [Token counting](https://github.com/q-fis/finforge-vanilla/blob/main/src/rag/rep/tokens.py): `src/rag/rep/tokens.py`

### Retrieval

- [Text embeddings](https://github.com/q-fis/finforge-vanilla/blob/main/src/rag/rep/embed.py): `src/rag/rep/embed.py`
- [Retrieval coordinator](https://github.com/q-fis/finforge-vanilla/blob/main/src/rag/ret/retrieve.py): `src/rag/ret/retrieve.py`
- [Dense index](https://github.com/q-fis/finforge-vanilla/blob/main/src/rag/ret/retrieve.py): `src/rag/ret/retrieve.py`
- [TF-IDF index](https://github.com/q-fis/finforge-vanilla/blob/main/src/rag/ret/tfidf.py): `src/rag/ret/tfidf.py`
- [Hit deduplication](https://github.com/q-fis/finforge-vanilla/blob/main/src/rag/ret/filters.py): `src/rag/ret/filters.py`

### Answer generation

- [Context builder](https://github.com/q-fis/finforge-vanilla/blob/main/src/rag/gen/context.py): `src/rag/gen/context.py`
- [Answer generator](https://github.com/q-fis/finforge-vanilla/blob/main/src/rag/gen/generate.py): `src/rag/gen/generate.py`
- [Language model](https://github.com/q-fis/finforge-vanilla/blob/main/src/rag/gen/llm.py): `src/rag/gen/llm.py`
- [Citation validation](https://github.com/q-fis/finforge-vanilla/blob/main/src/rag/gen/citations.py): `src/rag/gen/citations.py`

### Evaluation

- [Run orchestrator](https://github.com/q-fis/finforge-vanilla/blob/main/src/rag/run.py): `src/rag/run.py`
- [Run configuration](https://github.com/q-fis/finforge-vanilla/blob/main/src/rag/config.py): `src/rag/config.py`
- [Answer scoring](https://github.com/q-fis/finforge-vanilla/blob/main/src/rag/score.py): `src/rag/score.py`
- [Retrieval metrics](https://github.com/q-fis/finforge-vanilla/blob/main/src/rag/ret/metrics.py): `src/rag/ret/metrics.py`
- [Failure tracing](https://github.com/q-fis/finforge-vanilla/blob/main/src/rag/failure_trace.py): `src/rag/failure_trace.py`
- [Run comparison](https://github.com/q-fis/finforge-vanilla/blob/main/src/rag/compare.py): `src/rag/compare.py`
- [Run outputs](https://github.com/q-fis/finforge-vanilla/blob/main/src/rag/run.py): `src/rag/run.py`
- [Evaluation questions](https://github.com/q-fis/finforge-vanilla/blob/main/eval/questions.jsonl): `eval/questions.jsonl`
- [Pipeline data types](https://github.com/q-fis/finforge-vanilla/blob/main/src/rag/schema.py): `src/rag/schema.py`

### Other components

- **Questioner**

## Connections

- Questioner → Run orchestrator: starts run (evidence: `README.md`)
- Run orchestrator → Run configuration: loads settings (evidence: `src/rag/run.py`)
- Run orchestrator → Report registry: loads registry (evidence: `src/rag/run.py`)
- Report registry → Annual report PDFs: locates PDFs (evidence: `src/rag/registry.py`)
- Run orchestrator → PDF parser: parses reports (evidence: `README.md`)
- Run orchestrator → Text cleaning: cleans text (evidence: `README.md`)
- Run orchestrator → Chunk metadata: adds metadata (evidence: `README.md`)
- Run orchestrator → Chunking: chunks documents (evidence: `src/rag/run.py`)
- Chunking → Token counting: counts tokens (evidence: `src/rag/rep/chunking.py`)
- Run orchestrator → Text embeddings: embeds chunks (evidence: `src/rag/run.py`)
- Run orchestrator → Dense index: builds index (evidence: `src/rag/run.py`)
- Run orchestrator → TF-IDF index: builds index (evidence: `src/rag/run.py`)
- Run orchestrator → Retrieval coordinator: retrieves evidence (evidence: `src/rag/run.py`)
- Retrieval coordinator → Text embeddings: embeds query (evidence: `src/rag/ret/retrieve.py`)
- Retrieval coordinator → Dense index: searches dense (evidence: `src/rag/ret/retrieve.py`)
- Retrieval coordinator → TF-IDF index: searches terms (evidence: `src/rag/ret/retrieve.py`)
- Retrieval coordinator → Hit deduplication: deduplicates hits (evidence: `src/rag/ret/retrieve.py`)
- Run orchestrator → Context builder: builds context (evidence: `src/rag/run.py`)
- Run orchestrator → Answer generator: generates answer (evidence: `src/rag/run.py`)
- Answer generator → Language model: requests completion (evidence: `src/rag/gen/generate.py`)
- Run orchestrator → Citation validation: checks citations (evidence: `src/rag/run.py`)
- Run orchestrator → Answer scoring: scores answer (evidence: `src/rag/run.py`)
- Run orchestrator → Retrieval metrics: measures retrieval (evidence: `src/rag/run.py`)
- Run orchestrator → Failure tracing: labels failures (evidence: `src/rag/run.py`)
- Run orchestrator → Evaluation questions: loads questions (evidence: `src/rag/run.py`)
- Run orchestrator → Run outputs: writes results (evidence: `src/rag/run.py`)
- Run comparison → Run outputs: compares runs
