# jangidprashant92/my-ai-ecomm architecture

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

- Interactive diagram: https://gitdiagram.com/jangidprashant92/my-ai-ecomm
- Repository: https://github.com/jangidprashant92/my-ai-ecomm

## Overview

CommerceOps AI is a commerce-support chat application: users submit questions in the web client, the API streams agent responses, and conversations and messages are persisted. The documented agent combines commerce tools, authorization and human review with a RAG knowledge workflow; PostgreSQL, SQLite checkpoints and Qdrant support distinct state and retrieval needs. The repository also documents analytics, product/order services, document ingestion and RAG evaluation. Relationships for unsampled modules are included only where the README or source index supports them; detailed internal call paths remain uncertain.

Main entry points: [`backend/app/ai/agents/commerce_agent.py`](https://github.com/jangidprashant92/my-ai-ecomm/blob/main/backend/app/ai/agents/commerce_agent.py) (Commerce agent), [`backend/app/ai/rag/service.py`](https://github.com/jangidprashant92/my-ai-ecomm/blob/main/backend/app/ai/rag/service.py) (RAG service), [`backend/app/modules/messages/services.py`](https://github.com/jangidprashant92/my-ai-ecomm/blob/main/backend/app/modules/messages/services.py) (Message service), [`backend/app/ai/graph/builder.py`](https://github.com/jangidprashant92/my-ai-ecomm/blob/main/backend/app/ai/graph/builder.py) (Agent graph)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Chat client"]
  node_web["Chat interface<br/>[Chat.tsx]"]
  node_chat_context["Chat state<br/>[ChatContext.tsx]"]
  node_chat_service["Chat API client<br/>[chat.ts]"]
end

subgraph group_api["API and persistence"]
  node_api_entry["FastAPI entry<br/>[main.py]"]
  node_message_routes["Message routes<br/>[routes.py]"]
  node_message_service["Message service<br/>[services.py]"]
  node_conversation_service["Conversation service<br/>[services.py]"]
  node_memory_service["Conversation memory<br/>[services.py]"]
  node_postgres[("PostgreSQL<br/>[database.py]")]
end

subgraph group_agent["Commerce agent"]
  node_checkpoint[("Graph checkpoints<br/>[config.py]")]
  node_agent_graph["Agent graph<br/>[builder.py]"]
  node_commerce_agent["Commerce agent<br/>[commerce_agent.py]"]
  node_middleware["Policy and review<br/>[authorization.py]"]
  node_commerce_tools["Commerce tools"]
  node_llm["LLM provider<br/>[factory.py]"]
end

subgraph group_knowledge["Knowledge retrieval"]
  node_rag_service["RAG service<br/>[service.py]"]
  node_query_rewriter["Query rewriting<br/>[query_rewriter.py]"]
  node_embeddings["Embeddings<br/>[embeddings.py]"]
  node_vector_store[("Qdrant store<br/>[vector_store.py]")]
  node_ingestion["Document ingestion"]
end

subgraph group_commerce["Commerce data and evaluation"]
  node_orders["Order service<br/>[service.py]"]
  node_order_data[("Order records<br/>[order.py]")]
  node_products["Product service<br/>[service.py]"]
  node_analytics["Commerce analytics<br/>[service.py]"]
  node_todo["Todo API<br/>[schemas.py]"]
  node_rag_eval["RAG evaluation<br/>[scorers.py]"]
end

node_user(("Chat user"))

node_user -->|"asks"| node_web
node_web -.->|"updates"| node_chat_context
node_chat_context -.->|"requests"| node_chat_service
node_chat_service -.->|"calls"| node_message_routes
node_api_entry -->|"registers"| node_message_routes
node_api_entry -->|"registers routes"| node_conversation_service
node_message_routes -->|"dispatches"| node_message_service
node_message_service -.->|"streams agent"| node_agent_graph
node_message_service -.->|"persists messages"| node_postgres
node_conversation_service -.->|"persists conversations"| node_postgres
node_memory_service -.->|"stores memory"| node_postgres
node_agent_graph -.->|"builds agent"| node_commerce_agent
node_agent_graph -.->|"checkpoints"| node_checkpoint
node_commerce_agent -.->|"enforces policy"| node_middleware
node_commerce_agent -.->|"invokes tools"| node_commerce_tools
node_commerce_agent -.->|"uses model"| node_llm
node_commerce_agent -.->|"retrieves knowledge"| node_rag_service
node_rag_service -.->|"rewrites query"| node_query_rewriter
node_rag_service -.->|"embeds query"| node_embeddings
node_rag_service -.->|"retrieves documents"| node_vector_store
node_ingestion -.->|"indexes documents"| node_vector_store
node_commerce_tools -.->|"accesses orders"| node_orders
node_commerce_tools -.->|"accesses products"| node_products
node_orders -.->|"reads orders"| node_order_data
node_analytics -->|"analyzes orders"| node_order_data
node_rag_eval -->|"evaluates retrieval"| node_rag_service

click node_web "https://github.com/jangidprashant92/my-ai-ecomm/blob/main/frontend/src/pages/Chat.tsx"
click node_chat_context "https://github.com/jangidprashant92/my-ai-ecomm/blob/main/frontend/src/context/ChatContext.tsx"
click node_chat_service "https://github.com/jangidprashant92/my-ai-ecomm/blob/main/frontend/src/services/chat.ts"
click node_api_entry "https://github.com/jangidprashant92/my-ai-ecomm/blob/main/backend/main.py"
click node_message_routes "https://github.com/jangidprashant92/my-ai-ecomm/blob/main/backend/app/modules/messages/routes.py"
click node_message_service "https://github.com/jangidprashant92/my-ai-ecomm/blob/main/backend/app/modules/messages/services.py"
click node_conversation_service "https://github.com/jangidprashant92/my-ai-ecomm/blob/main/backend/app/modules/conversations/services.py"
click node_memory_service "https://github.com/jangidprashant92/my-ai-ecomm/blob/main/backend/app/modules/memory/services.py"
click node_postgres "https://github.com/jangidprashant92/my-ai-ecomm/blob/main/backend/app/core/database.py"
click node_checkpoint "https://github.com/jangidprashant92/my-ai-ecomm/blob/main/backend/app/core/config.py"
click node_agent_graph "https://github.com/jangidprashant92/my-ai-ecomm/blob/main/backend/app/ai/graph/builder.py"
click node_commerce_agent "https://github.com/jangidprashant92/my-ai-ecomm/blob/main/backend/app/ai/agents/commerce_agent.py"
click node_middleware "https://github.com/jangidprashant92/my-ai-ecomm/blob/main/backend/app/ai/middleware/authorization.py"
click node_commerce_tools "https://github.com/jangidprashant92/my-ai-ecomm/tree/main/backend/app/ai/tools"
click node_llm "https://github.com/jangidprashant92/my-ai-ecomm/blob/main/backend/app/ai/llm/factory.py"
click node_rag_service "https://github.com/jangidprashant92/my-ai-ecomm/blob/main/backend/app/ai/rag/service.py"
click node_query_rewriter "https://github.com/jangidprashant92/my-ai-ecomm/blob/main/backend/app/ai/rag/query_rewriter.py"
click node_embeddings "https://github.com/jangidprashant92/my-ai-ecomm/blob/main/backend/app/ai/rag/embeddings.py"
click node_vector_store "https://github.com/jangidprashant92/my-ai-ecomm/blob/main/backend/app/ai/rag/vector_store.py"
click node_ingestion "https://github.com/jangidprashant92/my-ai-ecomm/blob/main/backend/app/scripts/ingest_documents.py"
click node_orders "https://github.com/jangidprashant92/my-ai-ecomm/blob/main/backend/app/modules/orders/service.py"
click node_order_data "https://github.com/jangidprashant92/my-ai-ecomm/blob/main/backend/app/models/order.py"
click node_products "https://github.com/jangidprashant92/my-ai-ecomm/blob/main/backend/app/modules/products/service.py"
click node_analytics "https://github.com/jangidprashant92/my-ai-ecomm/blob/main/backend/app/modules/analytics/service.py"
click node_todo "https://github.com/jangidprashant92/my-ai-ecomm/blob/main/backend/app/modules/todo/schemas.py"
click node_rag_eval "https://github.com/jangidprashant92/my-ai-ecomm/blob/main/backend/evaluation/rag/scorers.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_web,node_chat_context,node_chat_service,node_user toneBlue
class node_api_entry,node_message_routes,node_message_service,node_conversation_service,node_memory_service,node_postgres toneAmber
class node_checkpoint,node_agent_graph,node_commerce_agent,node_middleware,node_commerce_tools,node_llm toneMint
class node_rag_service,node_query_rewriter,node_embeddings,node_vector_store,node_ingestion toneRose
class node_orders,node_order_data,node_products,node_analytics,node_todo,node_rag_eval toneIndigo
```

## Components

### Chat client

- [Chat interface](https://github.com/jangidprashant92/my-ai-ecomm/blob/main/frontend/src/pages/Chat.tsx): `frontend/src/pages/Chat.tsx`
- [Chat state](https://github.com/jangidprashant92/my-ai-ecomm/blob/main/frontend/src/context/ChatContext.tsx): `frontend/src/context/ChatContext.tsx`
- [Chat API client](https://github.com/jangidprashant92/my-ai-ecomm/blob/main/frontend/src/services/chat.ts): `frontend/src/services/chat.ts`

### API and persistence

- [FastAPI entry](https://github.com/jangidprashant92/my-ai-ecomm/blob/main/backend/main.py): `backend/main.py`
- [Message routes](https://github.com/jangidprashant92/my-ai-ecomm/blob/main/backend/app/modules/messages/routes.py): `backend/app/modules/messages/routes.py`
- [Message service](https://github.com/jangidprashant92/my-ai-ecomm/blob/main/backend/app/modules/messages/services.py): `backend/app/modules/messages/services.py`
- [Conversation service](https://github.com/jangidprashant92/my-ai-ecomm/blob/main/backend/app/modules/conversations/services.py): `backend/app/modules/conversations/services.py`
- [Conversation memory](https://github.com/jangidprashant92/my-ai-ecomm/blob/main/backend/app/modules/memory/services.py): `backend/app/modules/memory/services.py`
- [PostgreSQL](https://github.com/jangidprashant92/my-ai-ecomm/blob/main/backend/app/core/database.py): `backend/app/core/database.py`

### Commerce agent

- [Graph checkpoints](https://github.com/jangidprashant92/my-ai-ecomm/blob/main/backend/app/core/config.py): `backend/app/core/config.py`
- [Agent graph](https://github.com/jangidprashant92/my-ai-ecomm/blob/main/backend/app/ai/graph/builder.py): `backend/app/ai/graph/builder.py`
- [Commerce agent](https://github.com/jangidprashant92/my-ai-ecomm/blob/main/backend/app/ai/agents/commerce_agent.py): `backend/app/ai/agents/commerce_agent.py`
- [Policy and review](https://github.com/jangidprashant92/my-ai-ecomm/blob/main/backend/app/ai/middleware/authorization.py): `backend/app/ai/middleware/authorization.py`
- [Commerce tools](https://github.com/jangidprashant92/my-ai-ecomm/tree/main/backend/app/ai/tools): `backend/app/ai/tools`
- [LLM provider](https://github.com/jangidprashant92/my-ai-ecomm/blob/main/backend/app/ai/llm/factory.py): `backend/app/ai/llm/factory.py`

### Knowledge retrieval

- [RAG service](https://github.com/jangidprashant92/my-ai-ecomm/blob/main/backend/app/ai/rag/service.py): `backend/app/ai/rag/service.py`
- [Query rewriting](https://github.com/jangidprashant92/my-ai-ecomm/blob/main/backend/app/ai/rag/query_rewriter.py): `backend/app/ai/rag/query_rewriter.py`
- [Embeddings](https://github.com/jangidprashant92/my-ai-ecomm/blob/main/backend/app/ai/rag/embeddings.py): `backend/app/ai/rag/embeddings.py`
- [Qdrant store](https://github.com/jangidprashant92/my-ai-ecomm/blob/main/backend/app/ai/rag/vector_store.py): `backend/app/ai/rag/vector_store.py`
- [Document ingestion](https://github.com/jangidprashant92/my-ai-ecomm/blob/main/backend/app/scripts/ingest_documents.py): `backend/app/scripts/ingest_documents.py`

### Commerce data and evaluation

- [Order service](https://github.com/jangidprashant92/my-ai-ecomm/blob/main/backend/app/modules/orders/service.py): `backend/app/modules/orders/service.py`
- [Order records](https://github.com/jangidprashant92/my-ai-ecomm/blob/main/backend/app/models/order.py): `backend/app/models/order.py`
- [Product service](https://github.com/jangidprashant92/my-ai-ecomm/blob/main/backend/app/modules/products/service.py): `backend/app/modules/products/service.py`
- [Commerce analytics](https://github.com/jangidprashant92/my-ai-ecomm/blob/main/backend/app/modules/analytics/service.py): `backend/app/modules/analytics/service.py`
- [Todo API](https://github.com/jangidprashant92/my-ai-ecomm/blob/main/backend/app/modules/todo/schemas.py): `backend/app/modules/todo/schemas.py`
- [RAG evaluation](https://github.com/jangidprashant92/my-ai-ecomm/blob/main/backend/evaluation/rag/scorers.py): `backend/evaluation/rag/scorers.py`

### Other components

- **Chat user**

## Connections

- Chat user → Chat interface: asks
- Chat interface → Chat state: updates
- Chat state → Chat API client: requests
- Chat API client → Message routes: calls
- FastAPI entry → Message routes: registers (evidence: `backend/main.py`)
- FastAPI entry → Conversation service: registers routes (evidence: `backend/main.py`)
- Message routes → Message service: dispatches (evidence: `backend/app/modules/messages/routes.py`)
- Message service → Agent graph: streams agent
- Message service → PostgreSQL: persists messages
- Conversation service → PostgreSQL: persists conversations
- Conversation memory → PostgreSQL: stores memory (evidence: `backend/app/modules/memory/services.py`)
- Agent graph → Commerce agent: builds agent (evidence: `backend/app/core/lifespan.py`)
- Agent graph → Graph checkpoints: checkpoints
- Commerce agent → Policy and review: enforces policy
- Commerce agent → Commerce tools: invokes tools
- Commerce agent → LLM provider: uses model (evidence: `backend/app/core/lifespan.py`)
- Commerce agent → RAG service: retrieves knowledge
- RAG service → Query rewriting: rewrites query
- RAG service → Embeddings: embeds query
- RAG service → Qdrant store: retrieves documents
- Document ingestion → Qdrant store: indexes documents
- Commerce tools → Order service: accesses orders
- Commerce tools → Product service: accesses products
- Order service → Order records: reads orders (evidence: `backend/app/models/order.py`)
- Commerce analytics → Order records: analyzes orders
- RAG evaluation → RAG service: evaluates retrieval
