# sainihal1500/veritrust-ai architecture

> Architecture diagram of the GitHub repository sainihal1500/veritrust-ai, 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/sainihal1500/veritrust-ai
- Repository: https://github.com/sainihal1500/veritrust-ai

## Overview

VeriTrust AI is a customer-service API that routes a customer query, gathers policy and authorized account evidence, drafts an answer, and verifies it before returning a decision and response. The documented verification stages include claim extraction, claim and policy checks, judging, correction, and a final judge. Major capabilities also include structured commerce data, session-based access control, policy RAG, and auditing. The README describes the complete workflow; source excerpts confirm selected calls, while unsampled implementation details are represented only where documented.

Main entry points: [`backend/app/workflows/veritrust_graph.py`](https://github.com/sainihal1500/veritrust-ai/blob/main/backend/app/workflows/veritrust_graph.py) (VeriTrust Workflow), [`backend/app/database/account_service.py`](https://github.com/sainihal1500/veritrust-ai/blob/main/backend/app/database/account_service.py) (Account Service), [`backend/app/api/main.py`](https://github.com/sainihal1500/veritrust-ai/blob/main/backend/app/api/main.py) (FastAPI Service), [`backend/app/security/access_control.py`](https://github.com/sainihal1500/veritrust-ai/blob/main/backend/app/security/access_control.py) (Access Control)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["Customer API"]
  node_fastapi["FastAPI Service<br/>[main.py]"]
  node_workflow["VeriTrust Workflow<br/>[veritrust_graph.py]"]
  node_query_router["Query Router<br/>[query_router.py]"]
  node_account_router["Account Router<br/>[account_router.py]"]
  node_audit["Audit and Metrics<br/>[audit.py]"]
end

subgraph group_evidence["Evidence and Access"]
  node_access["Access Control<br/>[access_control.py]"]
  node_session["Session Registry<br/>[session.py]"]
  node_account_service["Account Service<br/>[account_service.py]"]
  node_retriever["Policy Retriever<br/>[retriever.py]"]
  node_ingest["Knowledge Ingestion<br/>[ingest.py]"]
  node_knowledge["Policy Knowledge Base"]
end

subgraph group_verify["Answer Verification"]
  node_maker["Maker Agent<br/>[maker.py]"]
  node_extractor["Claim Extractor<br/>[claim_extractor.py]"]
  node_claim_verifier["Claim Verifier<br/>[claim_verifier.py]"]
  node_policy_checker["Policy Checker<br/>[policy_checker.py]"]
  node_judge["Judge Agent<br/>[judge.py]"]
  node_corrector["Corrector Agent<br/>[corrector.py]"]
  node_llm_utils["LLM Utilities<br/>[llm_utils.py]"]
end

subgraph group_data["Commerce Data"]
  node_catalog[("Catalog Data<br/>[catalog_data.py]")]
  node_customers_orders[("Customer and Order Data<br/>[customer_data.py]")]
  node_transactions[("Transaction Data")]
  node_support[("Support Case Data<br/>[support_data.py]")]
end

node_customer(("Customer"))

node_customer -->|"submits query"| node_fastapi
node_fastapi -->|"invokes workflow"| node_workflow
node_workflow -->|"routes query"| node_query_router
node_workflow -->|"routes account query"| node_account_router
node_workflow -->|"checks access"| node_access
node_access -->|"checks session"| node_session
node_workflow -->|"loads account evidence"| node_account_service
node_account_service -->|"authorizes records"| node_access
node_account_service -->|"reads catalog"| node_catalog
node_account_service -->|"reads account records"| node_customers_orders
node_account_service -->|"reads case records"| node_support
node_account_service -->|"loads transaction summary"| node_transactions
node_workflow -->|"retrieves policy evidence"| node_retriever
node_retriever -->|"searches policies"| node_knowledge
node_ingest -.->|"ingests documents"| node_knowledge
node_workflow -->|"generates draft"| node_maker
node_workflow -->|"extracts claims"| node_extractor
node_workflow -->|"verifies claims"| node_claim_verifier
node_workflow -->|"checks policies"| node_policy_checker
node_workflow -->|"judges response"| node_judge
node_workflow -->|"corrects response"| node_corrector
node_workflow -->|"rechecks correction"| node_judge
node_query_router -->|"checks model availability"| node_llm_utils
node_maker -->|"sanitizes model output"| node_llm_utils
node_workflow -.->|"returns result"| node_fastapi
node_fastapi -->|"records workflow"| node_audit
node_ingest -.->|"prepares retrieval index"| node_retriever

click node_fastapi "https://github.com/sainihal1500/veritrust-ai/blob/main/backend/app/api/main.py"
click node_workflow "https://github.com/sainihal1500/veritrust-ai/blob/main/backend/app/workflows/veritrust_graph.py"
click node_query_router "https://github.com/sainihal1500/veritrust-ai/blob/main/backend/app/agents/query_router.py"
click node_account_router "https://github.com/sainihal1500/veritrust-ai/blob/main/backend/app/agents/account_router.py"
click node_access "https://github.com/sainihal1500/veritrust-ai/blob/main/backend/app/security/access_control.py"
click node_session "https://github.com/sainihal1500/veritrust-ai/blob/main/backend/app/security/session.py"
click node_account_service "https://github.com/sainihal1500/veritrust-ai/blob/main/backend/app/database/account_service.py"
click node_retriever "https://github.com/sainihal1500/veritrust-ai/blob/main/backend/app/rag/retriever.py"
click node_ingest "https://github.com/sainihal1500/veritrust-ai/blob/main/backend/app/rag/ingest.py"
click node_knowledge "https://github.com/sainihal1500/veritrust-ai/tree/main/backend/data/knowledge_base"
click node_maker "https://github.com/sainihal1500/veritrust-ai/blob/main/backend/app/agents/maker.py"
click node_extractor "https://github.com/sainihal1500/veritrust-ai/blob/main/backend/app/agents/claim_extractor.py"
click node_claim_verifier "https://github.com/sainihal1500/veritrust-ai/blob/main/backend/app/agents/claim_verifier.py"
click node_policy_checker "https://github.com/sainihal1500/veritrust-ai/blob/main/backend/app/agents/policy_checker.py"
click node_judge "https://github.com/sainihal1500/veritrust-ai/blob/main/backend/app/agents/judge.py"
click node_corrector "https://github.com/sainihal1500/veritrust-ai/blob/main/backend/app/agents/corrector.py"
click node_llm_utils "https://github.com/sainihal1500/veritrust-ai/blob/main/backend/app/agents/llm_utils.py"
click node_audit "https://github.com/sainihal1500/veritrust-ai/blob/main/backend/app/audit.py"
click node_catalog "https://github.com/sainihal1500/veritrust-ai/blob/main/backend/app/database/catalog_data.py"
click node_customers_orders "https://github.com/sainihal1500/veritrust-ai/blob/main/backend/app/database/customer_data.py"
click node_transactions "https://github.com/sainihal1500/veritrust-ai/blob/main/backend/app/database/transaction_data.py"
click node_support "https://github.com/sainihal1500/veritrust-ai/blob/main/backend/app/database/support_data.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_fastapi,node_workflow,node_query_router,node_account_router,node_audit toneBlue
class node_access,node_session,node_account_service,node_retriever,node_ingest,node_knowledge toneAmber
class node_maker,node_extractor,node_claim_verifier,node_policy_checker,node_judge,node_corrector,node_llm_utils toneMint
class node_catalog,node_customers_orders,node_transactions,node_support toneRose
class node_customer toneIndigo
```

## Components

### Customer API

- [FastAPI Service](https://github.com/sainihal1500/veritrust-ai/blob/main/backend/app/api/main.py): `backend/app/api/main.py`
- [VeriTrust Workflow](https://github.com/sainihal1500/veritrust-ai/blob/main/backend/app/workflows/veritrust_graph.py): `backend/app/workflows/veritrust_graph.py`
- [Query Router](https://github.com/sainihal1500/veritrust-ai/blob/main/backend/app/agents/query_router.py): `backend/app/agents/query_router.py`
- [Account Router](https://github.com/sainihal1500/veritrust-ai/blob/main/backend/app/agents/account_router.py): `backend/app/agents/account_router.py`
- [Audit and Metrics](https://github.com/sainihal1500/veritrust-ai/blob/main/backend/app/audit.py): `backend/app/audit.py`

### Evidence and Access

- [Access Control](https://github.com/sainihal1500/veritrust-ai/blob/main/backend/app/security/access_control.py): `backend/app/security/access_control.py`
- [Session Registry](https://github.com/sainihal1500/veritrust-ai/blob/main/backend/app/security/session.py): `backend/app/security/session.py`
- [Account Service](https://github.com/sainihal1500/veritrust-ai/blob/main/backend/app/database/account_service.py): `backend/app/database/account_service.py`
- [Policy Retriever](https://github.com/sainihal1500/veritrust-ai/blob/main/backend/app/rag/retriever.py): `backend/app/rag/retriever.py`
- [Knowledge Ingestion](https://github.com/sainihal1500/veritrust-ai/blob/main/backend/app/rag/ingest.py): `backend/app/rag/ingest.py`
- [Policy Knowledge Base](https://github.com/sainihal1500/veritrust-ai/tree/main/backend/data/knowledge_base): `backend/data/knowledge_base`

### Answer Verification

- [Maker Agent](https://github.com/sainihal1500/veritrust-ai/blob/main/backend/app/agents/maker.py): `backend/app/agents/maker.py`
- [Claim Extractor](https://github.com/sainihal1500/veritrust-ai/blob/main/backend/app/agents/claim_extractor.py): `backend/app/agents/claim_extractor.py`
- [Claim Verifier](https://github.com/sainihal1500/veritrust-ai/blob/main/backend/app/agents/claim_verifier.py): `backend/app/agents/claim_verifier.py`
- [Policy Checker](https://github.com/sainihal1500/veritrust-ai/blob/main/backend/app/agents/policy_checker.py): `backend/app/agents/policy_checker.py`
- [Judge Agent](https://github.com/sainihal1500/veritrust-ai/blob/main/backend/app/agents/judge.py): `backend/app/agents/judge.py`
- [Corrector Agent](https://github.com/sainihal1500/veritrust-ai/blob/main/backend/app/agents/corrector.py): `backend/app/agents/corrector.py`
- [LLM Utilities](https://github.com/sainihal1500/veritrust-ai/blob/main/backend/app/agents/llm_utils.py): `backend/app/agents/llm_utils.py`

### Commerce Data

- [Catalog Data](https://github.com/sainihal1500/veritrust-ai/blob/main/backend/app/database/catalog_data.py): `backend/app/database/catalog_data.py`
- [Customer and Order Data](https://github.com/sainihal1500/veritrust-ai/blob/main/backend/app/database/customer_data.py): `backend/app/database/customer_data.py`
- [Transaction Data](https://github.com/sainihal1500/veritrust-ai/blob/main/backend/app/database/transaction_data.py): `backend/app/database/transaction_data.py`
- [Support Case Data](https://github.com/sainihal1500/veritrust-ai/blob/main/backend/app/database/support_data.py): `backend/app/database/support_data.py`

### Other components

- **Customer**

## Connections

- Customer → FastAPI Service: submits query (evidence: `README.md`)
- FastAPI Service → VeriTrust Workflow: invokes workflow (evidence: `backend/app/api/main.py`)
- VeriTrust Workflow → Query Router: routes query (evidence: `backend/app/workflows/veritrust_graph.py`)
- VeriTrust Workflow → Account Router: routes account query (evidence: `backend/app/workflows/veritrust_graph.py`)
- VeriTrust Workflow → Access Control: checks access (evidence: `backend/app/workflows/veritrust_graph.py`)
- Access Control → Session Registry: checks session (evidence: `backend/app/security/access_control.py`)
- VeriTrust Workflow → Account Service: loads account evidence (evidence: `backend/app/workflows/veritrust_graph.py`)
- Account Service → Access Control: authorizes records (evidence: `backend/app/database/account_service.py`)
- Account Service → Catalog Data: reads catalog (evidence: `backend/app/database/account_service.py`)
- Account Service → Customer and Order Data: reads account records (evidence: `backend/app/database/account_service.py`)
- Account Service → Support Case Data: reads case records (evidence: `backend/app/database/account_service.py`)
- Account Service → Transaction Data: loads transaction summary (evidence: `backend/app/database/account_service.py`)
- VeriTrust Workflow → Policy Retriever: retrieves policy evidence (evidence: `backend/app/workflows/veritrust_graph.py`)
- Policy Retriever → Policy Knowledge Base: searches policies (evidence: `README.md`)
- Knowledge Ingestion → Policy Knowledge Base: ingests documents
- VeriTrust Workflow → Maker Agent: generates draft (evidence: `README.md`)
- VeriTrust Workflow → Claim Extractor: extracts claims (evidence: `README.md`)
- VeriTrust Workflow → Claim Verifier: verifies claims (evidence: `README.md`)
- VeriTrust Workflow → Policy Checker: checks policies (evidence: `README.md`)
- VeriTrust Workflow → Judge Agent: judges response (evidence: `README.md`)
- VeriTrust Workflow → Corrector Agent: corrects response (evidence: `README.md`)
- VeriTrust Workflow → Judge Agent: rechecks correction (evidence: `README.md`)
- Query Router → LLM Utilities: checks model availability (evidence: `backend/app/agents/query_router.py`)
- Maker Agent → LLM Utilities: sanitizes model output (evidence: `backend/app/agents/maker.py`)
- VeriTrust Workflow → FastAPI Service: returns result (evidence: `backend/app/api/main.py`)
- FastAPI Service → Audit and Metrics: records workflow (evidence: `backend/app/api/main.py`)
- Knowledge Ingestion → Policy Retriever: prepares retrieval index
