# mr-zelong/e-commerce-smart-agent architecture

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

- Interactive diagram: https://gitdiagram.com/mr-zelong/e-commerce-smart-agent
- Repository: https://github.com/mr-zelong/e-commerce-smart-agent

## Overview

E-commerce Smart Agent is a full-stack customer-service product: a customer asks about orders, policies, products, or carts; the backend recognizes intent, routes work to specialized agents and tools, and returns a response, with high-risk cases eligible for human review. The repository also documents configurable agent routing, memory, knowledge retrieval, safety and privacy controls, evaluation, and operational monitoring. The graph emphasizes relationships visible in excerpts or the README; some documented capabilities have no verified runtime connections in the sampled source.

Main entry points: [`app/main.py`](https://github.com/mr-zelong/e-commerce-smart-agent/blob/main/app/main.py) (Application Startup), [`app/intent/service.py`](https://github.com/mr-zelong/e-commerce-smart-agent/blob/main/app/intent/service.py) (Intent Recognition), [`app/memory/vector_manager.py`](https://github.com/mr-zelong/e-commerce-smart-agent/blob/main/app/memory/vector_manager.py) (Vector Memory), [`app/graph/workflow.py`](https://github.com/mr-zelong/e-commerce-smart-agent/blob/main/app/graph/workflow.py) (Agent Workflow)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_customer["Customer Experience"]
  node_customer_ui["Customer UI<br/>[App.tsx]"]
  node_chat_api["Chat API<br/>[chat.py]"]
end

subgraph group_orchestration["Conversation Orchestration"]
  node_intent["Intent Recognition<br/>[service.py]"]
  node_router["Intent Router<br/>[router.py]"]
  node_workflow["Agent Workflow<br/>[workflow.py]"]
  node_supervisor["Agent Supervisor<br/>[supervisor.py]"]
  node_main["Application Startup<br/>[main.py]"]
end

subgraph group_commerce["Commerce Operations"]
  node_domain_agents["Domain Agents"]
  node_tools["Commerce Tools"]
  node_order_service["Order and Refund Services<br/>[order_service.py]"]
end

subgraph group_knowledge["Memory and Knowledge"]
  node_structured_memory["Structured Memory"]
  node_vector_memory["Vector Memory<br/>[vector_manager.py]"]
  node_retrieval["Knowledge Retrieval<br/>[retriever.py]"]
end

subgraph group_operations["Safety and Operations"]
  node_safety["Output Safety"]
  node_pii_filter["PII Filtering<br/>[pii_filter.py]"]
  node_review_api["Review Queue API<br/>[review_queue.py]"]
  node_review_service["Review Queue Service<br/>[review_queue.py]"]
  node_review_store[("Review Records<br/>[review.py]")]
  node_admin_ui["Admin Console<br/>[App.tsx]"]
  node_evaluation["Evaluation<br/>[pipeline.py]"]
  node_observability["Observability<br/>[metrics.py]"]
  node_alerts["Alert Service<br/>[alert_service.py]"]
  node_alert_tasks["Alert Tasks<br/>[alert_tasks.py]"]
  node_alert_store[("Alert Records<br/>[alert.py]")]
end

node_customer(("Customer"))
node_qdrant[("Qdrant")]
node_llm{{"LLM Provider"}}

node_customer -->|"uses"| node_customer_ui
node_main -->|"mounts routes"| node_chat_api
node_main -->|"initializes"| node_intent
node_main -->|"initializes"| node_router
node_main -->|"creates client"| node_llm
node_router -->|"recognizes intent"| node_intent
node_intent -->|"classifies with"| node_llm
node_intent -->|"caches results"| node_structured_memory
node_main -->|"initializes"| node_retrieval
node_main -->|"registers tools"| node_tools
node_vector_memory -->|"filters content"| node_pii_filter
node_vector_memory -->|"queries and writes"| node_qdrant
node_vector_memory -->|"embeds with"| node_retrieval
node_review_api -->|"calls"| node_review_service
node_review_service -->|"uses records"| node_review_store
node_alert_tasks -->|"calls"| node_alerts
node_alert_tasks -->|"uses records"| node_alert_store
node_alerts -->|"manages alerts"| node_alert_store
node_evaluation -->|"evaluates"| node_intent
node_evaluation -->|"runs graph"| node_workflow
node_customer_ui -.->|"sends chat"| node_chat_api
node_workflow -.->|"dispatches agents"| node_supervisor
node_supervisor -.->|"dispatches work"| node_domain_agents
node_domain_agents -.->|"uses tools"| node_tools
node_domain_agents -.->|"handles commerce requests"| node_order_service
node_workflow -.->|"checks responses"| node_safety
node_admin_ui -.->|"manages reviews"| node_review_api
node_observability -.->|"drives alerting"| node_alerts

click node_customer_ui "https://github.com/mr-zelong/e-commerce-smart-agent/blob/main/frontend/src/apps/customer/App.tsx"
click node_chat_api "https://github.com/mr-zelong/e-commerce-smart-agent/blob/main/app/api/v1/chat.py"
click node_intent "https://github.com/mr-zelong/e-commerce-smart-agent/blob/main/app/intent/service.py"
click node_router "https://github.com/mr-zelong/e-commerce-smart-agent/blob/main/app/agents/router.py"
click node_workflow "https://github.com/mr-zelong/e-commerce-smart-agent/blob/main/app/graph/workflow.py"
click node_supervisor "https://github.com/mr-zelong/e-commerce-smart-agent/blob/main/app/agents/supervisor.py"
click node_domain_agents "https://github.com/mr-zelong/e-commerce-smart-agent/tree/main/app/agents"
click node_tools "https://github.com/mr-zelong/e-commerce-smart-agent/tree/main/app/tools"
click node_order_service "https://github.com/mr-zelong/e-commerce-smart-agent/blob/main/app/services/order_service.py"
click node_structured_memory "https://github.com/mr-zelong/e-commerce-smart-agent/blob/main/app/memory/structured_manager.py"
click node_vector_memory "https://github.com/mr-zelong/e-commerce-smart-agent/blob/main/app/memory/vector_manager.py"
click node_retrieval "https://github.com/mr-zelong/e-commerce-smart-agent/blob/main/app/retrieval/retriever.py"
click node_safety "https://github.com/mr-zelong/e-commerce-smart-agent/tree/main/app/safety"
click node_pii_filter "https://github.com/mr-zelong/e-commerce-smart-agent/blob/main/app/context/pii_filter.py"
click node_review_api "https://github.com/mr-zelong/e-commerce-smart-agent/blob/main/app/api/v1/admin/review_queue.py"
click node_review_service "https://github.com/mr-zelong/e-commerce-smart-agent/blob/main/app/services/review_queue.py"
click node_review_store "https://github.com/mr-zelong/e-commerce-smart-agent/blob/main/app/models/review.py"
click node_admin_ui "https://github.com/mr-zelong/e-commerce-smart-agent/blob/main/frontend/src/apps/admin/App.tsx"
click node_evaluation "https://github.com/mr-zelong/e-commerce-smart-agent/blob/main/app/evaluation/pipeline.py"
click node_observability "https://github.com/mr-zelong/e-commerce-smart-agent/blob/main/app/observability/metrics.py"
click node_alerts "https://github.com/mr-zelong/e-commerce-smart-agent/blob/main/app/services/alert_service.py"
click node_alert_tasks "https://github.com/mr-zelong/e-commerce-smart-agent/blob/main/app/tasks/alert_tasks.py"
click node_alert_store "https://github.com/mr-zelong/e-commerce-smart-agent/blob/main/app/models/alert.py"
click node_main "https://github.com/mr-zelong/e-commerce-smart-agent/blob/main/app/main.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_customer_ui,node_chat_api toneBlue
class node_intent,node_router,node_workflow,node_supervisor,node_main,node_qdrant toneAmber
class node_domain_agents,node_tools,node_order_service toneMint
class node_structured_memory,node_vector_memory,node_retrieval toneRose
class node_safety,node_pii_filter,node_review_api,node_review_service,node_review_store,node_admin_ui,node_evaluation,node_observability,node_alerts,node_alert_tasks,node_alert_store,node_customer,node_llm toneIndigo
```

## Components

### Customer Experience

- [Customer UI](https://github.com/mr-zelong/e-commerce-smart-agent/blob/main/frontend/src/apps/customer/App.tsx): `frontend/src/apps/customer/App.tsx`
- [Chat API](https://github.com/mr-zelong/e-commerce-smart-agent/blob/main/app/api/v1/chat.py): `app/api/v1/chat.py`

### Conversation Orchestration

- [Intent Recognition](https://github.com/mr-zelong/e-commerce-smart-agent/blob/main/app/intent/service.py): `app/intent/service.py`
- [Intent Router](https://github.com/mr-zelong/e-commerce-smart-agent/blob/main/app/agents/router.py): `app/agents/router.py`
- [Agent Workflow](https://github.com/mr-zelong/e-commerce-smart-agent/blob/main/app/graph/workflow.py): `app/graph/workflow.py`
- [Agent Supervisor](https://github.com/mr-zelong/e-commerce-smart-agent/blob/main/app/agents/supervisor.py): `app/agents/supervisor.py`
- [Application Startup](https://github.com/mr-zelong/e-commerce-smart-agent/blob/main/app/main.py): `app/main.py`

### Commerce Operations

- [Domain Agents](https://github.com/mr-zelong/e-commerce-smart-agent/tree/main/app/agents): `app/agents`
- [Commerce Tools](https://github.com/mr-zelong/e-commerce-smart-agent/tree/main/app/tools): `app/tools`
- [Order and Refund Services](https://github.com/mr-zelong/e-commerce-smart-agent/blob/main/app/services/order_service.py): `app/services/order_service.py`

### Memory and Knowledge

- [Structured Memory](https://github.com/mr-zelong/e-commerce-smart-agent/blob/main/app/memory/structured_manager.py): `app/memory/structured_manager.py`
- [Vector Memory](https://github.com/mr-zelong/e-commerce-smart-agent/blob/main/app/memory/vector_manager.py): `app/memory/vector_manager.py`
- [Knowledge Retrieval](https://github.com/mr-zelong/e-commerce-smart-agent/blob/main/app/retrieval/retriever.py): `app/retrieval/retriever.py`

### Safety and Operations

- [Output Safety](https://github.com/mr-zelong/e-commerce-smart-agent/tree/main/app/safety): `app/safety`
- [PII Filtering](https://github.com/mr-zelong/e-commerce-smart-agent/blob/main/app/context/pii_filter.py): `app/context/pii_filter.py`
- [Review Queue API](https://github.com/mr-zelong/e-commerce-smart-agent/blob/main/app/api/v1/admin/review_queue.py): `app/api/v1/admin/review_queue.py`
- [Review Queue Service](https://github.com/mr-zelong/e-commerce-smart-agent/blob/main/app/services/review_queue.py): `app/services/review_queue.py`
- [Review Records](https://github.com/mr-zelong/e-commerce-smart-agent/blob/main/app/models/review.py): `app/models/review.py`
- [Admin Console](https://github.com/mr-zelong/e-commerce-smart-agent/blob/main/frontend/src/apps/admin/App.tsx): `frontend/src/apps/admin/App.tsx`
- [Evaluation](https://github.com/mr-zelong/e-commerce-smart-agent/blob/main/app/evaluation/pipeline.py): `app/evaluation/pipeline.py`
- [Observability](https://github.com/mr-zelong/e-commerce-smart-agent/blob/main/app/observability/metrics.py): `app/observability/metrics.py`
- [Alert Service](https://github.com/mr-zelong/e-commerce-smart-agent/blob/main/app/services/alert_service.py): `app/services/alert_service.py`
- [Alert Tasks](https://github.com/mr-zelong/e-commerce-smart-agent/blob/main/app/tasks/alert_tasks.py): `app/tasks/alert_tasks.py`
- [Alert Records](https://github.com/mr-zelong/e-commerce-smart-agent/blob/main/app/models/alert.py): `app/models/alert.py`

### Other components

- **Customer**
- **Qdrant**
- **LLM Provider**

## Connections

- Customer → Customer UI: uses (evidence: `README.md`)
- Application Startup → Chat API: mounts routes (evidence: `app/main.py`)
- Application Startup → Intent Recognition: initializes (evidence: `app/main.py`)
- Application Startup → Intent Router: initializes (evidence: `app/main.py`)
- Application Startup → LLM Provider: creates client (evidence: `app/main.py`)
- Intent Router → Intent Recognition: recognizes intent (evidence: `app/agents/router.py`)
- Intent Recognition → LLM Provider: classifies with (evidence: `app/intent/service.py`)
- Intent Recognition → Structured Memory: caches results (evidence: `app/intent/service.py`)
- Application Startup → Knowledge Retrieval: initializes (evidence: `app/main.py`)
- Application Startup → Commerce Tools: registers tools (evidence: `app/main.py`)
- Vector Memory → PII Filtering: filters content (evidence: `app/memory/vector_manager.py`)
- Vector Memory → Qdrant: queries and writes (evidence: `app/memory/vector_manager.py`)
- Vector Memory → Knowledge Retrieval: embeds with (evidence: `app/memory/vector_manager.py`)
- Review Queue API → Review Queue Service: calls (evidence: `app/api/v1/admin/review_queue.py`)
- Review Queue Service → Review Records: uses records (evidence: `app/services/review_queue.py`)
- Alert Tasks → Alert Service: calls (evidence: `app/tasks/alert_tasks.py`)
- Alert Tasks → Alert Records: uses records (evidence: `app/tasks/alert_tasks.py`)
- Alert Service → Alert Records: manages alerts (evidence: `app/services/alert_service.py`)
- Evaluation → Intent Recognition: evaluates (evidence: `app/evaluation/pipeline.py`)
- Evaluation → Agent Workflow: runs graph (evidence: `app/evaluation/pipeline.py`)
- Customer UI → Chat API: sends chat
- Agent Workflow → Agent Supervisor: dispatches agents
- Agent Supervisor → Domain Agents: dispatches work
- Domain Agents → Commerce Tools: uses tools
- Domain Agents → Order and Refund Services: handles commerce requests
- Agent Workflow → Output Safety: checks responses
- Admin Console → Review Queue API: manages reviews
- Observability → Alert Service: drives alerting
