# shirleydhaka/multimodal-rag-provenance architecture

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

- Interactive diagram: https://gitdiagram.com/shirleydhaka/multimodal-rag-provenance
- Repository: https://github.com/shirleydhaka/multimodal-rag-provenance

## Overview

This repository implements a multimodal PDF claim-verification tool. A user supplies a PDF, query, and answer; the parser extracts text, tables, and image regions with page coordinates, then the RAG pipeline retrieves evidence, checks answer claims, and returns a provenance report for formatting. The code also provides an interactive provenance-graph and bounding-box viewer. The main workflow is evidenced by the excerpts; the viewer is a separate capability, and no connection from the PDF runner to it is shown.

Main entry points: [`main.py`](https://github.com/shirleydhaka/multimodal-rag-provenance/blob/main/main.py) (RAG orchestrator), [`run_real_pdf.py`](https://github.com/shirleydhaka/multimodal-rag-provenance/blob/main/run_real_pdf.py) (PDF runner), [`schema.py`](https://github.com/shirleydhaka/multimodal-rag-provenance/blob/main/schema.py) (Evidence and report models), [`parser.py`](https://github.com/shirleydhaka/multimodal-rag-provenance/blob/main/parser.py) (PDF parser)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ingestion["PDF ingestion"]
  node_runner["PDF runner<br/>[run_real_pdf.py]"]
  node_parser["PDF parser<br/>[parser.py]"]
end

subgraph group_verification["Claim verification"]
  node_rag["RAG orchestrator<br/>[main.py]"]
  node_decomposer["Claim decomposer<br/>[engine.py]"]
  node_retriever["Graph retriever<br/>[engine.py]"]
  node_conflict["Stance verifier<br/>[engine.py]"]
end

subgraph group_reporting["Provenance outputs"]
  node_formatter["Audit formatter"]
  node_visualizer["Interactive provenance viewer<br/>[visualizer.py]"]
  node_report["Verification report"]
end

subgraph group_models["Domain models"]
  node_schema["Evidence and report models<br/>[schema.py]"]
end

node_user(("User"))
node_pdf["PDF document"]

node_user -->|"submits query"| node_runner
node_pdf -->|"provides file"| node_runner
node_runner -->|"parses PDF"| node_parser
node_parser -->|"creates evidence"| node_schema
node_runner -->|"ingests evidence"| node_rag
node_runner -->|"requests verification"| node_rag
node_rag -->|"decomposes claims"| node_decomposer
node_rag -->|"retrieves evidence"| node_retriever
node_rag -->|"evaluates claims"| node_conflict
node_retriever -->|"uses evidence nodes"| node_schema
node_conflict -->|"returns verification"| node_schema
node_rag -->|"builds report"| node_schema
node_rag -->|"produces"| node_report
node_runner -->|"formats report"| node_formatter
node_report -->|"supplies data"| node_formatter
node_report -->|"renders graph"| node_visualizer

click node_runner "https://github.com/shirleydhaka/multimodal-rag-provenance/blob/main/run_real_pdf.py"
click node_parser "https://github.com/shirleydhaka/multimodal-rag-provenance/blob/main/parser.py"
click node_rag "https://github.com/shirleydhaka/multimodal-rag-provenance/blob/main/main.py"
click node_decomposer "https://github.com/shirleydhaka/multimodal-rag-provenance/blob/main/engine.py"
click node_retriever "https://github.com/shirleydhaka/multimodal-rag-provenance/blob/main/engine.py"
click node_conflict "https://github.com/shirleydhaka/multimodal-rag-provenance/blob/main/engine.py"
click node_schema "https://github.com/shirleydhaka/multimodal-rag-provenance/blob/main/schema.py"
click node_formatter "https://github.com/shirleydhaka/multimodal-rag-provenance/blob/main/report_formatter.py"
click node_visualizer "https://github.com/shirleydhaka/multimodal-rag-provenance/blob/main/visualizer.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_runner,node_parser,node_user toneBlue
class node_rag,node_decomposer,node_retriever,node_conflict toneAmber
class node_formatter,node_visualizer,node_report toneMint
class node_schema toneRose
class node_pdf toneIndigo
```

## Components

### PDF ingestion

- [PDF runner](https://github.com/shirleydhaka/multimodal-rag-provenance/blob/main/run_real_pdf.py): `run_real_pdf.py`
- [PDF parser](https://github.com/shirleydhaka/multimodal-rag-provenance/blob/main/parser.py): `parser.py`

### Claim verification

- [RAG orchestrator](https://github.com/shirleydhaka/multimodal-rag-provenance/blob/main/main.py): `main.py`
- [Claim decomposer](https://github.com/shirleydhaka/multimodal-rag-provenance/blob/main/engine.py): `engine.py`
- [Graph retriever](https://github.com/shirleydhaka/multimodal-rag-provenance/blob/main/engine.py): `engine.py`
- [Stance verifier](https://github.com/shirleydhaka/multimodal-rag-provenance/blob/main/engine.py): `engine.py`

### Provenance outputs

- [Audit formatter](https://github.com/shirleydhaka/multimodal-rag-provenance/blob/main/report_formatter.py): `report_formatter.py`
- [Interactive provenance viewer](https://github.com/shirleydhaka/multimodal-rag-provenance/blob/main/visualizer.py): `visualizer.py`
- **Verification report**

### Domain models

- [Evidence and report models](https://github.com/shirleydhaka/multimodal-rag-provenance/blob/main/schema.py): `schema.py`

### Other components

- **User**
- **PDF document**

## Connections

- User → PDF runner: submits query (evidence: `README.md`)
- PDF document → PDF runner: provides file (evidence: `README.md`)
- PDF runner → PDF parser: parses PDF (evidence: `run_real_pdf.py`)
- PDF parser → Evidence and report models: creates evidence (evidence: `parser.py`)
- PDF runner → RAG orchestrator: ingests evidence (evidence: `run_real_pdf.py`)
- PDF runner → RAG orchestrator: requests verification (evidence: `run_real_pdf.py`)
- RAG orchestrator → Claim decomposer: decomposes claims (evidence: `main.py`)
- RAG orchestrator → Graph retriever: retrieves evidence (evidence: `main.py`)
- RAG orchestrator → Stance verifier: evaluates claims (evidence: `main.py`)
- Graph retriever → Evidence and report models: uses evidence nodes (evidence: `engine.py`)
- Stance verifier → Evidence and report models: returns verification (evidence: `engine.py`)
- RAG orchestrator → Evidence and report models: builds report (evidence: `main.py`)
- RAG orchestrator → Verification report: produces (evidence: `main.py`)
- PDF runner → Audit formatter: formats report (evidence: `run_real_pdf.py`)
- Verification report → Audit formatter: supplies data
- Verification report → Interactive provenance viewer: renders graph (evidence: `visualizer.py`)
