# umaravuri/ecommerce-chatbot architecture

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

- Interactive diagram: https://gitdiagram.com/umaravuri/ecommerce-chatbot
- Repository: https://github.com/umaravuri/ecommerce-chatbot

## Overview

This is an e-commerce support chatbot that routes questions to policy retrieval, read-only database queries, combined answers, or human escalation. The main flow runs from the user through the chatbot and orchestrator; the orchestrator invokes the selected retrieval/execution stages and generates the answer. The graph preserves the separate SQL-generation capability and index-building path. Some connections are supported only by README descriptions or the source index; unsampled implementation details are not inferred.

Main entry points: [`app/orchestrator/orchestrator.py`](https://github.com/umaravuri/ecommerce-chatbot/blob/main/app/orchestrator/orchestrator.py) (Question orchestrator), [`app/orchestrator/router.py`](https://github.com/umaravuri/ecommerce-chatbot/blob/main/app/orchestrator/router.py) (Route classifier), [`app/indexing/index_manager.py`](https://github.com/umaravuri/ecommerce-chatbot/blob/main/app/indexing/index_manager.py) (Index manager), [`app/orchestrator/generator.py`](https://github.com/umaravuri/ecommerce-chatbot/blob/main/app/orchestrator/generator.py) (Response generator)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Chat entry"]
  node_chatbot["Chatbot CLI<br/>[chatbot.py]"]
end

subgraph group_routing["Routing and response"]
  node_orchestrator["Question orchestrator<br/>[orchestrator.py]"]
  node_router["Route classifier<br/>[router.py]"]
  node_response["Response generator<br/>[generator.py]"]
  node_orchestrator_prompt["Routing and answer prompts<br/>[prompt.py]"]
end

subgraph group_knowledge["Knowledge retrieval"]
  node_kb["Policy knowledge base"]
  node_loader["Markdown loader<br/>[loader.py]"]
  node_index_manager["Index manager<br/>[index_manager.py]"]
  node_index_settings["Embedding and LLM settings<br/>[settings.py]"]
  node_index_builder["Index builder<br/>[index_builder.py]"]
  node_query_engine["Knowledge retriever<br/>[query_engine.py]"]
end

subgraph group_sql["SQL agent"]
  node_sql_generator["SQL generator<br/>[sql_generator.py]"]
  node_sql_prompt["SQL generation prompt<br/>[prompt.py]"]
  node_schema_loader["Schema loader<br/>[schema_loader.py]"]
  node_sql_validator["SQL safety validator<br/>[sql_validator.py]"]
  node_sql_executor["SQL executor<br/>[sql_executor.py]"]
end

subgraph group_data["Data sources"]
  node_index_storage[("Persisted index")]
  node_db_connection["Database connection<br/>[connection.py]"]
  node_mysql[("MySQL database")]
end

node_user(("Customer"))
node_gemini(("Google Gemini"))
node_human(("Human support"))

node_user -->|"asks"| node_chatbot
node_chatbot -->|"processes question"| node_orchestrator
node_orchestrator -->|"routes question"| node_router
node_router -->|"loads schema"| node_schema_loader
node_router -->|"classifies"| node_gemini
node_router -->|"uses prompt"| node_orchestrator_prompt
node_orchestrator -->|"retrieves policies"| node_query_engine
node_query_engine -->|"gets index"| node_index_manager
node_index_manager -->|"loads documents"| node_loader
node_index_manager -->|"configures indexing"| node_index_settings
node_loader -->|"loads Markdown"| node_kb
node_index_manager -->|"loads or persists"| node_index_storage
node_index_builder -->|"configures index"| node_index_settings
node_orchestrator -->|"validates SQL"| node_sql_validator
node_orchestrator -->|"executes SQL"| node_sql_executor
node_sql_executor -->|"uses engine"| node_db_connection
node_schema_loader -->|"inspects schema"| node_db_connection
node_db_connection -.->|"connects"| node_mysql
node_orchestrator -->|"generates answer"| node_response
node_response -->|"uses prompt"| node_orchestrator_prompt
node_response -->|"generates text"| node_gemini
node_orchestrator -->|"escalates request"| node_human
node_sql_generator -->|"uses prompt"| node_sql_prompt
node_sql_generator -->|"loads schema"| node_schema_loader

click node_chatbot "https://github.com/umaravuri/ecommerce-chatbot/blob/main/app/chatbot.py"
click node_orchestrator "https://github.com/umaravuri/ecommerce-chatbot/blob/main/app/orchestrator/orchestrator.py"
click node_router "https://github.com/umaravuri/ecommerce-chatbot/blob/main/app/orchestrator/router.py"
click node_response "https://github.com/umaravuri/ecommerce-chatbot/blob/main/app/orchestrator/generator.py"
click node_orchestrator_prompt "https://github.com/umaravuri/ecommerce-chatbot/blob/main/app/orchestrator/prompt.py"
click node_kb "https://github.com/umaravuri/ecommerce-chatbot/tree/main/data/e_commerce_knowledge_base"
click node_loader "https://github.com/umaravuri/ecommerce-chatbot/blob/main/app/indexing/loader.py"
click node_index_manager "https://github.com/umaravuri/ecommerce-chatbot/blob/main/app/indexing/index_manager.py"
click node_index_settings "https://github.com/umaravuri/ecommerce-chatbot/blob/main/app/indexing/settings.py"
click node_index_builder "https://github.com/umaravuri/ecommerce-chatbot/blob/main/app/indexing/index_builder.py"
click node_query_engine "https://github.com/umaravuri/ecommerce-chatbot/blob/main/app/indexing/query_engine.py"
click node_index_storage "https://github.com/umaravuri/ecommerce-chatbot/tree/main/storage"
click node_sql_generator "https://github.com/umaravuri/ecommerce-chatbot/blob/main/app/sql_agent/sql_generator.py"
click node_sql_prompt "https://github.com/umaravuri/ecommerce-chatbot/blob/main/app/sql_agent/prompt.py"
click node_schema_loader "https://github.com/umaravuri/ecommerce-chatbot/blob/main/app/sql_agent/schema_loader.py"
click node_sql_validator "https://github.com/umaravuri/ecommerce-chatbot/blob/main/app/sql_agent/sql_validator.py"
click node_sql_executor "https://github.com/umaravuri/ecommerce-chatbot/blob/main/app/sql_agent/sql_executor.py"
click node_db_connection "https://github.com/umaravuri/ecommerce-chatbot/blob/main/app/db/connection.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_chatbot toneBlue
class node_orchestrator,node_router,node_response,node_orchestrator_prompt toneAmber
class node_kb,node_loader,node_index_manager,node_index_settings,node_index_builder,node_query_engine toneMint
class node_sql_generator,node_sql_prompt,node_schema_loader,node_sql_validator,node_sql_executor toneRose
class node_index_storage,node_db_connection,node_mysql,node_user,node_gemini,node_human toneIndigo
```

## Components

### Chat entry

- [Chatbot CLI](https://github.com/umaravuri/ecommerce-chatbot/blob/main/app/chatbot.py): `app/chatbot.py`

### Routing and response

- [Question orchestrator](https://github.com/umaravuri/ecommerce-chatbot/blob/main/app/orchestrator/orchestrator.py): `app/orchestrator/orchestrator.py`
- [Route classifier](https://github.com/umaravuri/ecommerce-chatbot/blob/main/app/orchestrator/router.py): `app/orchestrator/router.py`
- [Response generator](https://github.com/umaravuri/ecommerce-chatbot/blob/main/app/orchestrator/generator.py): `app/orchestrator/generator.py`
- [Routing and answer prompts](https://github.com/umaravuri/ecommerce-chatbot/blob/main/app/orchestrator/prompt.py): `app/orchestrator/prompt.py`

### Knowledge retrieval

- [Policy knowledge base](https://github.com/umaravuri/ecommerce-chatbot/tree/main/data/e_commerce_knowledge_base): `data/e_commerce_knowledge_base`
- [Markdown loader](https://github.com/umaravuri/ecommerce-chatbot/blob/main/app/indexing/loader.py): `app/indexing/loader.py`
- [Index manager](https://github.com/umaravuri/ecommerce-chatbot/blob/main/app/indexing/index_manager.py): `app/indexing/index_manager.py`
- [Embedding and LLM settings](https://github.com/umaravuri/ecommerce-chatbot/blob/main/app/indexing/settings.py): `app/indexing/settings.py`
- [Index builder](https://github.com/umaravuri/ecommerce-chatbot/blob/main/app/indexing/index_builder.py): `app/indexing/index_builder.py`
- [Knowledge retriever](https://github.com/umaravuri/ecommerce-chatbot/blob/main/app/indexing/query_engine.py): `app/indexing/query_engine.py`

### SQL agent

- [SQL generator](https://github.com/umaravuri/ecommerce-chatbot/blob/main/app/sql_agent/sql_generator.py): `app/sql_agent/sql_generator.py`
- [SQL generation prompt](https://github.com/umaravuri/ecommerce-chatbot/blob/main/app/sql_agent/prompt.py): `app/sql_agent/prompt.py`
- [Schema loader](https://github.com/umaravuri/ecommerce-chatbot/blob/main/app/sql_agent/schema_loader.py): `app/sql_agent/schema_loader.py`
- [SQL safety validator](https://github.com/umaravuri/ecommerce-chatbot/blob/main/app/sql_agent/sql_validator.py): `app/sql_agent/sql_validator.py`
- [SQL executor](https://github.com/umaravuri/ecommerce-chatbot/blob/main/app/sql_agent/sql_executor.py): `app/sql_agent/sql_executor.py`

### Data sources

- [Persisted index](https://github.com/umaravuri/ecommerce-chatbot/tree/main/storage): `storage`
- [Database connection](https://github.com/umaravuri/ecommerce-chatbot/blob/main/app/db/connection.py): `app/db/connection.py`
- **MySQL database**

### Other components

- **Customer**
- **Google Gemini**
- **Human support**

## Connections

- Customer → Chatbot CLI: asks (evidence: `readme.txt`)
- Chatbot CLI → Question orchestrator: processes question (evidence: `app/chatbot.py`)
- Question orchestrator → Route classifier: routes question (evidence: `app/orchestrator/orchestrator.py`)
- Route classifier → Schema loader: loads schema (evidence: `app/orchestrator/router.py`)
- Route classifier → Google Gemini: classifies (evidence: `app/orchestrator/router.py`)
- Route classifier → Routing and answer prompts: uses prompt (evidence: `app/orchestrator/router.py`)
- Question orchestrator → Knowledge retriever: retrieves policies (evidence: `app/orchestrator/orchestrator.py`)
- Knowledge retriever → Index manager: gets index (evidence: `app/indexing/query_engine.py`)
- Index manager → Markdown loader: loads documents (evidence: `app/indexing/index_manager.py`)
- Index manager → Embedding and LLM settings: configures indexing (evidence: `app/indexing/index_manager.py`)
- Markdown loader → Policy knowledge base: loads Markdown (evidence: `readme.txt`)
- Index manager → Persisted index: loads or persists (evidence: `app/indexing/index_manager.py`)
- Index builder → Embedding and LLM settings: configures index (evidence: `app/indexing/index_builder.py`)
- Question orchestrator → SQL safety validator: validates SQL (evidence: `app/orchestrator/orchestrator.py`)
- Question orchestrator → SQL executor: executes SQL (evidence: `app/orchestrator/orchestrator.py`)
- SQL executor → Database connection: uses engine (evidence: `app/sql_agent/sql_executor.py`)
- Schema loader → Database connection: inspects schema (evidence: `app/sql_agent/schema_loader.py`)
- Database connection → MySQL database: connects
- Question orchestrator → Response generator: generates answer (evidence: `app/orchestrator/orchestrator.py`)
- Response generator → Routing and answer prompts: uses prompt (evidence: `app/orchestrator/generator.py`)
- Response generator → Google Gemini: generates text (evidence: `app/orchestrator/generator.py`)
- Question orchestrator → Human support: escalates request (evidence: `readme.txt`)
- SQL generator → SQL generation prompt: uses prompt (evidence: `app/sql_agent/sql_generator.py`)
- SQL generator → Schema loader: loads schema (evidence: `app/sql_agent/sql_generator.py`)
