# varadganjoo/enterprise-ai-systems architecture

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

## Overview

This repository is a portfolio of nine independent FastAPI AI applications, not one end-to-end service. The README groups them into retrieval and fact verification, autonomous operations and human review, and AI infrastructure and governance. The graph preserves each system’s documented domain stages; source-index references and sampled excerpts support the shown internal links. Unsampled implementation details and cross-application runtime connections are intentionally omitted.

Main entry points: [`01-cited-knowledge-agent/app/main.py`](https://github.com/varadganjoo/enterprise-ai-systems/blob/main/01-cited-knowledge-agent/app/main.py) (Knowledge API), [`02-document-extraction/app/main.py`](https://github.com/varadganjoo/enterprise-ai-systems/blob/main/02-document-extraction/app/main.py) (Extraction API), [`04-analytics-copilot/app/copilot.py`](https://github.com/varadganjoo/enterprise-ai-systems/blob/main/04-analytics-copilot/app/copilot.py) (Analytics Copilot), [`01-cited-knowledge-agent/app/service.py`](https://github.com/varadganjoo/enterprise-ai-systems/blob/main/01-cited-knowledge-agent/app/service.py) (Grounded Answers)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_retrieval["Retrieval &amp; Verification"]
  node_k_api["Knowledge API<br/>[main.py]"]
  node_k_corpus["Corpus Loading<br/>[corpus.py]"]
  node_k_vectors["Embedding Index<br/>[embeddings.py]"]
  node_k_retrieval["Hybrid Retrieval<br/>[retrieve.py]"]
  node_k_answer["Grounded Answers<br/>[service.py]"]
  node_k_verify["Span Governance<br/>[grounding.py]"]
  node_audit_api["Auditor API<br/>[main.py]"]
  node_audit["Claim Verification<br/>[audit.py]"]
  node_brief_api["Brief API<br/>[main.py]"]
  node_brief["DAG Hop Planning<br/>[hops.py]"]
end

subgraph group_operations["Operations &amp; HITL"]
  node_invoice_api["Extraction API<br/>[main.py]"]
  node_extract["Invoice Extraction<br/>[extract.py]"]
  node_review["Reconcile &amp; Triage<br/>[review.py]"]
  node_po_match["Purchase Matching<br/>[match.py]"]
  node_invoice_store[("Review Storage<br/>[store.py]")]
  node_operator_api["Operator API<br/>[main.py]"]
  node_operator["Support Agent<br/>[agent.py]"]
  node_operator_policy["Action Policy<br/>[policy.py]"]
  node_operator_store[("Approval Queue<br/>[store.py]")]
  node_case_api["Case API<br/>[main.py]"]
  node_case_machine["Refund State Machine<br/>[machine.py]"]
  node_case_store[("Event Log<br/>[store.py]")]
end

subgraph group_infrastructure["Infrastructure &amp; Governance"]
  node_analytics_api["Analytics API<br/>[main.py]"]
  node_copilot["Analytics Copilot<br/>[copilot.py]"]
  node_sql_guard["SQL AST Guard<br/>[guard.py]"]
  node_metrics["Query Metrics<br/>[metrics.py]"]
  node_seed[("Analytics Data<br/>[seed.py]")]
  node_router_api["Router API<br/>[main.py]"]
  node_router["Tiered Model Routing<br/>[router.py]"]
  node_router_llm["Model Calls<br/>[llm.py]"]
  node_memory_api["Memory API<br/>[main.py]"]
  node_memory_service["PII Redaction<br/>[service.py]"]
  node_memory_ops["Entity Slot Memory<br/>[memory.py]"]
end

node_user(("User"))

node_user -->|"asks"| node_k_api
node_k_api -->|"loads"| node_k_corpus
node_k_api -->|"loads"| node_k_vectors
node_k_api -->|"builds index"| node_k_retrieval
node_k_api -->|"answers"| node_k_answer
node_k_answer -->|"retrieves"| node_k_retrieval
node_k_retrieval -->|"ranks chunks"| node_k_corpus
node_k_answer -->|"grounds citations"| node_k_verify
node_user -->|"submits content"| node_audit_api
node_audit_api -->|"audits claims"| node_audit
node_user -->|"asks question"| node_brief_api
node_brief_api -->|"plans hops"| node_brief
node_user -->|"submits invoice"| node_invoice_api
node_invoice_api -->|"extracts fields"| node_extract
node_invoice_api -->|"checks extraction"| node_review
node_review -->|"matches orders"| node_po_match
node_invoice_api -->|"records reviews"| node_invoice_store
node_user -->|"sets goal"| node_operator_api
node_operator_api -->|"runs agent"| node_operator
node_operator -->|"checks actions"| node_operator_policy
node_operator_api -->|"queues approvals"| node_operator_store
node_user -->|"opens case"| node_case_api
node_case_api -->|"applies transitions"| node_case_machine
node_case_api -->|"commits events"| node_case_store
node_case_store -->|"projects state"| node_case_machine
node_user -->|"asks analytics"| node_analytics_api
node_analytics_api -->|"handles query"| node_copilot
node_copilot -->|"validates SQL"| node_sql_guard
node_copilot -->|"tracks queries"| node_metrics
node_copilot -->|"uses sample data"| node_seed
node_user -->|"submits task"| node_router_api
node_router_api -->|"selects tier"| node_router
node_router_api -->|"generates answer"| node_router_llm
node_router -->|"supports routing"| node_router_llm
node_user -->|"chats"| node_memory_api
node_memory_api -->|"redacts PII"| node_memory_service
node_memory_api -->|"manages memories"| node_memory_ops
node_memory_ops -->|"redacts context"| node_memory_service

click node_k_api "https://github.com/varadganjoo/enterprise-ai-systems/blob/main/01-cited-knowledge-agent/app/main.py"
click node_k_corpus "https://github.com/varadganjoo/enterprise-ai-systems/blob/main/01-cited-knowledge-agent/app/corpus.py"
click node_k_vectors "https://github.com/varadganjoo/enterprise-ai-systems/blob/main/01-cited-knowledge-agent/app/embeddings.py"
click node_k_retrieval "https://github.com/varadganjoo/enterprise-ai-systems/blob/main/01-cited-knowledge-agent/app/retrieve.py"
click node_k_answer "https://github.com/varadganjoo/enterprise-ai-systems/blob/main/01-cited-knowledge-agent/app/service.py"
click node_k_verify "https://github.com/varadganjoo/enterprise-ai-systems/blob/main/01-cited-knowledge-agent/app/grounding.py"
click node_audit_api "https://github.com/varadganjoo/enterprise-ai-systems/blob/main/07-claim-auditor/app/main.py"
click node_audit "https://github.com/varadganjoo/enterprise-ai-systems/blob/main/07-claim-auditor/app/audit.py"
click node_brief_api "https://github.com/varadganjoo/enterprise-ai-systems/blob/main/09-multi-hop-brief/app/main.py"
click node_brief "https://github.com/varadganjoo/enterprise-ai-systems/blob/main/09-multi-hop-brief/app/hops.py"
click node_invoice_api "https://github.com/varadganjoo/enterprise-ai-systems/blob/main/02-document-extraction/app/main.py"
click node_extract "https://github.com/varadganjoo/enterprise-ai-systems/blob/main/02-document-extraction/app/extract.py"
click node_review "https://github.com/varadganjoo/enterprise-ai-systems/blob/main/02-document-extraction/app/review.py"
click node_po_match "https://github.com/varadganjoo/enterprise-ai-systems/blob/main/02-document-extraction/app/match.py"
click node_invoice_store "https://github.com/varadganjoo/enterprise-ai-systems/blob/main/02-document-extraction/app/store.py"
click node_operator_api "https://github.com/varadganjoo/enterprise-ai-systems/blob/main/03-operator-agent/app/main.py"
click node_operator "https://github.com/varadganjoo/enterprise-ai-systems/blob/main/03-operator-agent/app/agent.py"
click node_operator_policy "https://github.com/varadganjoo/enterprise-ai-systems/blob/main/03-operator-agent/app/policy.py"
click node_operator_store "https://github.com/varadganjoo/enterprise-ai-systems/blob/main/03-operator-agent/app/store.py"
click node_case_api "https://github.com/varadganjoo/enterprise-ai-systems/blob/main/08-case-workflow/app/main.py"
click node_case_machine "https://github.com/varadganjoo/enterprise-ai-systems/blob/main/08-case-workflow/app/machine.py"
click node_case_store "https://github.com/varadganjoo/enterprise-ai-systems/blob/main/08-case-workflow/app/store.py"
click node_analytics_api "https://github.com/varadganjoo/enterprise-ai-systems/blob/main/04-analytics-copilot/app/main.py"
click node_copilot "https://github.com/varadganjoo/enterprise-ai-systems/blob/main/04-analytics-copilot/app/copilot.py"
click node_sql_guard "https://github.com/varadganjoo/enterprise-ai-systems/blob/main/04-analytics-copilot/app/guard.py"
click node_metrics "https://github.com/varadganjoo/enterprise-ai-systems/blob/main/04-analytics-copilot/app/metrics.py"
click node_seed "https://github.com/varadganjoo/enterprise-ai-systems/blob/main/04-analytics-copilot/app/seed.py"
click node_router_api "https://github.com/varadganjoo/enterprise-ai-systems/blob/main/05-model-router/app/main.py"
click node_router "https://github.com/varadganjoo/enterprise-ai-systems/blob/main/05-model-router/app/router.py"
click node_router_llm "https://github.com/varadganjoo/enterprise-ai-systems/blob/main/05-model-router/app/llm.py"
click node_memory_api "https://github.com/varadganjoo/enterprise-ai-systems/blob/main/06-memory-service/app/main.py"
click node_memory_service "https://github.com/varadganjoo/enterprise-ai-systems/blob/main/06-memory-service/app/service.py"
click node_memory_ops "https://github.com/varadganjoo/enterprise-ai-systems/blob/main/06-memory-service/app/memory.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_k_api,node_k_corpus,node_k_vectors,node_k_retrieval,node_k_answer,node_k_verify,node_audit_api,node_audit,node_brief_api,node_brief,node_user toneBlue
class node_invoice_api,node_extract,node_review,node_po_match,node_invoice_store,node_operator_api,node_operator,node_operator_policy,node_operator_store,node_case_api,node_case_machine,node_case_store toneAmber
class node_analytics_api,node_copilot,node_sql_guard,node_metrics,node_seed,node_router_api,node_router,node_router_llm,node_memory_api,node_memory_service,node_memory_ops toneMint
```

## Components

### Retrieval & Verification

- [Knowledge API](https://github.com/varadganjoo/enterprise-ai-systems/blob/main/01-cited-knowledge-agent/app/main.py): `01-cited-knowledge-agent/app/main.py`
- [Corpus Loading](https://github.com/varadganjoo/enterprise-ai-systems/blob/main/01-cited-knowledge-agent/app/corpus.py): `01-cited-knowledge-agent/app/corpus.py`
- [Embedding Index](https://github.com/varadganjoo/enterprise-ai-systems/blob/main/01-cited-knowledge-agent/app/embeddings.py): `01-cited-knowledge-agent/app/embeddings.py`
- [Hybrid Retrieval](https://github.com/varadganjoo/enterprise-ai-systems/blob/main/01-cited-knowledge-agent/app/retrieve.py): `01-cited-knowledge-agent/app/retrieve.py`
- [Grounded Answers](https://github.com/varadganjoo/enterprise-ai-systems/blob/main/01-cited-knowledge-agent/app/service.py): `01-cited-knowledge-agent/app/service.py`
- [Span Governance](https://github.com/varadganjoo/enterprise-ai-systems/blob/main/01-cited-knowledge-agent/app/grounding.py): `01-cited-knowledge-agent/app/grounding.py`
- [Auditor API](https://github.com/varadganjoo/enterprise-ai-systems/blob/main/07-claim-auditor/app/main.py): `07-claim-auditor/app/main.py`
- [Claim Verification](https://github.com/varadganjoo/enterprise-ai-systems/blob/main/07-claim-auditor/app/audit.py): `07-claim-auditor/app/audit.py`
- [Brief API](https://github.com/varadganjoo/enterprise-ai-systems/blob/main/09-multi-hop-brief/app/main.py): `09-multi-hop-brief/app/main.py`
- [DAG Hop Planning](https://github.com/varadganjoo/enterprise-ai-systems/blob/main/09-multi-hop-brief/app/hops.py): `09-multi-hop-brief/app/hops.py`

### Operations & HITL

- [Extraction API](https://github.com/varadganjoo/enterprise-ai-systems/blob/main/02-document-extraction/app/main.py): `02-document-extraction/app/main.py`
- [Invoice Extraction](https://github.com/varadganjoo/enterprise-ai-systems/blob/main/02-document-extraction/app/extract.py): `02-document-extraction/app/extract.py`
- [Reconcile & Triage](https://github.com/varadganjoo/enterprise-ai-systems/blob/main/02-document-extraction/app/review.py): `02-document-extraction/app/review.py`
- [Purchase Matching](https://github.com/varadganjoo/enterprise-ai-systems/blob/main/02-document-extraction/app/match.py): `02-document-extraction/app/match.py`
- [Review Storage](https://github.com/varadganjoo/enterprise-ai-systems/blob/main/02-document-extraction/app/store.py): `02-document-extraction/app/store.py`
- [Operator API](https://github.com/varadganjoo/enterprise-ai-systems/blob/main/03-operator-agent/app/main.py): `03-operator-agent/app/main.py`
- [Support Agent](https://github.com/varadganjoo/enterprise-ai-systems/blob/main/03-operator-agent/app/agent.py): `03-operator-agent/app/agent.py`
- [Action Policy](https://github.com/varadganjoo/enterprise-ai-systems/blob/main/03-operator-agent/app/policy.py): `03-operator-agent/app/policy.py`
- [Approval Queue](https://github.com/varadganjoo/enterprise-ai-systems/blob/main/03-operator-agent/app/store.py): `03-operator-agent/app/store.py`
- [Case API](https://github.com/varadganjoo/enterprise-ai-systems/blob/main/08-case-workflow/app/main.py): `08-case-workflow/app/main.py`
- [Refund State Machine](https://github.com/varadganjoo/enterprise-ai-systems/blob/main/08-case-workflow/app/machine.py): `08-case-workflow/app/machine.py`
- [Event Log](https://github.com/varadganjoo/enterprise-ai-systems/blob/main/08-case-workflow/app/store.py): `08-case-workflow/app/store.py`

### Infrastructure & Governance

- [Analytics API](https://github.com/varadganjoo/enterprise-ai-systems/blob/main/04-analytics-copilot/app/main.py): `04-analytics-copilot/app/main.py`
- [Analytics Copilot](https://github.com/varadganjoo/enterprise-ai-systems/blob/main/04-analytics-copilot/app/copilot.py): `04-analytics-copilot/app/copilot.py`
- [SQL AST Guard](https://github.com/varadganjoo/enterprise-ai-systems/blob/main/04-analytics-copilot/app/guard.py): `04-analytics-copilot/app/guard.py`
- [Query Metrics](https://github.com/varadganjoo/enterprise-ai-systems/blob/main/04-analytics-copilot/app/metrics.py): `04-analytics-copilot/app/metrics.py`
- [Analytics Data](https://github.com/varadganjoo/enterprise-ai-systems/blob/main/04-analytics-copilot/app/seed.py): `04-analytics-copilot/app/seed.py`
- [Router API](https://github.com/varadganjoo/enterprise-ai-systems/blob/main/05-model-router/app/main.py): `05-model-router/app/main.py`
- [Tiered Model Routing](https://github.com/varadganjoo/enterprise-ai-systems/blob/main/05-model-router/app/router.py): `05-model-router/app/router.py`
- [Model Calls](https://github.com/varadganjoo/enterprise-ai-systems/blob/main/05-model-router/app/llm.py): `05-model-router/app/llm.py`
- [Memory API](https://github.com/varadganjoo/enterprise-ai-systems/blob/main/06-memory-service/app/main.py): `06-memory-service/app/main.py`
- [PII Redaction](https://github.com/varadganjoo/enterprise-ai-systems/blob/main/06-memory-service/app/service.py): `06-memory-service/app/service.py`
- [Entity Slot Memory](https://github.com/varadganjoo/enterprise-ai-systems/blob/main/06-memory-service/app/memory.py): `06-memory-service/app/memory.py`

### Other components

- **User**

## Connections

- User → Knowledge API: asks (evidence: `README.md`)
- Knowledge API → Corpus Loading: loads (evidence: `01-cited-knowledge-agent/app/main.py`)
- Knowledge API → Embedding Index: loads (evidence: `01-cited-knowledge-agent/app/main.py`)
- Knowledge API → Hybrid Retrieval: builds index (evidence: `01-cited-knowledge-agent/app/main.py`)
- Knowledge API → Grounded Answers: answers (evidence: `01-cited-knowledge-agent/app/main.py`)
- Grounded Answers → Hybrid Retrieval: retrieves (evidence: `01-cited-knowledge-agent/app/service.py`)
- Hybrid Retrieval → Corpus Loading: ranks chunks (evidence: `01-cited-knowledge-agent/app/retrieve.py`)
- Grounded Answers → Span Governance: grounds citations (evidence: `01-cited-knowledge-agent/app/grounding.py`)
- User → Auditor API: submits content (evidence: `README.md`)
- Auditor API → Claim Verification: audits claims (evidence: `07-claim-auditor/app/main.py`)
- User → Brief API: asks question (evidence: `README.md`)
- Brief API → DAG Hop Planning: plans hops (evidence: `09-multi-hop-brief/app/main.py`)
- User → Extraction API: submits invoice (evidence: `README.md`)
- Extraction API → Invoice Extraction: extracts fields (evidence: `02-document-extraction/app/main.py`)
- Extraction API → Reconcile & Triage: checks extraction (evidence: `02-document-extraction/app/main.py`)
- Reconcile & Triage → Purchase Matching: matches orders (evidence: `02-document-extraction/app/review.py`)
- Extraction API → Review Storage: records reviews (evidence: `02-document-extraction/app/main.py`)
- User → Operator API: sets goal (evidence: `README.md`)
- Operator API → Support Agent: runs agent (evidence: `03-operator-agent/app/main.py`)
- Support Agent → Action Policy: checks actions (evidence: `03-operator-agent/app/agent.py`)
- Operator API → Approval Queue: queues approvals (evidence: `03-operator-agent/app/main.py`)
- User → Case API: opens case (evidence: `README.md`)
- Case API → Refund State Machine: applies transitions (evidence: `08-case-workflow/app/main.py`)
- Case API → Event Log: commits events (evidence: `08-case-workflow/app/main.py`)
- Event Log → Refund State Machine: projects state (evidence: `08-case-workflow/app/store.py`)
- User → Analytics API: asks analytics (evidence: `README.md`)
- Analytics API → Analytics Copilot: handles query (evidence: `04-analytics-copilot/app/main.py`)
- Analytics Copilot → SQL AST Guard: validates SQL (evidence: `04-analytics-copilot/app/copilot.py`)
- Analytics Copilot → Query Metrics: tracks queries (evidence: `04-analytics-copilot/app/copilot.py`)
- Analytics Copilot → Analytics Data: uses sample data (evidence: `04-analytics-copilot/app/copilot.py`)
- User → Router API: submits task (evidence: `README.md`)
- Router API → Tiered Model Routing: selects tier (evidence: `05-model-router/app/main.py`)
- Router API → Model Calls: generates answer (evidence: `05-model-router/app/main.py`)
- Tiered Model Routing → Model Calls: supports routing (evidence: `05-model-router/app/router.py`)
- User → Memory API: chats (evidence: `README.md`)
- Memory API → PII Redaction: redacts PII (evidence: `06-memory-service/app/main.py`)
- Memory API → Entity Slot Memory: manages memories (evidence: `06-memory-service/app/main.py`)
- Entity Slot Memory → PII Redaction: redacts context (evidence: `06-memory-service/app/memory.py`)
