# anshmahajan-grep/customer_support_agent architecture

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

- Interactive diagram: https://gitdiagram.com/anshmahajan-grep/customer_support_agent
- Repository: https://github.com/anshmahajan-grep/customer_support_agent

## Overview

This is an AI customer-support application: customers submit threaded questions, the backend processes them asynchronously through a context-aware RAG agent, and answers are persisted for live display; low-confidence cases enter a human-resolution workflow. Admins also inspect analytics and feedback and upload knowledge sources. The graph combines sampled call sites with README-documented capabilities; unsampled agent stages and routes are represented at their exact tree paths, but their internal calls are not inferred.

Main entry points: [`Backend/app/routes`](https://github.com/anshmahajan-grep/customer_support_agent/tree/main/Backend/app/routes) (REST Routes), [`Backend/app/services/Admin/admin_service.py`](https://github.com/anshmahajan-grep/customer_support_agent/blob/main/Backend/app/services/Admin/admin_service.py) (Admin Service), [`Backend/app/services/Graph/graph.py`](https://github.com/anshmahajan-grep/customer_support_agent/blob/main/Backend/app/services/Graph/graph.py) (LangGraph Workflow), [`Backend/app/services/DataBases/Supabase/supabase_service.py`](https://github.com/anshmahajan-grep/customer_support_agent/blob/main/Backend/app/services/DataBases/Supabase/supabase_service.py) (Supabase Service)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Customer and Admin UI"]
  node_chat_ui["Chat UI<br/>[page.tsx]"]
  node_thread_hook["Live Thread"]
  node_thread_view["Thread View<br/>[QueryThread.tsx]"]
  node_admin_ui["Admin Dashboard<br/>[page.tsx]"]
  node_queue_ui["Escalation Queue<br/>[page.tsx]"]
end

subgraph group_api["API and Application Services"]
  node_routes["REST Routes"]
  node_chat_service["Chat Service<br/>[chatbox_service.py]"]
  node_admin_service["Admin Service<br/>[admin_service.py]"]
  node_processor["Query Processor<br/>[graph_service.py]"]
end

subgraph group_agent["Agent Reasoning"]
  node_graph["LangGraph Workflow<br/>[graph.py]"]
  node_memory["Conversation Memory"]
  node_query_rewrite["Query Rewrite<br/>[transform_query.py]"]
  node_agent_reasoning["RAG Agent<br/>[main_agent.py]"]
  node_confidence["Answer Evaluation<br/>[evaluator.py]"]
  node_answer_escalate["Answer and Escalation"]
end

subgraph group_knowledge["Knowledge Retrieval"]
  node_kb_ingest["Knowledge Ingestion<br/>[admin_service.py]"]
  node_service_files[("Service Knowledge<br/>[service_files.py]")]
  node_answered[("Answered Queries")]
  node_unanswered[("Unanswered Queries")]
end

subgraph group_data["Persistence and Operations"]
  node_supabase_service["Supabase Service"]
  node_supabase[("Supabase")]
  node_admin_models["Admin Models<br/>[admin.py]"]
  node_chunk_models["Chunk Models<br/>[chunking.py]"]
  node_graph_models["Graph State Models<br/>[graph.py]"]
  node_supabase_models["Data Models<br/>[supabase.py]"]
end

node_customer(("Customer"))
node_admin_user(("Admin"))
node_openai["OpenAI"]
node_deepeval["DeepEval"]

node_customer -->|"asks questions"| node_chat_ui
node_chat_ui -->|"submits via REST"| node_routes
node_routes -->|"handles chat"| node_chat_service
node_chat_service -->|"creates records"| node_supabase_service
node_chat_service -->|"schedules processing"| node_processor
node_processor -->|"invokes workflow"| node_graph
node_graph -->|"builds context"| node_memory
node_graph -->|"rewrites query"| node_query_rewrite
node_query_rewrite -->|"updates rewrite"| node_supabase_service
node_query_rewrite -->|"stores query"| node_unanswered
node_graph -->|"retrieves and reasons"| node_agent_reasoning
node_agent_reasoning -->|"searches knowledge"| node_service_files
node_agent_reasoning -->|"searches resolved cases"| node_answered
node_agent_reasoning -->|"scores candidate"| node_confidence
node_confidence -->|"evaluates quality"| node_deepeval
node_graph -->|"routes outcome"| node_answer_escalate
node_answer_escalate -->|"persists status"| node_supabase_service
node_admin_user -->|"reviews operations"| node_admin_ui
node_admin_user -->|"resolves cases"| node_queue_ui
node_admin_ui -->|"requests analytics"| node_routes
node_queue_ui -->|"requests queue"| node_routes
node_routes -->|"handles admin actions"| node_admin_service
node_admin_service -->|"reads analytics"| node_supabase
node_admin_service -->|"uploads chunks"| node_service_files
node_admin_service -.->|"reprocesses pool"| node_unanswered
node_admin_service -->|"returns typed results"| node_admin_models
node_kb_ingest -->|"creates chunks"| node_chunk_models
node_service_files -->|"embeds text"| node_openai
node_thread_hook -->|"supplies thread state"| node_chat_ui
node_thread_view -->|"renders messages"| node_chat_ui
node_thread_hook -->|"subscribes to updates"| node_supabase
node_thread_hook -->|"polls fallback"| node_routes
node_supabase_service -->|"reads and writes"| node_supabase
node_supabase_service -->|"uses data models"| node_supabase_models
node_processor -->|"constructs workflow state"| node_graph_models

click node_chat_ui "https://github.com/anshmahajan-grep/customer_support_agent/blob/main/Frontend/app/chat/%5BsessionId%5D/page.tsx"
click node_thread_hook "https://github.com/anshmahajan-grep/customer_support_agent/blob/main/Frontend/lib/supabase/useSessionThread.ts"
click node_thread_view "https://github.com/anshmahajan-grep/customer_support_agent/blob/main/Frontend/components/thread/QueryThread.tsx"
click node_admin_ui "https://github.com/anshmahajan-grep/customer_support_agent/blob/main/Frontend/app/admin/page.tsx"
click node_queue_ui "https://github.com/anshmahajan-grep/customer_support_agent/blob/main/Frontend/app/admin/queue/page.tsx"
click node_routes "https://github.com/anshmahajan-grep/customer_support_agent/tree/main/Backend/app/routes"
click node_chat_service "https://github.com/anshmahajan-grep/customer_support_agent/blob/main/Backend/app/services/Chatbox/chatbox_service.py"
click node_admin_service "https://github.com/anshmahajan-grep/customer_support_agent/blob/main/Backend/app/services/Admin/admin_service.py"
click node_processor "https://github.com/anshmahajan-grep/customer_support_agent/blob/main/Backend/app/services/Graph/graph_service.py"
click node_graph "https://github.com/anshmahajan-grep/customer_support_agent/blob/main/Backend/app/services/Graph/graph.py"
click node_memory "https://github.com/anshmahajan-grep/customer_support_agent/tree/main/Backend/app/services/Graph/nodes"
click node_query_rewrite "https://github.com/anshmahajan-grep/customer_support_agent/blob/main/Backend/app/services/Graph/nodes/transform_query.py"
click node_agent_reasoning "https://github.com/anshmahajan-grep/customer_support_agent/blob/main/Backend/app/services/Graph/nodes/main_agent.py"
click node_confidence "https://github.com/anshmahajan-grep/customer_support_agent/blob/main/Backend/app/services/Graph/nodes/tools/evaluator.py"
click node_answer_escalate "https://github.com/anshmahajan-grep/customer_support_agent/tree/main/Backend/app/services/Graph/nodes"
click node_kb_ingest "https://github.com/anshmahajan-grep/customer_support_agent/blob/main/Backend/app/services/Admin/admin_service.py"
click node_service_files "https://github.com/anshmahajan-grep/customer_support_agent/blob/main/Backend/app/services/DataBases/Qdrant/service_files.py"
click node_answered "https://github.com/anshmahajan-grep/customer_support_agent/blob/main/Backend/app/services/DataBases/Qdrant/answered_collection.py"
click node_unanswered "https://github.com/anshmahajan-grep/customer_support_agent/blob/main/Backend/app/services/DataBases/Qdrant/unanswered_collection.py"
click node_supabase_service "https://github.com/anshmahajan-grep/customer_support_agent/blob/main/Backend/app/services/DataBases/Supabase/supabase_service.py"
click node_admin_models "https://github.com/anshmahajan-grep/customer_support_agent/blob/main/Backend/app/models/admin.py"
click node_chunk_models "https://github.com/anshmahajan-grep/customer_support_agent/blob/main/Backend/app/models/chunking.py"
click node_graph_models "https://github.com/anshmahajan-grep/customer_support_agent/blob/main/Backend/app/models/graph.py"
click node_supabase_models "https://github.com/anshmahajan-grep/customer_support_agent/blob/main/Backend/app/models/supabase.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_chat_ui,node_thread_hook,node_thread_view,node_admin_ui,node_queue_ui toneBlue
class node_routes,node_chat_service,node_admin_service,node_processor toneAmber
class node_graph,node_memory,node_query_rewrite,node_agent_reasoning,node_confidence,node_answer_escalate toneMint
class node_kb_ingest,node_service_files,node_answered,node_unanswered toneRose
class node_supabase_service,node_supabase,node_admin_models,node_chunk_models,node_graph_models,node_supabase_models,node_customer,node_admin_user,node_openai,node_deepeval toneIndigo
```

## Components

### Customer and Admin UI

- [Chat UI](https://github.com/anshmahajan-grep/customer_support_agent/blob/main/Frontend/app/chat/%5BsessionId%5D/page.tsx): `Frontend/app/chat/[sessionId]/page.tsx`
- [Live Thread](https://github.com/anshmahajan-grep/customer_support_agent/blob/main/Frontend/lib/supabase/useSessionThread.ts): `Frontend/lib/supabase/useSessionThread.ts`
- [Thread View](https://github.com/anshmahajan-grep/customer_support_agent/blob/main/Frontend/components/thread/QueryThread.tsx): `Frontend/components/thread/QueryThread.tsx`
- [Admin Dashboard](https://github.com/anshmahajan-grep/customer_support_agent/blob/main/Frontend/app/admin/page.tsx): `Frontend/app/admin/page.tsx`
- [Escalation Queue](https://github.com/anshmahajan-grep/customer_support_agent/blob/main/Frontend/app/admin/queue/page.tsx): `Frontend/app/admin/queue/page.tsx`

### API and Application Services

- [REST Routes](https://github.com/anshmahajan-grep/customer_support_agent/tree/main/Backend/app/routes): `Backend/app/routes`
- [Chat Service](https://github.com/anshmahajan-grep/customer_support_agent/blob/main/Backend/app/services/Chatbox/chatbox_service.py): `Backend/app/services/Chatbox/chatbox_service.py`
- [Admin Service](https://github.com/anshmahajan-grep/customer_support_agent/blob/main/Backend/app/services/Admin/admin_service.py): `Backend/app/services/Admin/admin_service.py`
- [Query Processor](https://github.com/anshmahajan-grep/customer_support_agent/blob/main/Backend/app/services/Graph/graph_service.py): `Backend/app/services/Graph/graph_service.py`

### Agent Reasoning

- [LangGraph Workflow](https://github.com/anshmahajan-grep/customer_support_agent/blob/main/Backend/app/services/Graph/graph.py): `Backend/app/services/Graph/graph.py`
- [Conversation Memory](https://github.com/anshmahajan-grep/customer_support_agent/tree/main/Backend/app/services/Graph/nodes): `Backend/app/services/Graph/nodes`
- [Query Rewrite](https://github.com/anshmahajan-grep/customer_support_agent/blob/main/Backend/app/services/Graph/nodes/transform_query.py): `Backend/app/services/Graph/nodes/transform_query.py`
- [RAG Agent](https://github.com/anshmahajan-grep/customer_support_agent/blob/main/Backend/app/services/Graph/nodes/main_agent.py): `Backend/app/services/Graph/nodes/main_agent.py`
- [Answer Evaluation](https://github.com/anshmahajan-grep/customer_support_agent/blob/main/Backend/app/services/Graph/nodes/tools/evaluator.py): `Backend/app/services/Graph/nodes/tools/evaluator.py`
- [Answer and Escalation](https://github.com/anshmahajan-grep/customer_support_agent/tree/main/Backend/app/services/Graph/nodes): `Backend/app/services/Graph/nodes`

### Knowledge Retrieval

- [Knowledge Ingestion](https://github.com/anshmahajan-grep/customer_support_agent/blob/main/Backend/app/services/Admin/admin_service.py): `Backend/app/services/Admin/admin_service.py`
- [Service Knowledge](https://github.com/anshmahajan-grep/customer_support_agent/blob/main/Backend/app/services/DataBases/Qdrant/service_files.py): `Backend/app/services/DataBases/Qdrant/service_files.py`
- [Answered Queries](https://github.com/anshmahajan-grep/customer_support_agent/blob/main/Backend/app/services/DataBases/Qdrant/answered_collection.py): `Backend/app/services/DataBases/Qdrant/answered_collection.py`
- [Unanswered Queries](https://github.com/anshmahajan-grep/customer_support_agent/blob/main/Backend/app/services/DataBases/Qdrant/unanswered_collection.py): `Backend/app/services/DataBases/Qdrant/unanswered_collection.py`

### Persistence and Operations

- [Supabase Service](https://github.com/anshmahajan-grep/customer_support_agent/blob/main/Backend/app/services/DataBases/Supabase/supabase_service.py): `Backend/app/services/DataBases/Supabase/supabase_service.py`
- **Supabase**
- [Admin Models](https://github.com/anshmahajan-grep/customer_support_agent/blob/main/Backend/app/models/admin.py): `Backend/app/models/admin.py`
- [Chunk Models](https://github.com/anshmahajan-grep/customer_support_agent/blob/main/Backend/app/models/chunking.py): `Backend/app/models/chunking.py`
- [Graph State Models](https://github.com/anshmahajan-grep/customer_support_agent/blob/main/Backend/app/models/graph.py): `Backend/app/models/graph.py`
- [Data Models](https://github.com/anshmahajan-grep/customer_support_agent/blob/main/Backend/app/models/supabase.py): `Backend/app/models/supabase.py`

### Other components

- **Customer**
- **Admin**
- **OpenAI**
- **DeepEval**

## Connections

- Customer → Chat UI: asks questions
- Chat UI → REST Routes: submits via REST
- REST Routes → Chat Service: handles chat
- Chat Service → Supabase Service: creates records (evidence: `Backend/app/services/Chatbox/chatbox_service.py`)
- Chat Service → Query Processor: schedules processing (evidence: `Backend/app/services/Chatbox/chatbox_service.py`)
- Query Processor → LangGraph Workflow: invokes workflow (evidence: `Backend/app/services/Graph/graph_service.py`)
- LangGraph Workflow → Conversation Memory: builds context
- LangGraph Workflow → Query Rewrite: rewrites query
- Query Rewrite → Supabase Service: updates rewrite (evidence: `Backend/app/services/Graph/nodes/transform_query.py`)
- Query Rewrite → Unanswered Queries: stores query (evidence: `Backend/app/services/Graph/nodes/transform_query.py`)
- LangGraph Workflow → RAG Agent: retrieves and reasons
- RAG Agent → Service Knowledge: searches knowledge
- RAG Agent → Answered Queries: searches resolved cases
- RAG Agent → Answer Evaluation: scores candidate
- Answer Evaluation → DeepEval: evaluates quality
- LangGraph Workflow → Answer and Escalation: routes outcome
- Answer and Escalation → Supabase Service: persists status (evidence: `Backend/app/services/Graph/nodes/transform_query.py`)
- Admin → Admin Dashboard: reviews operations
- Admin → Escalation Queue: resolves cases
- Admin Dashboard → REST Routes: requests analytics
- Escalation Queue → REST Routes: requests queue
- REST Routes → Admin Service: handles admin actions
- Admin Service → Supabase: reads analytics (evidence: `Backend/app/services/Admin/admin_service.py`)
- Admin Service → Service Knowledge: uploads chunks (evidence: `Backend/app/services/Admin/admin_service.py`)
- Admin Service → Unanswered Queries: reprocesses pool
- Admin Service → Admin Models: returns typed results (evidence: `Backend/app/services/Admin/admin_service.py`)
- Knowledge Ingestion → Chunk Models: creates chunks
- Service Knowledge → OpenAI: embeds text (evidence: `Backend/app/services/DataBases/Qdrant/service_files.py`)
- Live Thread → Chat UI: supplies thread state (evidence: `Frontend/lib/supabase/useSessionThread.ts`)
- Thread View → Chat UI: renders messages (evidence: `Frontend/components/thread/QueryThread.tsx`)
- Live Thread → Supabase: subscribes to updates (evidence: `Frontend/lib/supabase/useSessionThread.ts`)
- Live Thread → REST Routes: polls fallback
- Supabase Service → Supabase: reads and writes (evidence: `Backend/app/services/DataBases/Supabase/supabase_service.py`)
- Supabase Service → Data Models: uses data models (evidence: `Backend/app/services/DataBases/Supabase/supabase_service.py`)
- Query Processor → Graph State Models: constructs workflow state (evidence: `Backend/app/services/Graph/graph_service.py`)
