# ashneetjha/finvision-ai architecture

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

- Interactive diagram: https://gitdiagram.com/ashneetjha/finvision-ai
- Repository: https://github.com/ashneetjha/finvision-ai

## Overview

FinVision AI is a document-digitization and invoice-audit web application. A client submits an invoice or selects a sample; the FastAPI orchestrator coordinates ingestion, OCR, table and financial extraction, signature detection, optional benchmarking, audit decisions, and report generation. Session workspaces retain inputs and reports, while the UI and download routes expose results. The README documents the overall workflow and capabilities; some internal wiring is supported by the sampled source index rather than complete app excerpts.

Main entry points: [`src/app.py`](https://github.com/ashneetjha/finvision-ai/blob/main/src/app.py) (FastAPI orchestrator), [`src/agents/audit_agent.py`](https://github.com/ashneetjha/finvision-ai/blob/main/src/agents/audit_agent.py) (Audit decisions), [`src/agents/ocr_agent.py`](https://github.com/ashneetjha/finvision-ai/blob/main/src/agents/ocr_agent.py) (OCR perception), [`src/agents/reporting_agent.py`](https://github.com/ashneetjha/finvision-ai/blob/main/src/agents/reporting_agent.py) (Workbook reporting)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web and orchestration"]
  node_api["FastAPI orchestrator<br/>[app.py]"]
  node_console["Audit console<br/>[index.html]"]
end

subgraph group_extract["Document extraction"]
  node_ingestion["Ingestion<br/>[ingestion_agent.py]"]
  node_ocr["OCR perception<br/>[ocr_agent.py]"]
  node_tables["Table reconstruction<br/>[table_agent.py]"]
  node_financial["Financial extraction<br/>[financial_agent.py]"]
  node_signature["Signature detection<br/>[signature_agent.py]"]
end

subgraph group_audit["Validation and provenance"]
  node_evaluation["Benchmark evaluation"]
  node_audit_engine["Audit decisions<br/>[audit_agent.py]"]
  node_trace["Traceability<br/>[traceability.py]"]
end

subgraph group_results["Reports and storage"]
  node_reporting["Workbook reporting<br/>[reporting_agent.py]"]
  node_sessions[("Session workspaces")]
  node_output[("Report output")]
end

node_client(("Client"))

node_client -->|"submits document"| node_api
node_api -->|"serves console"| node_console
node_api -->|"ingests input"| node_ingestion
node_api -->|"runs OCR"| node_ocr
node_api -->|"reconstructs tables"| node_tables
node_api -->|"extracts fields"| node_financial
node_api -->|"checks authorization"| node_signature
node_api -->|"benchmarks extraction"| node_evaluation
node_api -->|"audits document"| node_audit_engine
node_api -->|"builds provenance"| node_trace
node_api -->|"generates workbook"| node_reporting
node_ingestion -->|"stores session input"| node_sessions
node_api -->|"reads session files"| node_sessions
node_financial -->|"uses OCR tokens"| node_ocr
node_tables -->|"uses OCR tokens"| node_ocr
node_audit_engine -->|"checks extracted fields"| node_financial
node_audit_engine -->|"checks signature result"| node_signature
node_audit_engine -->|"checks confidence"| node_ocr
node_audit_engine -->|"uses table structure"| node_tables
node_trace -->|"records field lineage"| node_financial
node_trace -->|"resolves source tokens"| node_ocr
node_reporting -->|"renders provenance"| node_trace
node_reporting -->|"writes session report"| node_sessions
node_reporting -->|"writes fallback report"| node_output
node_api -->|"returns results"| node_client

click node_api "https://github.com/ashneetjha/finvision-ai/blob/main/src/app.py"
click node_console "https://github.com/ashneetjha/finvision-ai/blob/main/templates/index.html"
click node_ingestion "https://github.com/ashneetjha/finvision-ai/blob/main/src/agents/ingestion_agent.py"
click node_ocr "https://github.com/ashneetjha/finvision-ai/blob/main/src/agents/ocr_agent.py"
click node_tables "https://github.com/ashneetjha/finvision-ai/blob/main/src/agents/table_agent.py"
click node_financial "https://github.com/ashneetjha/finvision-ai/blob/main/src/agents/financial_agent.py"
click node_signature "https://github.com/ashneetjha/finvision-ai/blob/main/src/agents/signature_agent.py"
click node_evaluation "https://github.com/ashneetjha/finvision-ai/blob/main/src/agents/evaluation_agent.py"
click node_audit_engine "https://github.com/ashneetjha/finvision-ai/blob/main/src/agents/audit_agent.py"
click node_trace "https://github.com/ashneetjha/finvision-ai/blob/main/src/agents/traceability.py"
click node_reporting "https://github.com/ashneetjha/finvision-ai/blob/main/src/agents/reporting_agent.py"
click node_sessions "https://github.com/ashneetjha/finvision-ai/tree/main/data/sessions"
click node_output "https://github.com/ashneetjha/finvision-ai/tree/main/data/output"

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_api,node_console,node_client toneBlue
class node_ingestion,node_ocr,node_tables,node_financial,node_signature toneAmber
class node_evaluation,node_audit_engine,node_trace toneMint
class node_reporting,node_sessions,node_output toneRose
```

## Components

### Web and orchestration

- [FastAPI orchestrator](https://github.com/ashneetjha/finvision-ai/blob/main/src/app.py): `src/app.py`
- [Audit console](https://github.com/ashneetjha/finvision-ai/blob/main/templates/index.html): `templates/index.html`

### Document extraction

- [Ingestion](https://github.com/ashneetjha/finvision-ai/blob/main/src/agents/ingestion_agent.py): `src/agents/ingestion_agent.py`
- [OCR perception](https://github.com/ashneetjha/finvision-ai/blob/main/src/agents/ocr_agent.py): `src/agents/ocr_agent.py`
- [Table reconstruction](https://github.com/ashneetjha/finvision-ai/blob/main/src/agents/table_agent.py): `src/agents/table_agent.py`
- [Financial extraction](https://github.com/ashneetjha/finvision-ai/blob/main/src/agents/financial_agent.py): `src/agents/financial_agent.py`
- [Signature detection](https://github.com/ashneetjha/finvision-ai/blob/main/src/agents/signature_agent.py): `src/agents/signature_agent.py`

### Validation and provenance

- [Benchmark evaluation](https://github.com/ashneetjha/finvision-ai/blob/main/src/agents/evaluation_agent.py): `src/agents/evaluation_agent.py`
- [Audit decisions](https://github.com/ashneetjha/finvision-ai/blob/main/src/agents/audit_agent.py): `src/agents/audit_agent.py`
- [Traceability](https://github.com/ashneetjha/finvision-ai/blob/main/src/agents/traceability.py): `src/agents/traceability.py`

### Reports and storage

- [Workbook reporting](https://github.com/ashneetjha/finvision-ai/blob/main/src/agents/reporting_agent.py): `src/agents/reporting_agent.py`
- [Session workspaces](https://github.com/ashneetjha/finvision-ai/tree/main/data/sessions): `data/sessions`
- [Report output](https://github.com/ashneetjha/finvision-ai/tree/main/data/output): `data/output`

### Other components

- **Client**

## Connections

- Client → FastAPI orchestrator: submits document (evidence: `README.md`)
- FastAPI orchestrator → Audit console: serves console (evidence: `src/app.py`)
- FastAPI orchestrator → Ingestion: ingests input (evidence: `src/app.py`)
- FastAPI orchestrator → OCR perception: runs OCR (evidence: `README.md`)
- FastAPI orchestrator → Table reconstruction: reconstructs tables (evidence: `README.md`)
- FastAPI orchestrator → Financial extraction: extracts fields (evidence: `README.md`)
- FastAPI orchestrator → Signature detection: checks authorization (evidence: `README.md`)
- FastAPI orchestrator → Benchmark evaluation: benchmarks extraction (evidence: `README.md`)
- FastAPI orchestrator → Audit decisions: audits document (evidence: `README.md`)
- FastAPI orchestrator → Traceability: builds provenance (evidence: `README.md`)
- FastAPI orchestrator → Workbook reporting: generates workbook (evidence: `README.md`)
- Ingestion → Session workspaces: stores session input (evidence: `README.md`)
- FastAPI orchestrator → Session workspaces: reads session files (evidence: `src/app.py`)
- Financial extraction → OCR perception: uses OCR tokens (evidence: `src/agents/financial_agent.py`)
- Table reconstruction → OCR perception: uses OCR tokens (evidence: `src/agents/table_agent.py`)
- Audit decisions → Financial extraction: checks extracted fields (evidence: `src/agents/audit_agent.py`)
- Audit decisions → Signature detection: checks signature result (evidence: `src/agents/audit_agent.py`)
- Audit decisions → OCR perception: checks confidence (evidence: `src/agents/audit_agent.py`)
- Audit decisions → Table reconstruction: uses table structure (evidence: `src/agents/audit_agent.py`)
- Traceability → Financial extraction: records field lineage (evidence: `src/agents/traceability.py`)
- Traceability → OCR perception: resolves source tokens (evidence: `src/agents/traceability.py`)
- Workbook reporting → Traceability: renders provenance (evidence: `src/agents/reporting_agent.py`)
- Workbook reporting → Session workspaces: writes session report (evidence: `README.md`)
- Workbook reporting → Report output: writes fallback report (evidence: `src/agents/reporting_agent.py`)
- FastAPI orchestrator → Client: returns results (evidence: `README.md`)
