# deeparajasabeson/ecommerce-ai-assistant architecture

> Architecture diagram of the GitHub repository deeparajasabeson/ecommerce-ai-assistant, 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/deeparajasabeson/ecommerce-ai-assistant
- Repository: https://github.com/deeparajasabeson/ecommerce-ai-assistant

## Overview

This repository implements a React chat interface backed by a FastAPI e-commerce API and an Azure AI Foundry multi-agent assistant. The main workflow is customer prompt → chat request → orchestrator routing → specialist agent tools → REST endpoints → PostgreSQL-backed repositories, with the response and agent label returned to the UI. Product, order, shipping, customer, and payment APIs are also exposed independently. Payment chat is documented as a fixed Cash on Delivery response rather than a specialist-agent flow. Some subsystem links rely on README documentation because their source was not sampled.

Main entry points: [`backend/app/data/repositories.py`](https://github.com/deeparajasabeson/ecommerce-ai-assistant/blob/main/backend/app/data/repositories.py) (Repository providers), [`backend/main.py`](https://github.com/deeparajasabeson/ecommerce-ai-assistant/blob/main/backend/main.py) (FastAPI app), [`backend/ai/tools/api_client.py`](https://github.com/deeparajasabeson/ecommerce-ai-assistant/blob/main/backend/ai/tools/api_client.py) (E-commerce API client), [`frontend/src/App.tsx`](https://github.com/deeparajasabeson/ecommerce-ai-assistant/blob/main/frontend/src/App.tsx) (Chat app)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Chat interface"]
  node_app_ui["Chat app<br/>[App.tsx]"]
  node_chat_input["Chat input<br/>[ChatInput.tsx]"]
  node_chat_messages["Conversation view<br/>[ChatMessages.tsx]"]
  node_sidebar["Agent sidebar<br/>[Sidebar.tsx]"]
  node_chat_service["Chat client<br/>[chatService.ts]"]
end

subgraph group_chat_backend["Chat and routing"]
  node_chat_route["Chat endpoint<br/>[chat.py]"]
  node_orchestrator_service["Orchestrator service"]
end

subgraph group_ai_agents["AI agents and tools"]
  node_orchestrator["Query orchestrator<br/>[intelligent.py]"]
  node_specialists["Specialist agents"]
  node_agent_runtime["Agent runtime<br/>[base.py]"]
  node_tool_definitions["Tool definitions<br/>[definitions.py]"]
  node_tool_executors["Tool executors<br/>[executors.py]"]
  node_api_client["E-commerce API client<br/>[api_client.py]"]
end

subgraph group_api["Store API"]
  node_api_app["FastAPI app<br/>[main.py]"]
  node_product_api["Product API<br/>[product.py]"]
  node_order_api["Order API<br/>[order.py]"]
  node_shipping_api["Shipping API<br/>[shipping.py]"]
  node_customer_api["Customer API<br/>[customer.py]"]
  node_payment_api["Payment API<br/>[payment.py]"]
end

subgraph group_data["Persistence"]
  node_repo_providers["Repository providers<br/>[repositories.py]"]
  node_product_repo["Product repository"]
  node_order_repo["Order repository"]
  node_shipping_repo["Shipping repository"]
  node_customer_repo["Customer repository"]
  node_db_pool[("PostgreSQL pool<br/>[database.py]")]
end

node_customer(("Customer"))
node_postgres[("PostgreSQL")]
node_azure_foundry["Azure AI Foundry"]

node_customer -->|"enters prompt"| node_app_ui
node_app_ui -->|"renders"| node_chat_input
node_app_ui -->|"renders"| node_chat_messages
node_app_ui -->|"renders"| node_sidebar
node_app_ui -->|"sends query"| node_chat_service
node_chat_service -->|"POSTs query"| node_chat_route
node_chat_route -->|"routes query"| node_orchestrator_service
node_orchestrator_service -->|"routes query"| node_orchestrator
node_orchestrator_service -->|"initializes"| node_specialists
node_orchestrator -->|"dispatches query"| node_specialists
node_specialists -->|"extends runtime"| node_agent_runtime
node_agent_runtime -->|"registers tools"| node_tool_definitions
node_agent_runtime -->|"loads callbacks"| node_tool_executors
node_tool_executors -->|"calls API methods"| node_api_client
node_api_client -->|"requests products"| node_product_api
node_api_client -->|"requests orders"| node_order_api
node_api_client -->|"requests shipping"| node_shipping_api
node_api_client -->|"requests customers"| node_customer_api
node_api_client -->|"requests payments"| node_payment_api
node_api_app -->|"registers router"| node_product_api
node_api_app -->|"registers router"| node_order_api
node_api_app -->|"registers router"| node_shipping_api
node_api_app -->|"registers router"| node_customer_api
node_api_app -->|"registers router"| node_payment_api
node_api_app -->|"registers router"| node_chat_route
node_product_api -->|"uses dependency"| node_repo_providers
node_order_api -->|"uses dependency"| node_repo_providers
node_shipping_api -->|"uses dependency"| node_repo_providers
node_customer_api -->|"uses dependency"| node_repo_providers
node_payment_api -->|"uses dependency"| node_repo_providers
node_repo_providers -->|"provides"| node_product_repo
node_repo_providers -->|"provides"| node_order_repo
node_repo_providers -->|"provides"| node_shipping_repo
node_repo_providers -->|"provides"| node_customer_repo
node_api_app -->|"initializes pool"| node_db_pool
node_db_pool -->|"opens connections"| node_postgres
node_specialists -->|"uses agents"| node_azure_foundry

click node_app_ui "https://github.com/deeparajasabeson/ecommerce-ai-assistant/blob/main/frontend/src/App.tsx"
click node_chat_input "https://github.com/deeparajasabeson/ecommerce-ai-assistant/blob/main/frontend/src/components/ChatInput.tsx"
click node_chat_messages "https://github.com/deeparajasabeson/ecommerce-ai-assistant/blob/main/frontend/src/components/ChatMessages.tsx"
click node_sidebar "https://github.com/deeparajasabeson/ecommerce-ai-assistant/blob/main/frontend/src/components/Sidebar.tsx"
click node_chat_service "https://github.com/deeparajasabeson/ecommerce-ai-assistant/blob/main/frontend/src/services/chatService.ts"
click node_chat_route "https://github.com/deeparajasabeson/ecommerce-ai-assistant/blob/main/backend/app/routes/chat.py"
click node_orchestrator_service "https://github.com/deeparajasabeson/ecommerce-ai-assistant/blob/main/backend/app/services/orchestrator_service.py"
click node_orchestrator "https://github.com/deeparajasabeson/ecommerce-ai-assistant/blob/main/backend/ai/orchestrator/intelligent.py"
click node_specialists "https://github.com/deeparajasabeson/ecommerce-ai-assistant/tree/main/backend/ai/agents"
click node_agent_runtime "https://github.com/deeparajasabeson/ecommerce-ai-assistant/blob/main/backend/ai/agents/base.py"
click node_tool_definitions "https://github.com/deeparajasabeson/ecommerce-ai-assistant/blob/main/backend/ai/tools/definitions.py"
click node_tool_executors "https://github.com/deeparajasabeson/ecommerce-ai-assistant/blob/main/backend/ai/tools/executors.py"
click node_api_client "https://github.com/deeparajasabeson/ecommerce-ai-assistant/blob/main/backend/ai/tools/api_client.py"
click node_api_app "https://github.com/deeparajasabeson/ecommerce-ai-assistant/blob/main/backend/main.py"
click node_product_api "https://github.com/deeparajasabeson/ecommerce-ai-assistant/blob/main/backend/app/routes/product.py"
click node_order_api "https://github.com/deeparajasabeson/ecommerce-ai-assistant/blob/main/backend/app/routes/order.py"
click node_shipping_api "https://github.com/deeparajasabeson/ecommerce-ai-assistant/blob/main/backend/app/routes/shipping.py"
click node_customer_api "https://github.com/deeparajasabeson/ecommerce-ai-assistant/blob/main/backend/app/routes/customer.py"
click node_payment_api "https://github.com/deeparajasabeson/ecommerce-ai-assistant/blob/main/backend/app/routes/payment.py"
click node_repo_providers "https://github.com/deeparajasabeson/ecommerce-ai-assistant/blob/main/backend/app/data/repositories.py"
click node_product_repo "https://github.com/deeparajasabeson/ecommerce-ai-assistant/blob/main/backend/app/data/product_repository.py"
click node_order_repo "https://github.com/deeparajasabeson/ecommerce-ai-assistant/blob/main/backend/app/data/order_repository.py"
click node_shipping_repo "https://github.com/deeparajasabeson/ecommerce-ai-assistant/blob/main/backend/app/data/shipping_repository.py"
click node_customer_repo "https://github.com/deeparajasabeson/ecommerce-ai-assistant/blob/main/backend/app/data/customer_repository.py"
click node_db_pool "https://github.com/deeparajasabeson/ecommerce-ai-assistant/blob/main/backend/app/database.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_ui,node_chat_input,node_chat_messages,node_sidebar,node_chat_service toneBlue
class node_chat_route,node_orchestrator_service,node_postgres toneAmber
class node_orchestrator,node_specialists,node_agent_runtime,node_tool_definitions,node_tool_executors,node_api_client toneMint
class node_api_app,node_product_api,node_order_api,node_shipping_api,node_customer_api,node_payment_api toneRose
class node_repo_providers,node_product_repo,node_order_repo,node_shipping_repo,node_customer_repo,node_db_pool,node_customer,node_azure_foundry toneIndigo
```

## Components

### Chat interface

- [Chat app](https://github.com/deeparajasabeson/ecommerce-ai-assistant/blob/main/frontend/src/App.tsx): `frontend/src/App.tsx`
- [Chat input](https://github.com/deeparajasabeson/ecommerce-ai-assistant/blob/main/frontend/src/components/ChatInput.tsx): `frontend/src/components/ChatInput.tsx`
- [Conversation view](https://github.com/deeparajasabeson/ecommerce-ai-assistant/blob/main/frontend/src/components/ChatMessages.tsx): `frontend/src/components/ChatMessages.tsx`
- [Agent sidebar](https://github.com/deeparajasabeson/ecommerce-ai-assistant/blob/main/frontend/src/components/Sidebar.tsx): `frontend/src/components/Sidebar.tsx`
- [Chat client](https://github.com/deeparajasabeson/ecommerce-ai-assistant/blob/main/frontend/src/services/chatService.ts): `frontend/src/services/chatService.ts`

### Chat and routing

- [Chat endpoint](https://github.com/deeparajasabeson/ecommerce-ai-assistant/blob/main/backend/app/routes/chat.py): `backend/app/routes/chat.py`
- [Orchestrator service](https://github.com/deeparajasabeson/ecommerce-ai-assistant/blob/main/backend/app/services/orchestrator_service.py): `backend/app/services/orchestrator_service.py`

### AI agents and tools

- [Query orchestrator](https://github.com/deeparajasabeson/ecommerce-ai-assistant/blob/main/backend/ai/orchestrator/intelligent.py): `backend/ai/orchestrator/intelligent.py`
- [Specialist agents](https://github.com/deeparajasabeson/ecommerce-ai-assistant/tree/main/backend/ai/agents): `backend/ai/agents`
- [Agent runtime](https://github.com/deeparajasabeson/ecommerce-ai-assistant/blob/main/backend/ai/agents/base.py): `backend/ai/agents/base.py`
- [Tool definitions](https://github.com/deeparajasabeson/ecommerce-ai-assistant/blob/main/backend/ai/tools/definitions.py): `backend/ai/tools/definitions.py`
- [Tool executors](https://github.com/deeparajasabeson/ecommerce-ai-assistant/blob/main/backend/ai/tools/executors.py): `backend/ai/tools/executors.py`
- [E-commerce API client](https://github.com/deeparajasabeson/ecommerce-ai-assistant/blob/main/backend/ai/tools/api_client.py): `backend/ai/tools/api_client.py`

### Store API

- [FastAPI app](https://github.com/deeparajasabeson/ecommerce-ai-assistant/blob/main/backend/main.py): `backend/main.py`
- [Product API](https://github.com/deeparajasabeson/ecommerce-ai-assistant/blob/main/backend/app/routes/product.py): `backend/app/routes/product.py`
- [Order API](https://github.com/deeparajasabeson/ecommerce-ai-assistant/blob/main/backend/app/routes/order.py): `backend/app/routes/order.py`
- [Shipping API](https://github.com/deeparajasabeson/ecommerce-ai-assistant/blob/main/backend/app/routes/shipping.py): `backend/app/routes/shipping.py`
- [Customer API](https://github.com/deeparajasabeson/ecommerce-ai-assistant/blob/main/backend/app/routes/customer.py): `backend/app/routes/customer.py`
- [Payment API](https://github.com/deeparajasabeson/ecommerce-ai-assistant/blob/main/backend/app/routes/payment.py): `backend/app/routes/payment.py`

### Persistence

- [Repository providers](https://github.com/deeparajasabeson/ecommerce-ai-assistant/blob/main/backend/app/data/repositories.py): `backend/app/data/repositories.py`
- [Product repository](https://github.com/deeparajasabeson/ecommerce-ai-assistant/blob/main/backend/app/data/product_repository.py): `backend/app/data/product_repository.py`
- [Order repository](https://github.com/deeparajasabeson/ecommerce-ai-assistant/blob/main/backend/app/data/order_repository.py): `backend/app/data/order_repository.py`
- [Shipping repository](https://github.com/deeparajasabeson/ecommerce-ai-assistant/blob/main/backend/app/data/shipping_repository.py): `backend/app/data/shipping_repository.py`
- [Customer repository](https://github.com/deeparajasabeson/ecommerce-ai-assistant/blob/main/backend/app/data/customer_repository.py): `backend/app/data/customer_repository.py`
- [PostgreSQL pool](https://github.com/deeparajasabeson/ecommerce-ai-assistant/blob/main/backend/app/database.py): `backend/app/database.py`

### Other components

- **Customer**
- **PostgreSQL**
- **Azure AI Foundry**

## Connections

- Customer → Chat app: enters prompt
- Chat app → Chat input: renders (evidence: `frontend/src/App.tsx`)
- Chat app → Conversation view: renders (evidence: `frontend/src/App.tsx`)
- Chat app → Agent sidebar: renders (evidence: `frontend/src/App.tsx`)
- Chat app → Chat client: sends query (evidence: `frontend/src/App.tsx`)
- Chat client → Chat endpoint: POSTs query
- Chat endpoint → Orchestrator service: routes query (evidence: `backend/app/routes/chat.py`)
- Orchestrator service → Query orchestrator: routes query (evidence: `backend/app/services/orchestrator_service.py`)
- Orchestrator service → Specialist agents: initializes (evidence: `backend/app/services/orchestrator_service.py`)
- Query orchestrator → Specialist agents: dispatches query (evidence: `backend/ai/orchestrator/intelligent.py`)
- Specialist agents → Agent runtime: extends runtime (evidence: `backend/ai/agents/order.py`)
- Agent runtime → Tool definitions: registers tools (evidence: `backend/ai/agents/order.py`)
- Agent runtime → Tool executors: loads callbacks (evidence: `backend/ai/agents/base.py`)
- Tool executors → E-commerce API client: calls API methods (evidence: `backend/ai/tools/executors.py`)
- E-commerce API client → Product API: requests products
- E-commerce API client → Order API: requests orders
- E-commerce API client → Shipping API: requests shipping
- E-commerce API client → Customer API: requests customers
- E-commerce API client → Payment API: requests payments (evidence: `backend/ai/tools/api_client.py`)
- FastAPI app → Product API: registers router (evidence: `backend/main.py`)
- FastAPI app → Order API: registers router (evidence: `backend/main.py`)
- FastAPI app → Shipping API: registers router (evidence: `backend/main.py`)
- FastAPI app → Customer API: registers router (evidence: `backend/main.py`)
- FastAPI app → Payment API: registers router (evidence: `backend/main.py`)
- FastAPI app → Chat endpoint: registers router (evidence: `backend/main.py`)
- Product API → Repository providers: uses dependency (evidence: `backend/app/routes/product.py`)
- Order API → Repository providers: uses dependency (evidence: `backend/app/routes/order.py`)
- Shipping API → Repository providers: uses dependency (evidence: `backend/app/routes/shipping.py`)
- Customer API → Repository providers: uses dependency (evidence: `backend/app/routes/customer.py`)
- Payment API → Repository providers: uses dependency (evidence: `backend/app/routes/payment.py`)
- Repository providers → Product repository: provides (evidence: `backend/app/data/repositories.py`)
- Repository providers → Order repository: provides (evidence: `backend/app/data/repositories.py`)
- Repository providers → Shipping repository: provides (evidence: `backend/app/data/repositories.py`)
- Repository providers → Customer repository: provides (evidence: `backend/app/data/repositories.py`)
- FastAPI app → PostgreSQL pool: initializes pool (evidence: `backend/main.py`)
- PostgreSQL pool → PostgreSQL: opens connections (evidence: `backend/app/database.py`)
- Specialist agents → Azure AI Foundry: uses agents (evidence: `backend/ai/agents/base.py`)
