# lhnyx/echomind-backend architecture

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

- Interactive diagram: https://gitdiagram.com/lhnyx/echomind-backend
- Repository: https://github.com/lhnyx/echomind-backend

## Overview

EchoMind is a FastAPI multi-agent customer-support backend. Its primary workflow accepts a customer message, assembles conversational context, recognizes intent, routes the request to an agent, optionally enriches it with knowledge, and returns a reply while retaining conversation state. Separate API capabilities manage knowledge and Skills, expose monitoring, and run end-to-end evaluations. The README documents the broader routing, retrieval, memory, and feedback behavior; sampled source confirms key component responsibilities and selected calls, so undocumented wiring is omitted.

Main entry points: [`agents/agent_orchestrator.py`](https://github.com/lhnyx/echomind-backend/blob/main/agents/agent_orchestrator.py) (Agent Orchestrator), [`api/main.py`](https://github.com/lhnyx/echomind-backend/blob/main/api/main.py) (FastAPI API), [`monitor/performance_monitor.py`](https://github.com/lhnyx/echomind-backend/blob/main/monitor/performance_monitor.py) (Performance Monitor), [`evaluation/evaluator.py`](https://github.com/lhnyx/echomind-backend/blob/main/evaluation/evaluator.py) (End-to-End Evaluator)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Service Entry"]
  node_api["FastAPI API<br/>[main.py]"]
end

subgraph group_conversation["Conversation Handling"]
  node_orchestrator["Agent Orchestrator"]
  node_intent["Intent Recognition"]
  node_memory["Conversation Memory"]
  node_skills["Skills Loader<br/>[skill_loader.py]"]
  node_skillfiles["Business Skills"]
end

subgraph group_knowledge["Knowledge and Tools"]
  node_toolmanager["MCP Tool Manager<br/>[tool_manager.py]"]
  node_knowledgebase["Knowledge Base<br/>[knowledge_base.py]"]
end

subgraph group_operations["Operations"]
  node_monitor["Performance Monitor"]
end

subgraph group_evaluation["Evaluation"]
  node_evaluator["End-to-End Evaluator<br/>[evaluator.py]"]
end

node_customer(("Customer"))
node_llm(("LLM Provider"))
node_chromadb[("ChromaDB")]
node_redis[("Redis")]
node_prometheus(("Prometheus"))
node_webhook(("Alert Webhook"))

node_customer -->|"sends message"| node_api
node_api -->|"loads context"| node_memory
node_api -->|"submits request"| node_orchestrator
node_api -->|"requests retrieval"| node_toolmanager
node_api -->|"starts evaluation"| node_evaluator
node_api -->|"manages documents"| node_knowledgebase
node_api -->|"reloads Skills"| node_skills
node_intent -->|"requests classification"| node_llm
node_orchestrator -->|"recognizes intent"| node_intent
node_orchestrator -->|"loads prompt rules"| node_skills
node_orchestrator -->|"generates replies"| node_llm
node_orchestrator -.->|"uses conversation context"| node_memory
node_memory -->|"reads and writes"| node_redis
node_memory -->|"retrieves and stores memories"| node_chromadb
node_skills -->|"loads rules"| node_skillfiles
node_toolmanager -->|"dispatches search"| node_knowledgebase
node_toolmanager -->|"rewrites and reranks"| node_llm
node_knowledgebase -->|"stores and searches chunks"| node_chromadb
node_monitor -->|"reads performance"| node_orchestrator
node_monitor -->|"reads tool stats"| node_toolmanager
node_monitor -->|"updates route penalties"| node_orchestrator
node_monitor -.->|"exports metrics"| node_prometheus
node_monitor -.->|"sends alerts"| node_webhook
node_evaluator -->|"runs dialogue cases"| node_orchestrator
node_evaluator -->|"measures intent accuracy"| node_intent
node_evaluator -->|"judges response quality"| node_llm

click node_api "https://github.com/lhnyx/echomind-backend/blob/main/api/main.py"
click node_orchestrator "https://github.com/lhnyx/echomind-backend/blob/main/agents/agent_orchestrator.py"
click node_intent "https://github.com/lhnyx/echomind-backend/blob/main/core/intent_recognizer.py"
click node_memory "https://github.com/lhnyx/echomind-backend/blob/main/memory/conversation_memory.py"
click node_skills "https://github.com/lhnyx/echomind-backend/blob/main/core/skill_loader.py"
click node_skillfiles "https://github.com/lhnyx/echomind-backend/tree/main/skills"
click node_toolmanager "https://github.com/lhnyx/echomind-backend/blob/main/mcp/tool_manager.py"
click node_knowledgebase "https://github.com/lhnyx/echomind-backend/blob/main/mcp/knowledge_base.py"
click node_monitor "https://github.com/lhnyx/echomind-backend/blob/main/monitor/performance_monitor.py"
click node_evaluator "https://github.com/lhnyx/echomind-backend/blob/main/evaluation/evaluator.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_api toneBlue
class node_orchestrator,node_intent,node_memory,node_skills,node_skillfiles,node_chromadb,node_redis toneAmber
class node_toolmanager,node_knowledgebase,node_webhook toneMint
class node_monitor toneRose
class node_evaluator,node_customer,node_llm,node_prometheus toneIndigo
```

## Components

### Service Entry

- [FastAPI API](https://github.com/lhnyx/echomind-backend/blob/main/api/main.py): `api/main.py`

### Conversation Handling

- [Agent Orchestrator](https://github.com/lhnyx/echomind-backend/blob/main/agents/agent_orchestrator.py): `agents/agent_orchestrator.py`
- [Intent Recognition](https://github.com/lhnyx/echomind-backend/blob/main/core/intent_recognizer.py): `core/intent_recognizer.py`
- [Conversation Memory](https://github.com/lhnyx/echomind-backend/blob/main/memory/conversation_memory.py): `memory/conversation_memory.py`
- [Skills Loader](https://github.com/lhnyx/echomind-backend/blob/main/core/skill_loader.py): `core/skill_loader.py`
- [Business Skills](https://github.com/lhnyx/echomind-backend/tree/main/skills): `skills`

### Knowledge and Tools

- [MCP Tool Manager](https://github.com/lhnyx/echomind-backend/blob/main/mcp/tool_manager.py): `mcp/tool_manager.py`
- [Knowledge Base](https://github.com/lhnyx/echomind-backend/blob/main/mcp/knowledge_base.py): `mcp/knowledge_base.py`

### Operations

- [Performance Monitor](https://github.com/lhnyx/echomind-backend/blob/main/monitor/performance_monitor.py): `monitor/performance_monitor.py`

### Evaluation

- [End-to-End Evaluator](https://github.com/lhnyx/echomind-backend/blob/main/evaluation/evaluator.py): `evaluation/evaluator.py`

### Other components

- **Customer**
- **LLM Provider**
- **ChromaDB**
- **Redis**
- **Prometheus**
- **Alert Webhook**

## Connections

- Customer → FastAPI API: sends message
- FastAPI API → Conversation Memory: loads context
- FastAPI API → Agent Orchestrator: submits request
- FastAPI API → MCP Tool Manager: requests retrieval
- FastAPI API → End-to-End Evaluator: starts evaluation
- FastAPI API → Knowledge Base: manages documents
- FastAPI API → Skills Loader: reloads Skills
- Intent Recognition → LLM Provider: requests classification
- Agent Orchestrator → Intent Recognition: recognizes intent
- Agent Orchestrator → Skills Loader: loads prompt rules
- Agent Orchestrator → LLM Provider: generates replies
- Agent Orchestrator → Conversation Memory: uses conversation context
- Conversation Memory → Redis: reads and writes
- Conversation Memory → ChromaDB: retrieves and stores memories
- Skills Loader → Business Skills: loads rules
- MCP Tool Manager → Knowledge Base: dispatches search
- MCP Tool Manager → LLM Provider: rewrites and reranks
- Knowledge Base → ChromaDB: stores and searches chunks
- Performance Monitor → Agent Orchestrator: reads performance
- Performance Monitor → MCP Tool Manager: reads tool stats
- Performance Monitor → Agent Orchestrator: updates route penalties
- Performance Monitor → Prometheus: exports metrics
- Performance Monitor → Alert Webhook: sends alerts
- End-to-End Evaluator → Agent Orchestrator: runs dialogue cases
- End-to-End Evaluator → Intent Recognition: measures intent accuracy
- End-to-End Evaluator → LLM Provider: judges response quality
