# mahnoorahmed-dev/research-paper-rag architecture

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

- Interactive diagram: https://gitdiagram.com/mahnoorahmed-dev/research-paper-rag
- Repository: https://github.com/mahnoorahmed-dev/research-paper-rag

## Overview

Research Paper RAG is a local Streamlit application for searching a user’s PDF collection, producing cited answers, critiquing methodology drafts, and checking claims against the indexed corpus. The principal workflow is PDF upload or selection, extraction and indexing, then question or claim retrieval, reranking, and evidence-grounded generation. Critique adds section-by-section analysis; novelty adds a corpus-scoped verdict. The README documents these capabilities, while some retrieval and UI wiring was only partially sampled, so uncertain internal links are omitted.

Main entry points: [`app.py`](https://github.com/mahnoorahmed-dev/research-paper-rag/blob/Main/app.py) (Streamlit app), [`src/critique.py`](https://github.com/mahnoorahmed-dev/research-paper-rag/blob/Main/src/critique.py) (Methodology critique), [`src/chain.py`](https://github.com/mahnoorahmed-dev/research-paper-rag/blob/Main/src/chain.py) (Question answering), [`src/novelty.py`](https://github.com/mahnoorahmed-dev/research-paper-rag/blob/Main/src/novelty.py) (Novelty assessment)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["User interface"]
  node_app["Streamlit app<br/>[app.py]"]
end

subgraph group_indexing["Corpus indexing"]
  node_ingest["Indexing orchestration<br/>[ingest.py]"]
  node_extract["Page extraction<br/>[ingest.py]"]
  node_section_tags["Section tagging<br/>[ingest.py]"]
  node_chunking["Text chunking<br/>[ingest.py]"]
  node_embedding["Local embeddings<br/>[ingest.py]"]
  node_store[("Chroma index")]
end

subgraph group_analysis["Evidence analysis"]
  node_qa["Question answering<br/>[chain.py]"]
  node_single_retrieval["Single-paper retrieval<br/>[chain.py]"]
  node_multi_retrieval["Multi-paper retrieval<br/>[chain.py]"]
  node_rerank["Candidate reranking<br/>[chain.py]"]
  node_critique["Methodology critique<br/>[critique.py]"]
  node_section_split["Draft sectioning<br/>[critique.py]"]
  node_novelty["Novelty assessment<br/>[novelty.py]"]
end

subgraph group_generation["Response generation"]
  node_format["Evidence formatting<br/>[chain.py]"]
  node_llm{{"Groq language model"}}
end

node_user(("Researcher"))
node_pdfs["Paper PDFs"]

node_user -->|"uses"| node_app
node_app -->|"uploads PDFs"| node_pdfs
node_app -->|"adds PDFs"| node_ingest
node_ingest -->|"extracts pages"| node_extract
node_pdfs -->|"provides PDFs"| node_extract
node_extract -->|"tags sections"| node_section_tags
node_section_tags -->|"segments text"| node_chunking
node_chunking -->|"embeds chunks"| node_embedding
node_embedding -->|"writes vectors"| node_store
node_app -->|"asks question"| node_qa
node_app -->|"submits draft"| node_critique
node_app -->|"submits claim"| node_novelty
node_qa -->|"retrieves candidates"| node_single_retrieval
node_single_retrieval -->|"searches vectors"| node_store
node_single_retrieval -->|"reranks candidates"| node_rerank
node_critique -->|"splits draft"| node_section_split
node_critique -->|"retrieves per section"| node_multi_retrieval
node_novelty -->|"retrieves claim evidence"| node_multi_retrieval
node_multi_retrieval -->|"searches per paper"| node_store
node_multi_retrieval -->|"reranks candidates"| node_rerank
node_qa -->|"formats evidence"| node_format
node_critique -->|"formats evidence"| node_format
node_novelty -->|"formats evidence"| node_format
node_format -->|"supplies context"| node_llm
node_qa -->|"generates answer"| node_llm
node_critique -->|"generates critique"| node_llm
node_novelty -->|"generates assessment"| node_llm
node_llm -->|"returns results"| node_app
node_store -->|"lists indexed papers"| node_app

click node_pdfs "https://github.com/mahnoorahmed-dev/research-paper-rag/tree/Main/data/pdfs"
click node_app "https://github.com/mahnoorahmed-dev/research-paper-rag/blob/Main/app.py"
click node_ingest "https://github.com/mahnoorahmed-dev/research-paper-rag/blob/Main/src/ingest.py"
click node_extract "https://github.com/mahnoorahmed-dev/research-paper-rag/blob/Main/src/ingest.py"
click node_section_tags "https://github.com/mahnoorahmed-dev/research-paper-rag/blob/Main/src/ingest.py"
click node_chunking "https://github.com/mahnoorahmed-dev/research-paper-rag/blob/Main/src/ingest.py"
click node_embedding "https://github.com/mahnoorahmed-dev/research-paper-rag/blob/Main/src/ingest.py"
click node_store "https://github.com/mahnoorahmed-dev/research-paper-rag/tree/Main/chroma_db"
click node_qa "https://github.com/mahnoorahmed-dev/research-paper-rag/blob/Main/src/chain.py"
click node_single_retrieval "https://github.com/mahnoorahmed-dev/research-paper-rag/blob/Main/src/chain.py"
click node_multi_retrieval "https://github.com/mahnoorahmed-dev/research-paper-rag/blob/Main/src/chain.py"
click node_rerank "https://github.com/mahnoorahmed-dev/research-paper-rag/blob/Main/src/chain.py"
click node_critique "https://github.com/mahnoorahmed-dev/research-paper-rag/blob/Main/src/critique.py"
click node_section_split "https://github.com/mahnoorahmed-dev/research-paper-rag/blob/Main/src/critique.py"
click node_novelty "https://github.com/mahnoorahmed-dev/research-paper-rag/blob/Main/src/novelty.py"
click node_format "https://github.com/mahnoorahmed-dev/research-paper-rag/blob/Main/src/chain.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_app toneBlue
class node_ingest,node_extract,node_section_tags,node_chunking,node_embedding,node_store toneAmber
class node_qa,node_single_retrieval,node_multi_retrieval,node_rerank,node_critique,node_section_split,node_novelty toneMint
class node_format,node_llm toneRose
class node_user toneIndigo
class node_pdfs toneTeal
```

## Components

### User interface

- [Streamlit app](https://github.com/mahnoorahmed-dev/research-paper-rag/blob/Main/app.py): `app.py`

### Corpus indexing

- [Indexing orchestration](https://github.com/mahnoorahmed-dev/research-paper-rag/blob/Main/src/ingest.py): `src/ingest.py`
- [Page extraction](https://github.com/mahnoorahmed-dev/research-paper-rag/blob/Main/src/ingest.py): `src/ingest.py`
- [Section tagging](https://github.com/mahnoorahmed-dev/research-paper-rag/blob/Main/src/ingest.py): `src/ingest.py`
- [Text chunking](https://github.com/mahnoorahmed-dev/research-paper-rag/blob/Main/src/ingest.py): `src/ingest.py`
- [Local embeddings](https://github.com/mahnoorahmed-dev/research-paper-rag/blob/Main/src/ingest.py): `src/ingest.py`
- [Chroma index](https://github.com/mahnoorahmed-dev/research-paper-rag/tree/Main/chroma_db): `chroma_db`

### Evidence analysis

- [Question answering](https://github.com/mahnoorahmed-dev/research-paper-rag/blob/Main/src/chain.py): `src/chain.py`
- [Single-paper retrieval](https://github.com/mahnoorahmed-dev/research-paper-rag/blob/Main/src/chain.py): `src/chain.py`
- [Multi-paper retrieval](https://github.com/mahnoorahmed-dev/research-paper-rag/blob/Main/src/chain.py): `src/chain.py`
- [Candidate reranking](https://github.com/mahnoorahmed-dev/research-paper-rag/blob/Main/src/chain.py): `src/chain.py`
- [Methodology critique](https://github.com/mahnoorahmed-dev/research-paper-rag/blob/Main/src/critique.py): `src/critique.py`
- [Draft sectioning](https://github.com/mahnoorahmed-dev/research-paper-rag/blob/Main/src/critique.py): `src/critique.py`
- [Novelty assessment](https://github.com/mahnoorahmed-dev/research-paper-rag/blob/Main/src/novelty.py): `src/novelty.py`

### Response generation

- [Evidence formatting](https://github.com/mahnoorahmed-dev/research-paper-rag/blob/Main/src/chain.py): `src/chain.py`
- **Groq language model**

### Other components

- **Researcher**
- [Paper PDFs](https://github.com/mahnoorahmed-dev/research-paper-rag/tree/Main/data/pdfs): `data/pdfs`

## Connections

- Researcher → Streamlit app: uses
- Streamlit app → Paper PDFs: uploads PDFs
- Streamlit app → Indexing orchestration: adds PDFs
- Indexing orchestration → Page extraction: extracts pages
- Paper PDFs → Page extraction: provides PDFs
- Page extraction → Section tagging: tags sections
- Section tagging → Text chunking: segments text
- Text chunking → Local embeddings: embeds chunks
- Local embeddings → Chroma index: writes vectors
- Streamlit app → Question answering: asks question
- Streamlit app → Methodology critique: submits draft
- Streamlit app → Novelty assessment: submits claim
- Question answering → Single-paper retrieval: retrieves candidates
- Single-paper retrieval → Chroma index: searches vectors
- Single-paper retrieval → Candidate reranking: reranks candidates
- Methodology critique → Draft sectioning: splits draft
- Methodology critique → Multi-paper retrieval: retrieves per section
- Novelty assessment → Multi-paper retrieval: retrieves claim evidence
- Multi-paper retrieval → Chroma index: searches per paper
- Multi-paper retrieval → Candidate reranking: reranks candidates
- Question answering → Evidence formatting: formats evidence
- Methodology critique → Evidence formatting: formats evidence
- Novelty assessment → Evidence formatting: formats evidence
- Evidence formatting → Groq language model: supplies context
- Question answering → Groq language model: generates answer
- Methodology critique → Groq language model: generates critique
- Novelty assessment → Groq language model: generates assessment
- Groq language model → Streamlit app: returns results
- Chroma index → Streamlit app: lists indexed papers
