# alwyn25/voice_agent_ai architecture

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

- Interactive diagram: https://gitdiagram.com/alwyn25/voice_agent_ai
- Repository: https://github.com/alwyn25/voice_agent_ai

## Overview

This is a FastAPI AI voice-sales and customer-lifecycle platform. Its central workflow starts with a session, processes conversational turns through the engine, and performs post-call memory updates when the session ends. Separate capabilities cover knowledge ingestion and retrieval, configurable rules and tools, telephony, and administrative APIs. The excerpts establish session-to-turn and retrieval/ingestion relationships; broader subsystem links are included only where documented by the README or marked as unverified. Several major modules are represented at their exact tree paths because their source was not sampled.

Main entry points: [`core/app/api/sessions.py`](https://github.com/alwyn25/voice_agent_ai/blob/main/core/app/api/sessions.py) (Session lifecycle), [`core/app/engine/rag/retrieval.py`](https://github.com/alwyn25/voice_agent_ai/blob/main/core/app/engine/rag/retrieval.py) (Hybrid retrieval), [`core/app/engine/planner/planner.py`](https://github.com/alwyn25/voice_agent_ai/blob/main/core/app/engine/planner/planner.py) (Planning and response), [`core/app/engine/rag/ingestion.py`](https://github.com/alwyn25/voice_agent_ai/blob/main/core/app/engine/rag/ingestion.py) (Document ingestion)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["API and sessions"]
  node_app["FastAPI application<br/>[main.py]"]
  node_sessions["Session lifecycle<br/>[sessions.py]"]
end

subgraph group_engine["Conversation engine"]
  node_turn["Turn processing<br/>[turn_runner.py]"]
  node_planner["Planning and response<br/>[planner.py]"]
  node_tools["Tool execution<br/>[executor.py]"]
  node_memory["Post-call memory<br/>[pipeline.py]"]
end

subgraph group_knowledge["Knowledge retrieval"]
  node_rag_ingest["Document ingestion<br/>[ingestion.py]"]
  node_chunking["Chunking and enrichment<br/>[chunkers.py]"]
  node_parent_child["Parent-child chunks<br/>[parent_child.py]"]
  node_retrieval["Hybrid retrieval<br/>[retrieval.py]"]
  node_reranker["Result reranking<br/>[reranker.py]"]
end

subgraph group_platform["Platform capabilities"]
  node_apis["Business APIs"]
  node_voice["Voice and telephony<br/>[bridge.py]"]
  node_rules["Rules engine<br/>[engine.py]"]
  node_custom["Custom instructions<br/>[service.py]"]
  node_packs["Industry packs"]
end

subgraph group_storage["Providers and persistence"]
  node_db[("Relational database<br/>[base.py]")]
  node_models[("Domain records")]
  node_llm["LLM provider routing<br/>[router.py]"]
  node_embeddings["Embedding provider routing<br/>[router.py]"]
  node_shared["Shared turn schemas<br/>[turns.py]"]
end

node_client(("Channel clients"))

node_client -->|"sends requests"| node_app
node_app -->|"mounts routes"| node_sessions
node_client -->|"drives sessions"| node_sessions
node_sessions -->|"processes turns"| node_turn
node_sessions -->|"runs on end"| node_memory
node_turn -.->|"delegates planning"| node_planner
node_planner -.->|"dispatches tools"| node_tools
node_planner -.->|"retrieves knowledge"| node_retrieval
node_rag_ingest -->|"chunks documents"| node_chunking
node_rag_ingest -->|"builds hierarchy"| node_parent_child
node_rag_ingest -->|"creates vectors"| node_embeddings
node_retrieval -->|"reranks results"| node_reranker
node_retrieval -->|"fetches parents"| node_parent_child
node_retrieval -->|"embeds queries"| node_embeddings
node_retrieval -->|"queries records"| node_models
node_memory -->|"updates facts"| node_models
node_sessions -->|"loads sessions"| node_db
node_app -->|"registers endpoints"| node_apis
node_custom -->|"validates rules"| node_rules
node_llm -.->|"supplies model"| node_planner
node_voice -.->|"uses session lifecycle"| node_sessions
node_shared -.->|"defines turn contract"| node_sessions
node_packs -.->|"configures domain behavior"| node_planner

click node_app "https://github.com/alwyn25/voice_agent_ai/blob/main/core/app/main.py"
click node_sessions "https://github.com/alwyn25/voice_agent_ai/blob/main/core/app/api/sessions.py"
click node_turn "https://github.com/alwyn25/voice_agent_ai/blob/main/core/app/engine/planner/turn_runner.py"
click node_planner "https://github.com/alwyn25/voice_agent_ai/blob/main/core/app/engine/planner/planner.py"
click node_tools "https://github.com/alwyn25/voice_agent_ai/blob/main/core/app/engine/tools/executor.py"
click node_memory "https://github.com/alwyn25/voice_agent_ai/blob/main/core/app/engine/memory/pipeline.py"
click node_rag_ingest "https://github.com/alwyn25/voice_agent_ai/blob/main/core/app/engine/rag/ingestion.py"
click node_chunking "https://github.com/alwyn25/voice_agent_ai/blob/main/core/app/engine/rag/chunkers.py"
click node_parent_child "https://github.com/alwyn25/voice_agent_ai/blob/main/core/app/engine/rag/parent_child.py"
click node_retrieval "https://github.com/alwyn25/voice_agent_ai/blob/main/core/app/engine/rag/retrieval.py"
click node_reranker "https://github.com/alwyn25/voice_agent_ai/blob/main/core/app/engine/rag/reranker.py"
click node_apis "https://github.com/alwyn25/voice_agent_ai/tree/main/core/app/api"
click node_voice "https://github.com/alwyn25/voice_agent_ai/blob/main/core/app/engine/voice/bridge.py"
click node_rules "https://github.com/alwyn25/voice_agent_ai/blob/main/core/app/engine/rules/engine.py"
click node_custom "https://github.com/alwyn25/voice_agent_ai/blob/main/core/app/custom_instructions/service.py"
click node_packs "https://github.com/alwyn25/voice_agent_ai/tree/main/core/app/packs"
click node_db "https://github.com/alwyn25/voice_agent_ai/blob/main/core/app/db/base.py"
click node_models "https://github.com/alwyn25/voice_agent_ai/tree/main/core/app/db/models"
click node_llm "https://github.com/alwyn25/voice_agent_ai/blob/main/core/app/providers/llm/router.py"
click node_embeddings "https://github.com/alwyn25/voice_agent_ai/blob/main/core/app/providers/embeddings/router.py"
click node_shared "https://github.com/alwyn25/voice_agent_ai/blob/main/packages/shared/src/shared/schemas/turns.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_app,node_sessions,node_client toneBlue
class node_turn,node_planner,node_tools,node_memory toneAmber
class node_rag_ingest,node_chunking,node_parent_child,node_retrieval,node_reranker toneMint
class node_apis,node_voice,node_rules,node_custom,node_packs toneRose
class node_db,node_models,node_llm,node_embeddings,node_shared toneIndigo
```

## Components

### API and sessions

- [FastAPI application](https://github.com/alwyn25/voice_agent_ai/blob/main/core/app/main.py): `core/app/main.py`
- [Session lifecycle](https://github.com/alwyn25/voice_agent_ai/blob/main/core/app/api/sessions.py): `core/app/api/sessions.py`

### Conversation engine

- [Turn processing](https://github.com/alwyn25/voice_agent_ai/blob/main/core/app/engine/planner/turn_runner.py): `core/app/engine/planner/turn_runner.py`
- [Planning and response](https://github.com/alwyn25/voice_agent_ai/blob/main/core/app/engine/planner/planner.py): `core/app/engine/planner/planner.py`
- [Tool execution](https://github.com/alwyn25/voice_agent_ai/blob/main/core/app/engine/tools/executor.py): `core/app/engine/tools/executor.py`
- [Post-call memory](https://github.com/alwyn25/voice_agent_ai/blob/main/core/app/engine/memory/pipeline.py): `core/app/engine/memory/pipeline.py`

### Knowledge retrieval

- [Document ingestion](https://github.com/alwyn25/voice_agent_ai/blob/main/core/app/engine/rag/ingestion.py): `core/app/engine/rag/ingestion.py`
- [Chunking and enrichment](https://github.com/alwyn25/voice_agent_ai/blob/main/core/app/engine/rag/chunkers.py): `core/app/engine/rag/chunkers.py`
- [Parent-child chunks](https://github.com/alwyn25/voice_agent_ai/blob/main/core/app/engine/rag/parent_child.py): `core/app/engine/rag/parent_child.py`
- [Hybrid retrieval](https://github.com/alwyn25/voice_agent_ai/blob/main/core/app/engine/rag/retrieval.py): `core/app/engine/rag/retrieval.py`
- [Result reranking](https://github.com/alwyn25/voice_agent_ai/blob/main/core/app/engine/rag/reranker.py): `core/app/engine/rag/reranker.py`

### Platform capabilities

- [Business APIs](https://github.com/alwyn25/voice_agent_ai/tree/main/core/app/api): `core/app/api`
- [Voice and telephony](https://github.com/alwyn25/voice_agent_ai/blob/main/core/app/engine/voice/bridge.py): `core/app/engine/voice/bridge.py`
- [Rules engine](https://github.com/alwyn25/voice_agent_ai/blob/main/core/app/engine/rules/engine.py): `core/app/engine/rules/engine.py`
- [Custom instructions](https://github.com/alwyn25/voice_agent_ai/blob/main/core/app/custom_instructions/service.py): `core/app/custom_instructions/service.py`
- [Industry packs](https://github.com/alwyn25/voice_agent_ai/tree/main/core/app/packs): `core/app/packs`

### Providers and persistence

- [Relational database](https://github.com/alwyn25/voice_agent_ai/blob/main/core/app/db/base.py): `core/app/db/base.py`
- [Domain records](https://github.com/alwyn25/voice_agent_ai/tree/main/core/app/db/models): `core/app/db/models`
- [LLM provider routing](https://github.com/alwyn25/voice_agent_ai/blob/main/core/app/providers/llm/router.py): `core/app/providers/llm/router.py`
- [Embedding provider routing](https://github.com/alwyn25/voice_agent_ai/blob/main/core/app/providers/embeddings/router.py): `core/app/providers/embeddings/router.py`
- [Shared turn schemas](https://github.com/alwyn25/voice_agent_ai/blob/main/packages/shared/src/shared/schemas/turns.py): `packages/shared/src/shared/schemas/turns.py`

### Other components

- **Channel clients**

## Connections

- Channel clients → FastAPI application: sends requests
- FastAPI application → Session lifecycle: mounts routes (evidence: `core/app/main.py`)
- Channel clients → Session lifecycle: drives sessions (evidence: `core/app/api/sessions.py`)
- Session lifecycle → Turn processing: processes turns (evidence: `core/app/api/sessions.py`)
- Session lifecycle → Post-call memory: runs on end (evidence: `core/app/api/sessions.py`)
- Turn processing → Planning and response: delegates planning
- Planning and response → Tool execution: dispatches tools
- Planning and response → Hybrid retrieval: retrieves knowledge
- Document ingestion → Chunking and enrichment: chunks documents (evidence: `core/app/engine/rag/ingestion.py`)
- Document ingestion → Parent-child chunks: builds hierarchy (evidence: `core/app/engine/rag/ingestion.py`)
- Document ingestion → Embedding provider routing: creates vectors (evidence: `core/app/engine/rag/ingestion.py`)
- Hybrid retrieval → Result reranking: reranks results (evidence: `core/app/engine/rag/retrieval.py`)
- Hybrid retrieval → Parent-child chunks: fetches parents (evidence: `core/app/engine/rag/retrieval.py`)
- Hybrid retrieval → Embedding provider routing: embeds queries (evidence: `core/app/engine/rag/retrieval.py`)
- Hybrid retrieval → Domain records: queries records (evidence: `core/app/engine/rag/retrieval.py`)
- Post-call memory → Domain records: updates facts (evidence: `core/app/engine/memory/pipeline.py`)
- Session lifecycle → Relational database: loads sessions (evidence: `core/app/api/sessions.py`)
- FastAPI application → Business APIs: registers endpoints (evidence: `core/app/main.py`)
- Custom instructions → Rules engine: validates rules
- LLM provider routing → Planning and response: supplies model
- Voice and telephony → Session lifecycle: uses session lifecycle
- Shared turn schemas → Session lifecycle: defines turn contract
- Industry packs → Planning and response: configures domain behavior
