# sanketwork300-hash/voiceagent_for_bsfi architecture

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

- Interactive diagram: https://gitdiagram.com/sanketwork300-hash/voiceagent_for_bsfi
- Repository: https://github.com/sanketwork300-hash/voiceagent_for_bsfi

## Overview

This is a BFSI conversational-agent platform: a shared backend runtime serves customer chat and voice, while a Next.js assistant and operator console provide the user-facing surfaces. The principal flow is a customer message through a channel and API into the agent runtime, which can retrieve grounded knowledge or request a tool; tool execution is mediated by policy before reaching institution systems. Document ingestion, authentication, handoff, governance, and evaluation are distinct product capabilities. Some links are documented only at README level; unsampled integrations are not mapped in detail.

Main entry points: [`backend/app/agents/orchestrator.py`](https://github.com/sanketwork300-hash/voiceagent_for_bsfi/blob/main/backend/app/agents/orchestrator.py) (Agent runtime), [`backend/app/tools/router.py`](https://github.com/sanketwork300-hash/voiceagent_for_bsfi/blob/main/backend/app/tools/router.py) (Tool gateway), [`backend/app/policies/engine.py`](https://github.com/sanketwork300-hash/voiceagent_for_bsfi/blob/main/backend/app/policies/engine.py) (Policy engine), [`frontend/src/app`](https://github.com/sanketwork300-hash/voiceagent_for_bsfi/tree/main/frontend/src/app) (Assistant and console)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["User experiences"]
  node_frontend["Assistant and console"]
  node_chat_channel["Chat channel"]
  node_voice_channel["Voice channel"]
end

subgraph group_runtime["Agent runtime"]
  node_agent_runtime["Agent runtime<br/>[orchestrator.py]"]
  node_execution["Workflow execution<br/>[executor.py]"]
  node_llm["LLM providers"]
  node_tool_gateway["Tool gateway<br/>[router.py]"]
  node_tool_registry["Tool registry<br/>[registry.py]"]
  node_institution_tools["Institution APIs and MCP"]
end

subgraph group_knowledge["Knowledge"]
  node_knowledge_ingestion["Document ingestion<br/>[pipeline.py]"]
  node_rag["Knowledge retrieval<br/>[rag.py]"]
  node_knowledge_store[("Knowledge index<br/>[base.py]")]
end

subgraph group_governance["Trust and governance"]
  node_policy["Policy engine<br/>[engine.py]"]
  node_approval["Human approval<br/>[approval.py]"]
  node_handoff["Human handoff<br/>[handoff.py]"]
  node_authentication["Customer authentication<br/>[authentication.py]"]
end

subgraph group_platform["Platform services"]
  node_api["HTTP API<br/>[main.py]"]
  node_session[("Session state<br/>[manager.py]")]
  node_database[("Platform database<br/>[session.py]")]
  node_evaluation["Agent evaluation"]
  node_observability["Audit and observability"]
end

node_customer(("Customer"))
node_operator(("Operator"))

node_customer -->|"uses"| node_frontend
node_operator -->|"operates"| node_frontend
node_frontend -.->|"calls"| node_api
node_api -.->|"routes requests"| node_chat_channel
node_chat_channel -.->|"submits turns"| node_agent_runtime
node_voice_channel -.->|"submits turns"| node_agent_runtime
node_agent_runtime -->|"orchestrates"| node_llm
node_agent_runtime -->|"delegates"| node_execution
node_execution -->|"executes tools"| node_tool_gateway
node_tool_gateway -->|"checks policy"| node_policy
node_tool_gateway -->|"resolves tools"| node_tool_registry
node_tool_gateway -->|"dispatches calls"| node_institution_tools
node_agent_runtime -->|"retrieves context"| node_rag
node_rag -->|"searches index"| node_knowledge_store
node_knowledge_ingestion -->|"indexes chunks"| node_knowledge_store
node_policy -->|"requests approval"| node_approval
node_agent_runtime -->|"initiates handoff"| node_handoff
node_agent_runtime -->|"checks identity"| node_authentication
node_agent_runtime -->|"uses session state"| node_session
node_session -->|"persists state"| node_database
node_policy -->|"loads rules"| node_database
node_evaluation -.->|"evaluates behavior"| node_agent_runtime
node_observability -.->|"records runtime"| node_agent_runtime

click node_frontend "https://github.com/sanketwork300-hash/voiceagent_for_bsfi/tree/main/frontend/src/app"
click node_chat_channel "https://github.com/sanketwork300-hash/voiceagent_for_bsfi/tree/main/backend/app/channels/chat"
click node_voice_channel "https://github.com/sanketwork300-hash/voiceagent_for_bsfi/tree/main/backend/app/channels/voice"
click node_api "https://github.com/sanketwork300-hash/voiceagent_for_bsfi/blob/main/backend/app/main.py"
click node_agent_runtime "https://github.com/sanketwork300-hash/voiceagent_for_bsfi/blob/main/backend/app/agents/orchestrator.py"
click node_execution "https://github.com/sanketwork300-hash/voiceagent_for_bsfi/blob/main/backend/app/agents/execution/executor.py"
click node_llm "https://github.com/sanketwork300-hash/voiceagent_for_bsfi/tree/main/backend/app/llm"
click node_tool_gateway "https://github.com/sanketwork300-hash/voiceagent_for_bsfi/blob/main/backend/app/tools/router.py"
click node_tool_registry "https://github.com/sanketwork300-hash/voiceagent_for_bsfi/blob/main/backend/app/tools/registry.py"
click node_institution_tools "https://github.com/sanketwork300-hash/voiceagent_for_bsfi/tree/main/backend/app/tools"
click node_knowledge_ingestion "https://github.com/sanketwork300-hash/voiceagent_for_bsfi/blob/main/backend/app/knowledge/ingestion/pipeline.py"
click node_rag "https://github.com/sanketwork300-hash/voiceagent_for_bsfi/blob/main/backend/app/knowledge/rag.py"
click node_knowledge_store "https://github.com/sanketwork300-hash/voiceagent_for_bsfi/blob/main/backend/app/knowledge/retrieval/base.py"
click node_policy "https://github.com/sanketwork300-hash/voiceagent_for_bsfi/blob/main/backend/app/policies/engine.py"
click node_approval "https://github.com/sanketwork300-hash/voiceagent_for_bsfi/blob/main/backend/app/policies/approval.py"
click node_handoff "https://github.com/sanketwork300-hash/voiceagent_for_bsfi/blob/main/backend/app/escalation/handoff.py"
click node_authentication "https://github.com/sanketwork300-hash/voiceagent_for_bsfi/blob/main/backend/app/auth/authentication.py"
click node_session "https://github.com/sanketwork300-hash/voiceagent_for_bsfi/blob/main/backend/app/sessions/manager.py"
click node_database "https://github.com/sanketwork300-hash/voiceagent_for_bsfi/blob/main/backend/app/database/session.py"
click node_evaluation "https://github.com/sanketwork300-hash/voiceagent_for_bsfi/tree/main/backend/app/evaluation"
click node_observability "https://github.com/sanketwork300-hash/voiceagent_for_bsfi/tree/main/backend/app/observability"

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_frontend,node_chat_channel,node_voice_channel toneBlue
class node_agent_runtime,node_execution,node_llm,node_tool_gateway,node_tool_registry,node_institution_tools toneAmber
class node_knowledge_ingestion,node_rag,node_knowledge_store toneMint
class node_policy,node_approval,node_handoff,node_authentication toneRose
class node_api,node_session,node_database,node_evaluation,node_observability,node_customer,node_operator toneIndigo
```

## Components

### User experiences

- [Assistant and console](https://github.com/sanketwork300-hash/voiceagent_for_bsfi/tree/main/frontend/src/app): `frontend/src/app`
- [Chat channel](https://github.com/sanketwork300-hash/voiceagent_for_bsfi/tree/main/backend/app/channels/chat): `backend/app/channels/chat`
- [Voice channel](https://github.com/sanketwork300-hash/voiceagent_for_bsfi/tree/main/backend/app/channels/voice): `backend/app/channels/voice`

### Agent runtime

- [Agent runtime](https://github.com/sanketwork300-hash/voiceagent_for_bsfi/blob/main/backend/app/agents/orchestrator.py): `backend/app/agents/orchestrator.py`
- [Workflow execution](https://github.com/sanketwork300-hash/voiceagent_for_bsfi/blob/main/backend/app/agents/execution/executor.py): `backend/app/agents/execution/executor.py`
- [LLM providers](https://github.com/sanketwork300-hash/voiceagent_for_bsfi/tree/main/backend/app/llm): `backend/app/llm`
- [Tool gateway](https://github.com/sanketwork300-hash/voiceagent_for_bsfi/blob/main/backend/app/tools/router.py): `backend/app/tools/router.py`
- [Tool registry](https://github.com/sanketwork300-hash/voiceagent_for_bsfi/blob/main/backend/app/tools/registry.py): `backend/app/tools/registry.py`
- [Institution APIs and MCP](https://github.com/sanketwork300-hash/voiceagent_for_bsfi/tree/main/backend/app/tools): `backend/app/tools`

### Knowledge

- [Document ingestion](https://github.com/sanketwork300-hash/voiceagent_for_bsfi/blob/main/backend/app/knowledge/ingestion/pipeline.py): `backend/app/knowledge/ingestion/pipeline.py`
- [Knowledge retrieval](https://github.com/sanketwork300-hash/voiceagent_for_bsfi/blob/main/backend/app/knowledge/rag.py): `backend/app/knowledge/rag.py`
- [Knowledge index](https://github.com/sanketwork300-hash/voiceagent_for_bsfi/blob/main/backend/app/knowledge/retrieval/base.py): `backend/app/knowledge/retrieval/base.py`

### Trust and governance

- [Policy engine](https://github.com/sanketwork300-hash/voiceagent_for_bsfi/blob/main/backend/app/policies/engine.py): `backend/app/policies/engine.py`
- [Human approval](https://github.com/sanketwork300-hash/voiceagent_for_bsfi/blob/main/backend/app/policies/approval.py): `backend/app/policies/approval.py`
- [Human handoff](https://github.com/sanketwork300-hash/voiceagent_for_bsfi/blob/main/backend/app/escalation/handoff.py): `backend/app/escalation/handoff.py`
- [Customer authentication](https://github.com/sanketwork300-hash/voiceagent_for_bsfi/blob/main/backend/app/auth/authentication.py): `backend/app/auth/authentication.py`

### Platform services

- [HTTP API](https://github.com/sanketwork300-hash/voiceagent_for_bsfi/blob/main/backend/app/main.py): `backend/app/main.py`
- [Session state](https://github.com/sanketwork300-hash/voiceagent_for_bsfi/blob/main/backend/app/sessions/manager.py): `backend/app/sessions/manager.py`
- [Platform database](https://github.com/sanketwork300-hash/voiceagent_for_bsfi/blob/main/backend/app/database/session.py): `backend/app/database/session.py`
- [Agent evaluation](https://github.com/sanketwork300-hash/voiceagent_for_bsfi/tree/main/backend/app/evaluation): `backend/app/evaluation`
- [Audit and observability](https://github.com/sanketwork300-hash/voiceagent_for_bsfi/tree/main/backend/app/observability): `backend/app/observability`

### Other components

- **Customer**
- **Operator**

## Connections

- Customer → Assistant and console: uses (evidence: `README.md`)
- Operator → Assistant and console: operates (evidence: `README.md`)
- Assistant and console → HTTP API: calls
- HTTP API → Chat channel: routes requests
- Chat channel → Agent runtime: submits turns (evidence: `README.md`)
- Voice channel → Agent runtime: submits turns (evidence: `README.md`)
- Agent runtime → LLM providers: orchestrates (evidence: `backend/app/agents/orchestrator.py`)
- Agent runtime → Workflow execution: delegates (evidence: `backend/app/agents/orchestrator.py`)
- Workflow execution → Tool gateway: executes tools (evidence: `backend/app/agents/execution/executor.py`)
- Tool gateway → Policy engine: checks policy (evidence: `backend/app/tools/router.py`)
- Tool gateway → Tool registry: resolves tools (evidence: `backend/app/tools/router.py`)
- Tool gateway → Institution APIs and MCP: dispatches calls (evidence: `backend/app/tools/router.py`)
- Agent runtime → Knowledge retrieval: retrieves context (evidence: `backend/app/agents/orchestrator.py`)
- Knowledge retrieval → Knowledge index: searches index (evidence: `backend/app/knowledge/rag.py`)
- Document ingestion → Knowledge index: indexes chunks (evidence: `backend/app/knowledge/ingestion/pipeline.py`)
- Policy engine → Human approval: requests approval (evidence: `backend/app/policies/engine.py`)
- Agent runtime → Human handoff: initiates handoff (evidence: `backend/app/agents/orchestrator.py`)
- Agent runtime → Customer authentication: checks identity (evidence: `backend/app/agents/orchestrator.py`)
- Agent runtime → Session state: uses session state (evidence: `backend/app/agents/orchestrator.py`)
- Session state → Platform database: persists state (evidence: `backend/app/sessions/manager.py`)
- Policy engine → Platform database: loads rules (evidence: `backend/app/policies/engine.py`)
- Agent evaluation → Agent runtime: evaluates behavior (evidence: `README.md`)
- Audit and observability → Agent runtime: records runtime (evidence: `README.md`)
