# ejathinreddy/customer-support-agent architecture

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

- Interactive diagram: https://gitdiagram.com/ejathinreddy/customer-support-agent
- Repository: https://github.com/ejathinreddy/customer-support-agent

## Overview

Fieldmark is an embedded AI support chatbot for a fictional field-service SaaS company. A visitor chats through the JavaScript widget; the Flask backend classifies the request, retrieves relevant knowledge, and uses an LLM to formulate a response or handle escalation. Escalations can capture contact details, persist records, and notify support by email. The README documents Anthropic support and the embedded demo site; some of those implementation details are not sampled, so their links are documented rather than inferred from unseen code.

Main entry points: [`widget/widget.js`](https://github.com/ejathinreddy/customer-support-agent/blob/main/widget/widget.js) (Chat widget), [`backend/app.py`](https://github.com/ejathinreddy/customer-support-agent/blob/main/backend/app.py) (Flask chat API), [`backend/llm.py`](https://github.com/ejathinreddy/customer-support-agent/blob/main/backend/llm.py) (LLM adapter), [`demo-site/index.html`](https://github.com/ejathinreddy/customer-support-agent/blob/main/demo-site/index.html) (Demo website)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["Chat experience"]
  node_demo["Demo website<br/>[index.html]"]
  node_widget["Chat widget<br/>[widget.js]"]
  node_widget_style["Widget styling<br/>[widget.css]"]
end

subgraph group_support["Support workflow"]
  node_chat_api["Flask chat API<br/>[app.py]"]
  node_intent["Intent classifier<br/>[classifier.py]"]
  node_response["Answer orchestration<br/>[app.py]"]
  node_llm["LLM adapter<br/>[llm.py]"]
  node_escalation_form["Contact capture<br/>[widget.js]"]
  node_escalation_api["Escalation handler<br/>[app.py]"]
  node_escalation_store[("Escalation records<br/>[escalations.json]")]
end

subgraph group_knowledge["Knowledge retrieval"]
  node_retriever["PDF retrieval<br/>[retrieval.py]"]
  node_knowledge_pdfs["Support knowledge PDFs"]
end

subgraph group_integrations["External services"]
  node_groq{{"Groq API"}}
  node_anthropic{{"Anthropic API"}}
  node_smtp{{"SMTP email service"}}
end

node_visitor(("Site visitor"))
node_support_agent(("Support agent"))

node_visitor -->|"visits"| node_demo
node_demo -->|"embeds"| node_widget
node_visitor -->|"chats"| node_widget
node_widget -->|"loads styles"| node_widget_style
node_widget -->|"posts messages"| node_chat_api
node_chat_api -->|"classifies intent"| node_intent
node_chat_api -->|"retrieves context"| node_retriever
node_chat_api -->|"routes chat"| node_response
node_response -->|"requests completion"| node_llm
node_retriever -->|"reads PDFs"| node_knowledge_pdfs
node_llm -->|"calls provider"| node_groq
node_llm -->|"calls provider"| node_anthropic
node_chat_api -.->|"returns answer"| node_widget
node_widget -->|"offers handoff"| node_escalation_form
node_escalation_form -->|"submits details"| node_escalation_api
node_escalation_api -.->|"stores record"| node_escalation_store
node_escalation_api -.->|"sends notification"| node_smtp
node_smtp -.->|"emails"| node_support_agent

click node_demo "https://github.com/ejathinreddy/customer-support-agent/blob/main/demo-site/index.html"
click node_widget "https://github.com/ejathinreddy/customer-support-agent/blob/main/widget/widget.js"
click node_widget_style "https://github.com/ejathinreddy/customer-support-agent/blob/main/widget/widget.css"
click node_chat_api "https://github.com/ejathinreddy/customer-support-agent/blob/main/backend/app.py"
click node_intent "https://github.com/ejathinreddy/customer-support-agent/blob/main/backend/classifier.py"
click node_response "https://github.com/ejathinreddy/customer-support-agent/blob/main/backend/app.py"
click node_llm "https://github.com/ejathinreddy/customer-support-agent/blob/main/backend/llm.py"
click node_escalation_form "https://github.com/ejathinreddy/customer-support-agent/blob/main/widget/widget.js"
click node_escalation_api "https://github.com/ejathinreddy/customer-support-agent/blob/main/backend/app.py"
click node_escalation_store "https://github.com/ejathinreddy/customer-support-agent/blob/main/backend/escalations.json"
click node_retriever "https://github.com/ejathinreddy/customer-support-agent/blob/main/backend/retrieval.py"
click node_knowledge_pdfs "https://github.com/ejathinreddy/customer-support-agent/tree/main/backend/knowledge_base"

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_demo,node_widget,node_widget_style toneBlue
class node_chat_api,node_intent,node_response,node_llm,node_escalation_form,node_escalation_api,node_escalation_store toneAmber
class node_retriever,node_knowledge_pdfs toneMint
class node_groq,node_anthropic,node_smtp toneRose
class node_visitor,node_support_agent toneIndigo
```

## Components

### Chat experience

- [Demo website](https://github.com/ejathinreddy/customer-support-agent/blob/main/demo-site/index.html): `demo-site/index.html`
- [Chat widget](https://github.com/ejathinreddy/customer-support-agent/blob/main/widget/widget.js): `widget/widget.js`
- [Widget styling](https://github.com/ejathinreddy/customer-support-agent/blob/main/widget/widget.css): `widget/widget.css`

### Support workflow

- [Flask chat API](https://github.com/ejathinreddy/customer-support-agent/blob/main/backend/app.py): `backend/app.py`
- [Intent classifier](https://github.com/ejathinreddy/customer-support-agent/blob/main/backend/classifier.py): `backend/classifier.py`
- [Answer orchestration](https://github.com/ejathinreddy/customer-support-agent/blob/main/backend/app.py): `backend/app.py`
- [LLM adapter](https://github.com/ejathinreddy/customer-support-agent/blob/main/backend/llm.py): `backend/llm.py`
- [Contact capture](https://github.com/ejathinreddy/customer-support-agent/blob/main/widget/widget.js): `widget/widget.js`
- [Escalation handler](https://github.com/ejathinreddy/customer-support-agent/blob/main/backend/app.py): `backend/app.py`
- [Escalation records](https://github.com/ejathinreddy/customer-support-agent/blob/main/backend/escalations.json): `backend/escalations.json`

### Knowledge retrieval

- [PDF retrieval](https://github.com/ejathinreddy/customer-support-agent/blob/main/backend/retrieval.py): `backend/retrieval.py`
- [Support knowledge PDFs](https://github.com/ejathinreddy/customer-support-agent/tree/main/backend/knowledge_base): `backend/knowledge_base`

### External services

- **Groq API**
- **Anthropic API**
- **SMTP email service**

### Other components

- **Site visitor**
- **Support agent**

## Connections

- Site visitor → Demo website: visits (evidence: `README.md`)
- Demo website → Chat widget: embeds (evidence: `README.md`)
- Site visitor → Chat widget: chats (evidence: `widget/widget.js`)
- Chat widget → Widget styling: loads styles (evidence: `widget/widget.js`)
- Chat widget → Flask chat API: posts messages (evidence: `widget/widget.js`)
- Flask chat API → Intent classifier: classifies intent (evidence: `backend/app.py`)
- Flask chat API → PDF retrieval: retrieves context (evidence: `backend/app.py`)
- Flask chat API → Answer orchestration: routes chat (evidence: `backend/app.py`)
- Answer orchestration → LLM adapter: requests completion (evidence: `backend/app.py`)
- PDF retrieval → Support knowledge PDFs: reads PDFs (evidence: `backend/retrieval.py`)
- LLM adapter → Groq API: calls provider (evidence: `backend/llm.py`)
- LLM adapter → Anthropic API: calls provider (evidence: `backend/llm.py`)
- Flask chat API → Chat widget: returns answer (evidence: `README.md`)
- Chat widget → Contact capture: offers handoff (evidence: `widget/widget.js`)
- Contact capture → Escalation handler: submits details (evidence: `widget/widget.js`)
- Escalation handler → Escalation records: stores record (evidence: `README.md`)
- Escalation handler → SMTP email service: sends notification (evidence: `README.md`)
- SMTP email service → Support agent: emails (evidence: `README.md`)
