# ayush-nagar55/veridoc-document-intelligence architecture

> Architecture diagram of the GitHub repository ayush-nagar55/veridoc-document-intelligence, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-26). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ayush-nagar55/veridoc-document-intelligence
- Repository: https://github.com/ayush-nagar55/veridoc-document-intelligence

## Overview

VeriDoc turns uploaded files into validated, reviewable, searchable knowledge, then answers questions with evidence and confidence. The main path runs from the browser through the document API and background pipeline, from format-aware reading through extraction, independent validation, confidence-based review routing, and indexing. Separate user workflows cover human review, grounded multi-document queries, comparison, exports, and analytics. The README documents additional capabilities whose route-to-service wiring is not shown in the sampled source; those are represented without speculative call edges.

Main entry points: [`backend/app/services/pipeline.py`](https://github.com/ayush-nagar55/veridoc-document-intelligence/blob/main/backend/app/services/pipeline.py) (Processing pipeline), [`backend/app/api/router.py`](https://github.com/ayush-nagar55/veridoc-document-intelligence/blob/main/backend/app/api/router.py) (Route registry), [`backend/app/database.py`](https://github.com/ayush-nagar55/veridoc-document-intelligence/blob/main/backend/app/database.py) (Application records), [`backend/app/api/routes/documents.py`](https://github.com/ayush-nagar55/veridoc-document-intelligence/blob/main/backend/app/api/routes/documents.py) (Document routes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Web application"]
  node_web["Web pages"]
  node_clientapi["API client<br/>[client.ts]"]
end

subgraph group_api["API workflows"]
  node_app["API application<br/>[main.py]"]
  node_router["Route registry<br/>[router.py]"]
  node_documents["Document routes<br/>[documents.py]"]
  node_review["Review routes<br/>[review.py]"]
  node_query["Query routes<br/>[query.py]"]
  node_compare["Comparison routes<br/>[compare.py]"]
  node_analytics["Analytics routes<br/>[analytics.py]"]
end

subgraph group_processing["Document processing"]
  node_pipeline["Processing pipeline<br/>[pipeline.py]"]
  node_processors["Format processors<br/>[factory.py]"]
  node_ocr["OCR<br/>[ocr_service.py]"]
  node_extraction["Field extraction"]
  node_llm["LLM provider<br/>[factory.py]"]
  node_validation["Independent validation"]
  node_confidence["Review threshold"]
  node_quality["Quality and summary<br/>[summary_service.py]"]
  node_pii["PII detection<br/>[pii_service.py]"]
  node_duplicates["Duplicate detection"]
  node_comparison["Document comparison"]
end

subgraph group_knowledge["Verified knowledge"]
  node_rag["Grounded RAG<br/>[rag_service.py]"]
  node_embedding["Embedding service"]
  node_vectors[("Vector index<br/>[vector_store.py]")]
  node_storage["File storage<br/>[storage.py]"]
  node_database[("Application records<br/>[database.py]")]
  node_audit["Audit trail<br/>[audit_service.py]"]
end

node_user(("User"))
node_actorllm(("Configured model"))

node_user -->|"uses"| node_web
node_web -->|"requests"| node_clientapi
node_clientapi -->|"HTTP calls"| node_router
node_app -->|"mounts routes"| node_router
node_router -->|"dispatches"| node_documents
node_router -->|"dispatches"| node_review
node_router -->|"dispatches"| node_query
node_router -->|"dispatches"| node_compare
node_router -->|"dispatches"| node_analytics
node_documents -->|"starts processing"| node_pipeline
node_documents -->|"stores files"| node_storage
node_pipeline -->|"reads document"| node_processors
node_processors -.->|"OCR fallback"| node_ocr
node_pipeline -->|"extracts fields"| node_extraction
node_extraction -->|"requests extraction"| node_llm
node_llm -.->|"calls provider"| node_actorllm
node_pipeline -->|"validates fields"| node_validation
node_pipeline -->|"routes uncertain fields"| node_confidence
node_pipeline -->|"computes quality"| node_quality
node_pipeline -->|"scans text"| node_pii
node_pipeline -->|"checks duplicates"| node_duplicates
node_pipeline -->|"indexes document"| node_rag
node_rag -->|"embeds text"| node_embedding
node_rag -->|"updates and searches"| node_vectors
node_query -->|"asks question"| node_rag
node_query -->|"logs query"| node_database
node_review -->|"records decisions"| node_database
node_review -->|"records review"| node_audit
node_pipeline -->|"records processing"| node_audit
node_compare -->|"compares documents"| node_comparison
node_documents -->|"reads and writes records"| node_database
node_pipeline -->|"persists results"| node_database
node_analytics -->|"reads metrics"| node_database

click node_web "https://github.com/ayush-nagar55/veridoc-document-intelligence/tree/main/frontend/src/pages"
click node_clientapi "https://github.com/ayush-nagar55/veridoc-document-intelligence/blob/main/frontend/src/api/client.ts"
click node_app "https://github.com/ayush-nagar55/veridoc-document-intelligence/blob/main/backend/app/main.py"
click node_router "https://github.com/ayush-nagar55/veridoc-document-intelligence/blob/main/backend/app/api/router.py"
click node_documents "https://github.com/ayush-nagar55/veridoc-document-intelligence/blob/main/backend/app/api/routes/documents.py"
click node_review "https://github.com/ayush-nagar55/veridoc-document-intelligence/blob/main/backend/app/api/routes/review.py"
click node_query "https://github.com/ayush-nagar55/veridoc-document-intelligence/blob/main/backend/app/api/routes/query.py"
click node_compare "https://github.com/ayush-nagar55/veridoc-document-intelligence/blob/main/backend/app/api/routes/compare.py"
click node_analytics "https://github.com/ayush-nagar55/veridoc-document-intelligence/blob/main/backend/app/api/routes/analytics.py"
click node_pipeline "https://github.com/ayush-nagar55/veridoc-document-intelligence/blob/main/backend/app/services/pipeline.py"
click node_processors "https://github.com/ayush-nagar55/veridoc-document-intelligence/blob/main/backend/app/services/processors/factory.py"
click node_ocr "https://github.com/ayush-nagar55/veridoc-document-intelligence/blob/main/backend/app/services/ocr_service.py"
click node_extraction "https://github.com/ayush-nagar55/veridoc-document-intelligence/blob/main/backend/app/services/extraction_service.py"
click node_llm "https://github.com/ayush-nagar55/veridoc-document-intelligence/blob/main/backend/app/services/llm/factory.py"
click node_validation "https://github.com/ayush-nagar55/veridoc-document-intelligence/blob/main/backend/app/services/validation_service.py"
click node_confidence "https://github.com/ayush-nagar55/veridoc-document-intelligence/blob/main/backend/app/services/confidence_service.py"
click node_quality "https://github.com/ayush-nagar55/veridoc-document-intelligence/blob/main/backend/app/services/summary_service.py"
click node_pii "https://github.com/ayush-nagar55/veridoc-document-intelligence/blob/main/backend/app/services/pii_service.py"
click node_duplicates "https://github.com/ayush-nagar55/veridoc-document-intelligence/blob/main/backend/app/services/duplicate_service.py"
click node_comparison "https://github.com/ayush-nagar55/veridoc-document-intelligence/blob/main/backend/app/services/comparison_service.py"
click node_rag "https://github.com/ayush-nagar55/veridoc-document-intelligence/blob/main/backend/app/services/rag_service.py"
click node_embedding "https://github.com/ayush-nagar55/veridoc-document-intelligence/blob/main/backend/app/services/embedding_service.py"
click node_vectors "https://github.com/ayush-nagar55/veridoc-document-intelligence/blob/main/backend/app/services/vector_store.py"
click node_storage "https://github.com/ayush-nagar55/veridoc-document-intelligence/blob/main/backend/app/services/storage.py"
click node_database "https://github.com/ayush-nagar55/veridoc-document-intelligence/blob/main/backend/app/database.py"
click node_audit "https://github.com/ayush-nagar55/veridoc-document-intelligence/blob/main/backend/app/services/audit_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_web,node_clientapi,node_user toneBlue
class node_app,node_router,node_documents,node_review,node_query,node_compare,node_analytics toneAmber
class node_pipeline,node_processors,node_ocr,node_extraction,node_llm,node_validation,node_confidence,node_quality,node_pii,node_duplicates,node_comparison toneMint
class node_rag,node_embedding,node_vectors,node_storage,node_database,node_audit toneRose
class node_actorllm toneIndigo
```

## Components

### Web application

- [Web pages](https://github.com/ayush-nagar55/veridoc-document-intelligence/tree/main/frontend/src/pages): `frontend/src/pages`
- [API client](https://github.com/ayush-nagar55/veridoc-document-intelligence/blob/main/frontend/src/api/client.ts): `frontend/src/api/client.ts`

### API workflows

- [API application](https://github.com/ayush-nagar55/veridoc-document-intelligence/blob/main/backend/app/main.py): `backend/app/main.py`
- [Route registry](https://github.com/ayush-nagar55/veridoc-document-intelligence/blob/main/backend/app/api/router.py): `backend/app/api/router.py`
- [Document routes](https://github.com/ayush-nagar55/veridoc-document-intelligence/blob/main/backend/app/api/routes/documents.py): `backend/app/api/routes/documents.py`
- [Review routes](https://github.com/ayush-nagar55/veridoc-document-intelligence/blob/main/backend/app/api/routes/review.py): `backend/app/api/routes/review.py`
- [Query routes](https://github.com/ayush-nagar55/veridoc-document-intelligence/blob/main/backend/app/api/routes/query.py): `backend/app/api/routes/query.py`
- [Comparison routes](https://github.com/ayush-nagar55/veridoc-document-intelligence/blob/main/backend/app/api/routes/compare.py): `backend/app/api/routes/compare.py`
- [Analytics routes](https://github.com/ayush-nagar55/veridoc-document-intelligence/blob/main/backend/app/api/routes/analytics.py): `backend/app/api/routes/analytics.py`

### Document processing

- [Processing pipeline](https://github.com/ayush-nagar55/veridoc-document-intelligence/blob/main/backend/app/services/pipeline.py): `backend/app/services/pipeline.py`
- [Format processors](https://github.com/ayush-nagar55/veridoc-document-intelligence/blob/main/backend/app/services/processors/factory.py): `backend/app/services/processors/factory.py`
- [OCR](https://github.com/ayush-nagar55/veridoc-document-intelligence/blob/main/backend/app/services/ocr_service.py): `backend/app/services/ocr_service.py`
- [Field extraction](https://github.com/ayush-nagar55/veridoc-document-intelligence/blob/main/backend/app/services/extraction_service.py): `backend/app/services/extraction_service.py`
- [LLM provider](https://github.com/ayush-nagar55/veridoc-document-intelligence/blob/main/backend/app/services/llm/factory.py): `backend/app/services/llm/factory.py`
- [Independent validation](https://github.com/ayush-nagar55/veridoc-document-intelligence/blob/main/backend/app/services/validation_service.py): `backend/app/services/validation_service.py`
- [Review threshold](https://github.com/ayush-nagar55/veridoc-document-intelligence/blob/main/backend/app/services/confidence_service.py): `backend/app/services/confidence_service.py`
- [Quality and summary](https://github.com/ayush-nagar55/veridoc-document-intelligence/blob/main/backend/app/services/summary_service.py): `backend/app/services/summary_service.py`
- [PII detection](https://github.com/ayush-nagar55/veridoc-document-intelligence/blob/main/backend/app/services/pii_service.py): `backend/app/services/pii_service.py`
- [Duplicate detection](https://github.com/ayush-nagar55/veridoc-document-intelligence/blob/main/backend/app/services/duplicate_service.py): `backend/app/services/duplicate_service.py`
- [Document comparison](https://github.com/ayush-nagar55/veridoc-document-intelligence/blob/main/backend/app/services/comparison_service.py): `backend/app/services/comparison_service.py`

### Verified knowledge

- [Grounded RAG](https://github.com/ayush-nagar55/veridoc-document-intelligence/blob/main/backend/app/services/rag_service.py): `backend/app/services/rag_service.py`
- [Embedding service](https://github.com/ayush-nagar55/veridoc-document-intelligence/blob/main/backend/app/services/embedding_service.py): `backend/app/services/embedding_service.py`
- [Vector index](https://github.com/ayush-nagar55/veridoc-document-intelligence/blob/main/backend/app/services/vector_store.py): `backend/app/services/vector_store.py`
- [File storage](https://github.com/ayush-nagar55/veridoc-document-intelligence/blob/main/backend/app/services/storage.py): `backend/app/services/storage.py`
- [Application records](https://github.com/ayush-nagar55/veridoc-document-intelligence/blob/main/backend/app/database.py): `backend/app/database.py`
- [Audit trail](https://github.com/ayush-nagar55/veridoc-document-intelligence/blob/main/backend/app/services/audit_service.py): `backend/app/services/audit_service.py`

### Other components

- **User**
- **Configured model**

## Connections

- User → Web pages: uses
- Web pages → API client: requests
- API client → Route registry: HTTP calls
- API application → Route registry: mounts routes
- Route registry → Document routes: dispatches
- Route registry → Review routes: dispatches
- Route registry → Query routes: dispatches
- Route registry → Comparison routes: dispatches
- Route registry → Analytics routes: dispatches
- Document routes → Processing pipeline: starts processing
- Document routes → File storage: stores files
- Processing pipeline → Format processors: reads document
- Format processors → OCR: OCR fallback
- Processing pipeline → Field extraction: extracts fields
- Field extraction → LLM provider: requests extraction
- LLM provider → Configured model: calls provider
- Processing pipeline → Independent validation: validates fields
- Processing pipeline → Review threshold: routes uncertain fields
- Processing pipeline → Quality and summary: computes quality
- Processing pipeline → PII detection: scans text
- Processing pipeline → Duplicate detection: checks duplicates
- Processing pipeline → Grounded RAG: indexes document
- Grounded RAG → Embedding service: embeds text
- Grounded RAG → Vector index: updates and searches
- Query routes → Grounded RAG: asks question
- Query routes → Application records: logs query
- Review routes → Application records: records decisions
- Review routes → Audit trail: records review
- Processing pipeline → Audit trail: records processing
- Comparison routes → Document comparison: compares documents
- Document routes → Application records: reads and writes records
- Processing pipeline → Application records: persists results
- Analytics routes → Application records: reads metrics
