# deepak156566/a2a architecture

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

- Interactive diagram: https://gitdiagram.com/deepak156566/a2a
- Repository: https://github.com/deepak156566/a2a

## Overview

This repository implements an invoice-audit and question-answering product: invoices enter through upload or folder scanning, are extracted and validated, then reported and stored for review; users can query audited results through structured SQL or retrieval-augmented answers. The main service assembles the workflow, database, indexing, and tool runtime. Separate modules provide ADK agents, ERP integration, and a Streamlit interface. The README is empty, and several workflow and UI excerpts were not provided, so some subsystem connections are intentionally omitted rather than inferred.

Main entry points: [`agent/app/main.py`](https://github.com/deepak156566/a2a/blob/main/agent/app/main.py) (Agent API), [`agent/app/workflow/nodes.py`](https://github.com/deepak156566/a2a/blob/main/agent/app/workflow/nodes.py) (Workflow stages), [`agent/app/tools/server.py`](https://github.com/deepak156566/a2a/blob/main/agent/app/tools/server.py) (MCP tool server), [`agent/app/rag/indexer.py`](https://github.com/deepak156566/a2a/blob/main/agent/app/rag/indexer.py) (Vector indexer)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ingest["Invoice intake"]
  node_monitor["Folder monitor<br/>[watcher.py]"]
  node_extract["Invoice extraction<br/>[parsing.py]"]
  node_normalize["Field normalization<br/>[normalize.py]"]
end

subgraph group_audit["Audit workflow"]
  node_workflow["Workflow runner<br/>[runner.py]"]
  node_workflow_nodes["Workflow stages<br/>[nodes.py]"]
  node_data_validation["Data validation<br/>[data_validator.py]"]
  node_business_validation["Business validation"]
  node_severity["Decision severity<br/>[severity.py]"]
  node_reporting["Audit reporting<br/>[reporter.py]"]
  node_repository[("Audit repository<br/>[repository.py]")]
end

subgraph group_platform["Agent platform"]
  node_adk_server["ADK agent service<br/>[server.py]"]
  node_translation["Translation agent"]
  node_a2a["A2A client<br/>[client.py]"]
  node_tool_server["MCP tool server<br/>[server.py]"]
  node_tool_bus["MCP tool bus<br/>[mcp_bus.py]"]
  node_guardrails["Safety guardrails<br/>[guardrails.py]"]
  node_config["Runtime configuration<br/>[config.py]"]
end

subgraph group_knowledge["Search and Q&amp;A"]
  node_rag_service["Question answering<br/>[service.py]"]
  node_query_router["Query router<br/>[query_router.py]"]
  node_rag_graph["RAG answer graph<br/>[rag_graph.py]"]
  node_indexer["Vector indexer<br/>[indexer.py]"]
  node_retrieval["Semantic retrieval<br/>[retrieval.py]"]
end

subgraph group_clients["User and ERP interfaces"]
  node_streamlit["Streamlit UI<br/>[streamlit_app.py]"]
  node_ui_data["UI data client<br/>[data.py]"]
  node_api["Agent API<br/>[main.py]"]
  node_erp_client["ERP client<br/>[client.py]"]
  node_mock_erp["Mock ERP service<br/>[main.py]"]
end

node_user(("Invoice user"))

node_user -.->|"uses"| node_streamlit
node_streamlit -.->|"requests data"| node_ui_data
node_user -.->|"submits invoices"| node_api
node_api -->|"runs workflow"| node_workflow
node_api -->|"builds index"| node_indexer
node_api -->|"builds tools"| node_tool_server
node_api -->|"reads audit data"| node_repository
node_monitor -->|"checks invoices"| node_repository
node_monitor -->|"extracts files"| node_extract
node_workflow -.->|"dispatches stages"| node_workflow_nodes
node_workflow_nodes -.->|"validates fields"| node_data_validation
node_workflow_nodes -.->|"checks business rules"| node_business_validation
node_workflow_nodes -.->|"generates report"| node_reporting
node_workflow_nodes -.->|"persists audit"| node_repository
node_business_validation -->|"checks ERP"| node_erp_client
node_erp_client -.->|"requests ERP data"| node_mock_erp
node_tool_server -->|"validates invoice"| node_data_validation
node_tool_server -->|"builds report"| node_reporting
node_tool_server -->|"indexes invoice"| node_indexer
node_tool_bus -->|"dispatches tools"| node_tool_server
node_api -.->|"answers questions"| node_rag_service
node_rag_service -->|"routes question"| node_query_router
node_rag_service -->|"runs RAG"| node_rag_graph
node_rag_graph -->|"invokes tools"| node_tool_bus
node_indexer -->|"loads invoice data"| node_repository
node_retrieval -.->|"uses embeddings"| node_indexer
node_adk_server -->|"serves agent"| node_translation
node_api -->|"configures safety"| node_guardrails
node_adk_server -->|"configures safety"| node_guardrails
node_api -->|"loads settings"| node_config

click node_streamlit "https://github.com/deepak156566/a2a/blob/main/streamlit-ui/app/streamlit_app.py"
click node_ui_data "https://github.com/deepak156566/a2a/blob/main/streamlit-ui/app/data.py"
click node_api "https://github.com/deepak156566/a2a/blob/main/agent/app/main.py"
click node_monitor "https://github.com/deepak156566/a2a/blob/main/agent/app/monitoring/watcher.py"
click node_extract "https://github.com/deepak156566/a2a/blob/main/agent/app/extraction/parsing.py"
click node_normalize "https://github.com/deepak156566/a2a/blob/main/agent/app/extraction/normalize.py"
click node_workflow "https://github.com/deepak156566/a2a/blob/main/agent/app/workflow/runner.py"
click node_workflow_nodes "https://github.com/deepak156566/a2a/blob/main/agent/app/workflow/nodes.py"
click node_data_validation "https://github.com/deepak156566/a2a/blob/main/agent/app/validation/data_validator.py"
click node_business_validation "https://github.com/deepak156566/a2a/blob/main/agent/app/validation/business_validator.py"
click node_severity "https://github.com/deepak156566/a2a/blob/main/agent/app/validation/severity.py"
click node_reporting "https://github.com/deepak156566/a2a/blob/main/agent/app/reporting/reporter.py"
click node_repository "https://github.com/deepak156566/a2a/blob/main/agent/app/database/repository.py"
click node_adk_server "https://github.com/deepak156566/a2a/blob/main/agent/app/adk_agents/server.py"
click node_translation "https://github.com/deepak156566/a2a/blob/main/agent/app/adk_agents/translation_agent.py"
click node_a2a "https://github.com/deepak156566/a2a/blob/main/agent/app/a2a_client/client.py"
click node_erp_client "https://github.com/deepak156566/a2a/blob/main/agent/app/erp_client/client.py"
click node_mock_erp "https://github.com/deepak156566/a2a/blob/main/mock-erp/app/main.py"
click node_tool_server "https://github.com/deepak156566/a2a/blob/main/agent/app/tools/server.py"
click node_tool_bus "https://github.com/deepak156566/a2a/blob/main/agent/app/tools/mcp_bus.py"
click node_rag_service "https://github.com/deepak156566/a2a/blob/main/agent/app/rag/service.py"
click node_query_router "https://github.com/deepak156566/a2a/blob/main/agent/app/rag/query_router.py"
click node_rag_graph "https://github.com/deepak156566/a2a/blob/main/agent/app/rag/rag_graph.py"
click node_indexer "https://github.com/deepak156566/a2a/blob/main/agent/app/rag/indexer.py"
click node_retrieval "https://github.com/deepak156566/a2a/blob/main/agent/app/rag/retrieval.py"
click node_guardrails "https://github.com/deepak156566/a2a/blob/main/agent/app/guardrails.py"
click node_config "https://github.com/deepak156566/a2a/blob/main/agent/app/config.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_monitor,node_extract,node_normalize,node_user toneBlue
class node_workflow,node_workflow_nodes,node_data_validation,node_business_validation,node_severity,node_reporting,node_repository toneAmber
class node_adk_server,node_translation,node_a2a,node_tool_server,node_tool_bus,node_guardrails,node_config toneMint
class node_rag_service,node_query_router,node_rag_graph,node_indexer,node_retrieval toneRose
class node_streamlit,node_ui_data,node_api,node_erp_client,node_mock_erp toneIndigo
```

## Components

### Invoice intake

- [Folder monitor](https://github.com/deepak156566/a2a/blob/main/agent/app/monitoring/watcher.py): `agent/app/monitoring/watcher.py`
- [Invoice extraction](https://github.com/deepak156566/a2a/blob/main/agent/app/extraction/parsing.py): `agent/app/extraction/parsing.py`
- [Field normalization](https://github.com/deepak156566/a2a/blob/main/agent/app/extraction/normalize.py): `agent/app/extraction/normalize.py`

### Audit workflow

- [Workflow runner](https://github.com/deepak156566/a2a/blob/main/agent/app/workflow/runner.py): `agent/app/workflow/runner.py`
- [Workflow stages](https://github.com/deepak156566/a2a/blob/main/agent/app/workflow/nodes.py): `agent/app/workflow/nodes.py`
- [Data validation](https://github.com/deepak156566/a2a/blob/main/agent/app/validation/data_validator.py): `agent/app/validation/data_validator.py`
- [Business validation](https://github.com/deepak156566/a2a/blob/main/agent/app/validation/business_validator.py): `agent/app/validation/business_validator.py`
- [Decision severity](https://github.com/deepak156566/a2a/blob/main/agent/app/validation/severity.py): `agent/app/validation/severity.py`
- [Audit reporting](https://github.com/deepak156566/a2a/blob/main/agent/app/reporting/reporter.py): `agent/app/reporting/reporter.py`
- [Audit repository](https://github.com/deepak156566/a2a/blob/main/agent/app/database/repository.py): `agent/app/database/repository.py`

### Agent platform

- [ADK agent service](https://github.com/deepak156566/a2a/blob/main/agent/app/adk_agents/server.py): `agent/app/adk_agents/server.py`
- [Translation agent](https://github.com/deepak156566/a2a/blob/main/agent/app/adk_agents/translation_agent.py): `agent/app/adk_agents/translation_agent.py`
- [A2A client](https://github.com/deepak156566/a2a/blob/main/agent/app/a2a_client/client.py): `agent/app/a2a_client/client.py`
- [MCP tool server](https://github.com/deepak156566/a2a/blob/main/agent/app/tools/server.py): `agent/app/tools/server.py`
- [MCP tool bus](https://github.com/deepak156566/a2a/blob/main/agent/app/tools/mcp_bus.py): `agent/app/tools/mcp_bus.py`
- [Safety guardrails](https://github.com/deepak156566/a2a/blob/main/agent/app/guardrails.py): `agent/app/guardrails.py`
- [Runtime configuration](https://github.com/deepak156566/a2a/blob/main/agent/app/config.py): `agent/app/config.py`

### Search and Q&A

- [Question answering](https://github.com/deepak156566/a2a/blob/main/agent/app/rag/service.py): `agent/app/rag/service.py`
- [Query router](https://github.com/deepak156566/a2a/blob/main/agent/app/rag/query_router.py): `agent/app/rag/query_router.py`
- [RAG answer graph](https://github.com/deepak156566/a2a/blob/main/agent/app/rag/rag_graph.py): `agent/app/rag/rag_graph.py`
- [Vector indexer](https://github.com/deepak156566/a2a/blob/main/agent/app/rag/indexer.py): `agent/app/rag/indexer.py`
- [Semantic retrieval](https://github.com/deepak156566/a2a/blob/main/agent/app/rag/retrieval.py): `agent/app/rag/retrieval.py`

### User and ERP interfaces

- [Streamlit UI](https://github.com/deepak156566/a2a/blob/main/streamlit-ui/app/streamlit_app.py): `streamlit-ui/app/streamlit_app.py`
- [UI data client](https://github.com/deepak156566/a2a/blob/main/streamlit-ui/app/data.py): `streamlit-ui/app/data.py`
- [Agent API](https://github.com/deepak156566/a2a/blob/main/agent/app/main.py): `agent/app/main.py`
- [ERP client](https://github.com/deepak156566/a2a/blob/main/agent/app/erp_client/client.py): `agent/app/erp_client/client.py`
- [Mock ERP service](https://github.com/deepak156566/a2a/blob/main/mock-erp/app/main.py): `mock-erp/app/main.py`

### Other components

- **Invoice user**

## Connections

- Invoice user → Streamlit UI: uses
- Streamlit UI → UI data client: requests data (evidence: `streamlit-ui/app/streamlit_app.py`)
- Invoice user → Agent API: submits invoices
- Agent API → Workflow runner: runs workflow (evidence: `agent/app/main.py`)
- Agent API → Vector indexer: builds index (evidence: `agent/app/main.py`)
- Agent API → MCP tool server: builds tools (evidence: `agent/app/main.py`)
- Agent API → Audit repository: reads audit data (evidence: `agent/app/main.py`)
- Folder monitor → Audit repository: checks invoices (evidence: `agent/app/monitoring/watcher.py`)
- Folder monitor → Invoice extraction: extracts files (evidence: `agent/app/monitoring/watcher.py`)
- Workflow runner → Workflow stages: dispatches stages
- Workflow stages → Data validation: validates fields
- Workflow stages → Business validation: checks business rules
- Workflow stages → Audit reporting: generates report
- Workflow stages → Audit repository: persists audit
- Business validation → ERP client: checks ERP (evidence: `agent/app/validation/business_validator.py`)
- ERP client → Mock ERP service: requests ERP data
- MCP tool server → Data validation: validates invoice (evidence: `agent/app/tools/server.py`)
- MCP tool server → Audit reporting: builds report (evidence: `agent/app/tools/server.py`)
- MCP tool server → Vector indexer: indexes invoice (evidence: `agent/app/tools/server.py`)
- MCP tool bus → MCP tool server: dispatches tools (evidence: `agent/app/tools/mcp_bus.py`)
- Agent API → Question answering: answers questions
- Question answering → Query router: routes question (evidence: `agent/app/rag/service.py`)
- Question answering → RAG answer graph: runs RAG (evidence: `agent/app/rag/service.py`)
- RAG answer graph → MCP tool bus: invokes tools (evidence: `agent/app/rag/rag_graph.py`)
- Vector indexer → Audit repository: loads invoice data (evidence: `agent/app/rag/service.py`)
- Semantic retrieval → Vector indexer: uses embeddings
- ADK agent service → Translation agent: serves agent (evidence: `agent/app/adk_agents/server.py`)
- Agent API → Safety guardrails: configures safety (evidence: `agent/app/main.py`)
- ADK agent service → Safety guardrails: configures safety (evidence: `agent/app/adk_agents/server.py`)
- Agent API → Runtime configuration: loads settings (evidence: `agent/app/main.py`)
