# ashish-netam011/prooflens architecture

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

- Interactive diagram: https://gitdiagram.com/ashish-netam011/prooflens
- Repository: https://github.com/ashish-netam011/prooflens

## Overview

VerifiDoc AI is a document-intelligence app for evidence-grounded answers across PDFs, with abstention, citations, search, contradiction checks, and amendment timelines. Users upload PDFs into a page-aware document library, then ask questions or search; the backend retrieves and verifies evidence before returning results. Separate UI and API branches support conflict comparison and amendment resolution. The graph reflects the README and supplied source excerpts/index; some endpoint-to-service relationships are documented or indexed rather than visible in full source, so uncertain links are omitted.

Main entry points: [`backend/app/services/retrieval_service.py`](https://github.com/ashish-netam011/prooflens/blob/main/backend/app/services/retrieval_service.py) (Hybrid retrieval), [`frontend/src/App.jsx`](https://github.com/ashish-netam011/prooflens/blob/main/frontend/src/App.jsx) (App routes), [`backend/app/main.py`](https://github.com/ashish-netam011/prooflens/blob/main/backend/app/main.py) (FastAPI app), [`backend/app/routers/documents.py`](https://github.com/ashish-netam011/prooflens/blob/main/backend/app/routers/documents.py) (Document endpoints)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["User interface"]
  node_app["App routes<br/>[App.jsx]"]
  node_library["Document library<br/>[Library.jsx]"]
  node_upload["Upload interface<br/>[UploadPanel.jsx]"]
  node_askui["Ask interface<br/>[AskPage.jsx]"]
  node_searchui["Search interface<br/>[SearchPage.jsx]"]
  node_conflictui["Conflict view<br/>[Contradictions.jsx]"]
  node_amendui["Amendment view<br/>[Amendments.jsx]"]
  node_transport["API transport<br/>[client.js]"]
end

subgraph group_api["API workflows"]
  node_server["FastAPI app<br/>[main.py]"]
  node_documents_api["Document endpoints<br/>[documents.py]"]
  node_qa_api["Q&amp;A endpoint<br/>[qa.py]"]
  node_search_api["Search endpoint<br/>[search.py]"]
  node_conflict_api["Conflict endpoint<br/>[conflicts.py]"]
  node_amend_api["Amendment endpoint<br/>[amendments.py]"]
end

subgraph group_docs["Document processing"]
  node_pdf["PDF extraction<br/>[pdf_service.py]"]
  node_chunk["Page-aware chunking<br/>[chunking.py]"]
end

subgraph group_evidence["Retrieval and assurance"]
  node_qa["Answer orchestration<br/>[qa_service.py]"]
  node_retrieval["Hybrid retrieval"]
  node_bm25["Keyword search<br/>[bm25_service.py]"]
  node_embed["Embeddings"]
  node_rerank["Relevance reranking"]
  node_citation["Citation verification"]
  node_sufficiency["Evidence sufficiency"]
  node_contradiction["Fact comparison"]
  node_amendment["Amendment resolution"]
end

subgraph group_integrations["Storage and models"]
  node_store[("Document catalogue<br/>[document_store.py]")]
  node_vectors[("Vector index<br/>[vector_store.py]")]
  node_llm["LLM provider routing<br/>[llm_service.py]"]
end

node_user(("User"))
node_hosted{{"OpenRouter"}}
node_local{{"Ollama"}}

node_user -->|"uses"| node_app
node_app -->|"routes to"| node_library
node_app -->|"routes to"| node_askui
node_app -->|"routes to"| node_searchui
node_app -->|"routes to"| node_conflictui
node_app -->|"routes to"| node_amendui
node_user -.->|"submits PDFs"| node_upload
node_upload -.->|"sends requests"| node_transport
node_askui -.->|"sends questions"| node_transport
node_searchui -->|"sends queries"| node_transport
node_conflictui -.->|"requests comparison"| node_transport
node_amendui -.->|"requests timeline"| node_transport
node_transport -.->|"HTTP requests"| node_server
node_server -->|"mounts routes"| node_documents_api
node_server -->|"mounts routes"| node_qa_api
node_server -->|"mounts routes"| node_search_api
node_server -->|"mounts routes"| node_conflict_api
node_server -->|"mounts routes"| node_amend_api
node_documents_api -->|"extracts PDF"| node_pdf
node_documents_api -.->|"chunks pages"| node_chunk
node_documents_api -->|"writes records"| node_store
node_documents_api -->|"embeds passages"| node_embed
node_documents_api -->|"indexes vectors"| node_vectors
node_qa_api -->|"answers question"| node_qa
node_search_api -->|"searches"| node_retrieval
node_conflict_api -->|"compares facts"| node_contradiction
node_amend_api -->|"resolves chain"| node_amendment
node_qa -->|"retrieves evidence"| node_retrieval
node_qa -->|"checks sufficiency"| node_sufficiency
node_qa -->|"verifies citations"| node_citation
node_qa -->|"generates draft"| node_llm
node_retrieval -->|"embeds query"| node_embed
node_retrieval -.->|"searches vectors"| node_vectors
node_retrieval -->|"gets keyword hits"| node_bm25
node_retrieval -.->|"reranks candidates"| node_rerank
node_retrieval -.->|"hydrates chunks"| node_store
node_llm -->|"calls primary"| node_hosted
node_llm -.->|"falls back"| node_local
node_contradiction -.->|"finds candidates"| node_retrieval
node_amendment -.->|"reads documents"| node_store

click node_app "https://github.com/ashish-netam011/prooflens/blob/main/frontend/src/App.jsx"
click node_library "https://github.com/ashish-netam011/prooflens/blob/main/frontend/src/pages/Library.jsx"
click node_upload "https://github.com/ashish-netam011/prooflens/blob/main/frontend/src/components/UploadPanel.jsx"
click node_askui "https://github.com/ashish-netam011/prooflens/blob/main/frontend/src/pages/AskPage.jsx"
click node_searchui "https://github.com/ashish-netam011/prooflens/blob/main/frontend/src/pages/SearchPage.jsx"
click node_conflictui "https://github.com/ashish-netam011/prooflens/blob/main/frontend/src/pages/Contradictions.jsx"
click node_amendui "https://github.com/ashish-netam011/prooflens/blob/main/frontend/src/pages/Amendments.jsx"
click node_transport "https://github.com/ashish-netam011/prooflens/blob/main/frontend/src/api/client.js"
click node_server "https://github.com/ashish-netam011/prooflens/blob/main/backend/app/main.py"
click node_documents_api "https://github.com/ashish-netam011/prooflens/blob/main/backend/app/routers/documents.py"
click node_qa_api "https://github.com/ashish-netam011/prooflens/blob/main/backend/app/routers/qa.py"
click node_search_api "https://github.com/ashish-netam011/prooflens/blob/main/backend/app/routers/search.py"
click node_conflict_api "https://github.com/ashish-netam011/prooflens/blob/main/backend/app/routers/conflicts.py"
click node_amend_api "https://github.com/ashish-netam011/prooflens/blob/main/backend/app/routers/amendments.py"
click node_pdf "https://github.com/ashish-netam011/prooflens/blob/main/backend/app/services/pdf_service.py"
click node_chunk "https://github.com/ashish-netam011/prooflens/blob/main/backend/app/services/chunking.py"
click node_qa "https://github.com/ashish-netam011/prooflens/blob/main/backend/app/services/qa_service.py"
click node_retrieval "https://github.com/ashish-netam011/prooflens/blob/main/backend/app/services/retrieval_service.py"
click node_bm25 "https://github.com/ashish-netam011/prooflens/blob/main/backend/app/services/bm25_service.py"
click node_embed "https://github.com/ashish-netam011/prooflens/blob/main/backend/app/services/embedding_service.py"
click node_rerank "https://github.com/ashish-netam011/prooflens/blob/main/backend/app/services/reranker_service.py"
click node_citation "https://github.com/ashish-netam011/prooflens/blob/main/backend/app/services/citation_verifier.py"
click node_sufficiency "https://github.com/ashish-netam011/prooflens/blob/main/backend/app/services/evidence_sufficiency.py"
click node_contradiction "https://github.com/ashish-netam011/prooflens/blob/main/backend/app/services/contradiction_service.py"
click node_amendment "https://github.com/ashish-netam011/prooflens/blob/main/backend/app/services/amendment_service.py"
click node_store "https://github.com/ashish-netam011/prooflens/blob/main/backend/app/services/document_store.py"
click node_vectors "https://github.com/ashish-netam011/prooflens/blob/main/backend/app/services/vector_store.py"
click node_llm "https://github.com/ashish-netam011/prooflens/blob/main/backend/app/services/llm_service.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,node_library,node_upload,node_askui,node_searchui,node_conflictui,node_amendui,node_transport,node_user toneBlue
class node_server,node_documents_api,node_qa_api,node_search_api,node_conflict_api,node_amend_api toneAmber
class node_pdf,node_chunk,node_hosted toneMint
class node_qa,node_retrieval,node_bm25,node_embed,node_rerank,node_citation,node_sufficiency,node_contradiction,node_amendment toneRose
class node_store,node_vectors,node_llm,node_local toneIndigo
```

## Components

### User interface

- [App routes](https://github.com/ashish-netam011/prooflens/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Document library](https://github.com/ashish-netam011/prooflens/blob/main/frontend/src/pages/Library.jsx): `frontend/src/pages/Library.jsx`
- [Upload interface](https://github.com/ashish-netam011/prooflens/blob/main/frontend/src/components/UploadPanel.jsx): `frontend/src/components/UploadPanel.jsx`
- [Ask interface](https://github.com/ashish-netam011/prooflens/blob/main/frontend/src/pages/AskPage.jsx): `frontend/src/pages/AskPage.jsx`
- [Search interface](https://github.com/ashish-netam011/prooflens/blob/main/frontend/src/pages/SearchPage.jsx): `frontend/src/pages/SearchPage.jsx`
- [Conflict view](https://github.com/ashish-netam011/prooflens/blob/main/frontend/src/pages/Contradictions.jsx): `frontend/src/pages/Contradictions.jsx`
- [Amendment view](https://github.com/ashish-netam011/prooflens/blob/main/frontend/src/pages/Amendments.jsx): `frontend/src/pages/Amendments.jsx`
- [API transport](https://github.com/ashish-netam011/prooflens/blob/main/frontend/src/api/client.js): `frontend/src/api/client.js`

### API workflows

- [FastAPI app](https://github.com/ashish-netam011/prooflens/blob/main/backend/app/main.py): `backend/app/main.py`
- [Document endpoints](https://github.com/ashish-netam011/prooflens/blob/main/backend/app/routers/documents.py): `backend/app/routers/documents.py`
- [Q&A endpoint](https://github.com/ashish-netam011/prooflens/blob/main/backend/app/routers/qa.py): `backend/app/routers/qa.py`
- [Search endpoint](https://github.com/ashish-netam011/prooflens/blob/main/backend/app/routers/search.py): `backend/app/routers/search.py`
- [Conflict endpoint](https://github.com/ashish-netam011/prooflens/blob/main/backend/app/routers/conflicts.py): `backend/app/routers/conflicts.py`
- [Amendment endpoint](https://github.com/ashish-netam011/prooflens/blob/main/backend/app/routers/amendments.py): `backend/app/routers/amendments.py`

### Document processing

- [PDF extraction](https://github.com/ashish-netam011/prooflens/blob/main/backend/app/services/pdf_service.py): `backend/app/services/pdf_service.py`
- [Page-aware chunking](https://github.com/ashish-netam011/prooflens/blob/main/backend/app/services/chunking.py): `backend/app/services/chunking.py`

### Retrieval and assurance

- [Answer orchestration](https://github.com/ashish-netam011/prooflens/blob/main/backend/app/services/qa_service.py): `backend/app/services/qa_service.py`
- [Hybrid retrieval](https://github.com/ashish-netam011/prooflens/blob/main/backend/app/services/retrieval_service.py): `backend/app/services/retrieval_service.py`
- [Keyword search](https://github.com/ashish-netam011/prooflens/blob/main/backend/app/services/bm25_service.py): `backend/app/services/bm25_service.py`
- [Embeddings](https://github.com/ashish-netam011/prooflens/blob/main/backend/app/services/embedding_service.py): `backend/app/services/embedding_service.py`
- [Relevance reranking](https://github.com/ashish-netam011/prooflens/blob/main/backend/app/services/reranker_service.py): `backend/app/services/reranker_service.py`
- [Citation verification](https://github.com/ashish-netam011/prooflens/blob/main/backend/app/services/citation_verifier.py): `backend/app/services/citation_verifier.py`
- [Evidence sufficiency](https://github.com/ashish-netam011/prooflens/blob/main/backend/app/services/evidence_sufficiency.py): `backend/app/services/evidence_sufficiency.py`
- [Fact comparison](https://github.com/ashish-netam011/prooflens/blob/main/backend/app/services/contradiction_service.py): `backend/app/services/contradiction_service.py`
- [Amendment resolution](https://github.com/ashish-netam011/prooflens/blob/main/backend/app/services/amendment_service.py): `backend/app/services/amendment_service.py`

### Storage and models

- [Document catalogue](https://github.com/ashish-netam011/prooflens/blob/main/backend/app/services/document_store.py): `backend/app/services/document_store.py`
- [Vector index](https://github.com/ashish-netam011/prooflens/blob/main/backend/app/services/vector_store.py): `backend/app/services/vector_store.py`
- [LLM provider routing](https://github.com/ashish-netam011/prooflens/blob/main/backend/app/services/llm_service.py): `backend/app/services/llm_service.py`

### Other components

- **User**
- **OpenRouter**
- **Ollama**

## Connections

- User → App routes: uses (evidence: `frontend/src/App.jsx`)
- App routes → Document library: routes to (evidence: `frontend/src/App.jsx`)
- App routes → Ask interface: routes to (evidence: `frontend/src/App.jsx`)
- App routes → Search interface: routes to (evidence: `frontend/src/App.jsx`)
- App routes → Conflict view: routes to (evidence: `frontend/src/App.jsx`)
- App routes → Amendment view: routes to (evidence: `frontend/src/App.jsx`)
- User → Upload interface: submits PDFs (evidence: `README.md`)
- Upload interface → API transport: sends requests
- Ask interface → API transport: sends questions
- Search interface → API transport: sends queries
- Conflict view → API transport: requests comparison
- Amendment view → API transport: requests timeline
- API transport → FastAPI app: HTTP requests (evidence: `frontend/src/api/client.js`)
- FastAPI app → Document endpoints: mounts routes (evidence: `backend/app/main.py`)
- FastAPI app → Q&A endpoint: mounts routes (evidence: `backend/app/main.py`)
- FastAPI app → Search endpoint: mounts routes (evidence: `backend/app/main.py`)
- FastAPI app → Conflict endpoint: mounts routes (evidence: `backend/app/main.py`)
- FastAPI app → Amendment endpoint: mounts routes (evidence: `backend/app/main.py`)
- Document endpoints → PDF extraction: extracts PDF (evidence: `backend/app/routers/documents.py`)
- Document endpoints → Page-aware chunking: chunks pages (evidence: `backend/app/routers/documents.py`)
- Document endpoints → Document catalogue: writes records (evidence: `backend/app/routers/documents.py`)
- Document endpoints → Embeddings: embeds passages (evidence: `backend/app/routers/documents.py`)
- Document endpoints → Vector index: indexes vectors (evidence: `backend/app/routers/documents.py`)
- Q&A endpoint → Answer orchestration: answers question (evidence: `backend/app/routers/qa.py`)
- Search endpoint → Hybrid retrieval: searches (evidence: `backend/app/routers/search.py`)
- Conflict endpoint → Fact comparison: compares facts (evidence: `backend/app/routers/conflicts.py`)
- Amendment endpoint → Amendment resolution: resolves chain (evidence: `backend/app/routers/amendments.py`)
- Answer orchestration → Hybrid retrieval: retrieves evidence (evidence: `backend/app/services/qa_service.py`)
- Answer orchestration → Evidence sufficiency: checks sufficiency (evidence: `backend/app/services/qa_service.py`)
- Answer orchestration → Citation verification: verifies citations (evidence: `backend/app/services/qa_service.py`)
- Answer orchestration → LLM provider routing: generates draft (evidence: `backend/app/services/qa_service.py`)
- Hybrid retrieval → Embeddings: embeds query (evidence: `backend/app/services/retrieval_service.py`)
- Hybrid retrieval → Vector index: searches vectors (evidence: `backend/app/services/retrieval_service.py`)
- Hybrid retrieval → Keyword search: gets keyword hits (evidence: `backend/app/services/retrieval_service.py`)
- Hybrid retrieval → Relevance reranking: reranks candidates (evidence: `backend/app/services/retrieval_service.py`)
- Hybrid retrieval → Document catalogue: hydrates chunks (evidence: `backend/app/services/retrieval_service.py`)
- LLM provider routing → OpenRouter: calls primary (evidence: `README.md`)
- LLM provider routing → Ollama: falls back (evidence: `backend/app/services/llm_service.py`)
- Fact comparison → Hybrid retrieval: finds candidates (evidence: `backend/app/services/contradiction_service.py`)
- Amendment resolution → Document catalogue: reads documents (evidence: `backend/app/routers/amendments.py`)
