# tahaishfaq/ai-customer-support-agent architecture

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

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

## Overview

Aide is a hosted AI customer-support and customer-insights product. The main workflow is an operator authenticating, creating an agent, adding knowledge, configuring and embedding its webchat, then reviewing conversations and analytics; customers chat through the public widget and can be handed off to the human desk. The graph also preserves billing, agent actions, realtime updates, and platform administration. Relationships are limited to README-documented capabilities and SOURCE INDEX references; several route-to-service details were not sampled and are therefore not asserted.

Main entry points: [`app/(app)/agents/[id]/page.jsx`](https://github.com/tahaishfaq/ai-customer-support-agent/blob/main/app/(app)/agents/%5Bid%5D/page.jsx) (Agent console), [`lib/prisma.js`](https://github.com/tahaishfaq/ai-customer-support-agent/blob/main/lib/prisma.js) (Application database), [`lib/require-product.js`](https://github.com/tahaishfaq/ai-customer-support-agent/blob/main/lib/require-product.js) (Access control), [`lib/orchestrator/loop.js`](https://github.com/tahaishfaq/ai-customer-support-agent/blob/main/lib/orchestrator/loop.js) (Agent orchestration)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_product["Agent product"]
  node_agent_console["Agent console<br/>[page.jsx]"]
  node_agent_api["Agent management API<br/>[route.js]"]
  node_agent_service["Agent service<br/>[agent.service.js]"]
  node_knowledge["Knowledge management<br/>[route.js]"]
  node_customization["Widget customization"]
  node_actions["Agent actions<br/>[action-config.js]"]
  node_orchestrator["Agent orchestration<br/>[loop.js]"]
  node_source_policy["Knowledge retrieval policy<br/>[source-policy.js]"]
end

subgraph group_chat["Chat and desk"]
  node_embed["Embedded webchat<br/>[page.jsx]"]
  node_public_chat_api["Public chat API<br/>[route.js]"]
  node_chat_service["Chat service<br/>[chat.service.js]"]
  node_conversations["Conversation management<br/>[route.js]"]
  node_human_desk["Human support desk<br/>[InboxShell.jsx]"]
  node_analytics["Customer insights<br/>[route.js]"]
end

subgraph group_platform["Platform services"]
  node_auth["Authentication<br/>[auth.js]"]
  node_auth_guard["Access control<br/>[require-product.js]"]
  node_workspace["Workspace management"]
  node_database[("Application database<br/>[prisma.js]")]
  node_realtime["Realtime gateway<br/>[attach.js]"]
end

subgraph group_billing["Billing"]
  node_subscription["Subscription service"]
  node_entitlements["Product entitlements"]
end

subgraph group_admin["Administration"]
  node_admin_console["Admin console<br/>[page.jsx]"]
  node_platform_settings["Platform settings"]
end

node_operator(("Support operator"))
node_customer(("Web customer"))

node_operator -->|"signs in"| node_auth
node_operator -->|"builds agent"| node_agent_console
node_agent_console -->|"manages agents"| node_agent_api
node_agent_api -->|"calls service"| node_agent_service
node_agent_console -->|"adds knowledge"| node_knowledge
node_agent_console -->|"configures widget"| node_customization
node_agent_console -->|"configures tools"| node_actions
node_embed -->|"serves widget"| node_customer
node_customer -->|"sends messages"| node_public_chat_api
node_operator -->|"reviews chats"| node_conversations
node_operator -->|"handles handoff"| node_human_desk
node_operator -->|"reads insights"| node_analytics
node_auth_guard -->|"checks session"| node_auth
node_auth_guard -->|"checks subscription"| node_subscription
node_auth_guard -->|"checks entitlements"| node_entitlements
node_workspace -->|"reads and writes"| node_database
node_agent_service -.->|"reads and writes"| node_database
node_chat_service -.->|"runs agent"| node_orchestrator
node_orchestrator -->|"applies policy"| node_source_policy
node_orchestrator -->|"uses action config"| node_actions
node_subscription -->|"reads and writes"| node_database
node_subscription -.->|"supplies access state"| node_entitlements
node_operator -->|"administers platform"| node_admin_console
node_admin_console -.->|"manages settings"| node_platform_settings
node_realtime -.->|"session checks"| node_database

click node_agent_console "https://github.com/tahaishfaq/ai-customer-support-agent/blob/main/app/(app)/agents/%5Bid%5D/page.jsx"
click node_agent_api "https://github.com/tahaishfaq/ai-customer-support-agent/blob/main/app/api/agents/route.js"
click node_agent_service "https://github.com/tahaishfaq/ai-customer-support-agent/blob/main/lib/services/agent.service.js"
click node_knowledge "https://github.com/tahaishfaq/ai-customer-support-agent/blob/main/app/api/agents/%5Bid%5D/knowledge/route.js"
click node_customization "https://github.com/tahaishfaq/ai-customer-support-agent/blob/main/components/customization/CustomizationStudio.jsx"
click node_actions "https://github.com/tahaishfaq/ai-customer-support-agent/blob/main/lib/actions/action-config.js"
click node_orchestrator "https://github.com/tahaishfaq/ai-customer-support-agent/blob/main/lib/orchestrator/loop.js"
click node_source_policy "https://github.com/tahaishfaq/ai-customer-support-agent/blob/main/lib/services/ai/source-policy.js"
click node_embed "https://github.com/tahaishfaq/ai-customer-support-agent/blob/main/app/w/%5BpublicKey%5D/page.jsx"
click node_public_chat_api "https://github.com/tahaishfaq/ai-customer-support-agent/blob/main/app/api/public/agents/%5BpublicKey%5D/chat/route.js"
click node_chat_service "https://github.com/tahaishfaq/ai-customer-support-agent/blob/main/lib/services/chat.service.js"
click node_conversations "https://github.com/tahaishfaq/ai-customer-support-agent/blob/main/app/api/conversations/route.js"
click node_human_desk "https://github.com/tahaishfaq/ai-customer-support-agent/blob/main/components/desk/InboxShell.jsx"
click node_analytics "https://github.com/tahaishfaq/ai-customer-support-agent/blob/main/app/api/analytics/overview/route.js"
click node_auth "https://github.com/tahaishfaq/ai-customer-support-agent/blob/main/auth.js"
click node_auth_guard "https://github.com/tahaishfaq/ai-customer-support-agent/blob/main/lib/require-product.js"
click node_workspace "https://github.com/tahaishfaq/ai-customer-support-agent/blob/main/lib/services/workspace.service.js"
click node_database "https://github.com/tahaishfaq/ai-customer-support-agent/blob/main/lib/prisma.js"
click node_realtime "https://github.com/tahaishfaq/ai-customer-support-agent/blob/main/realtime-gateway/attach.js"
click node_subscription "https://github.com/tahaishfaq/ai-customer-support-agent/blob/main/lib/billing/subscription.service.js"
click node_entitlements "https://github.com/tahaishfaq/ai-customer-support-agent/blob/main/lib/billing/entitlements.service.js"
click node_admin_console "https://github.com/tahaishfaq/ai-customer-support-agent/blob/main/app/admin/(console)/page.jsx"
click node_platform_settings "https://github.com/tahaishfaq/ai-customer-support-agent/blob/main/lib/services/platform-settings.service.js"

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_agent_console,node_agent_api,node_agent_service,node_knowledge,node_customization,node_actions,node_orchestrator,node_source_policy toneBlue
class node_embed,node_public_chat_api,node_chat_service,node_conversations,node_human_desk,node_analytics toneAmber
class node_auth,node_auth_guard,node_workspace,node_database,node_realtime toneMint
class node_subscription,node_entitlements toneRose
class node_admin_console,node_platform_settings,node_operator,node_customer toneIndigo
```

## Components

### Agent product

- [Agent console](https://github.com/tahaishfaq/ai-customer-support-agent/blob/main/app/(app)/agents/%5Bid%5D/page.jsx): `app/(app)/agents/[id]/page.jsx`
- [Agent management API](https://github.com/tahaishfaq/ai-customer-support-agent/blob/main/app/api/agents/route.js): `app/api/agents/route.js`
- [Agent service](https://github.com/tahaishfaq/ai-customer-support-agent/blob/main/lib/services/agent.service.js): `lib/services/agent.service.js`
- [Knowledge management](https://github.com/tahaishfaq/ai-customer-support-agent/blob/main/app/api/agents/%5Bid%5D/knowledge/route.js): `app/api/agents/[id]/knowledge/route.js`
- [Widget customization](https://github.com/tahaishfaq/ai-customer-support-agent/blob/main/components/customization/CustomizationStudio.jsx): `components/customization/CustomizationStudio.jsx`
- [Agent actions](https://github.com/tahaishfaq/ai-customer-support-agent/blob/main/lib/actions/action-config.js): `lib/actions/action-config.js`
- [Agent orchestration](https://github.com/tahaishfaq/ai-customer-support-agent/blob/main/lib/orchestrator/loop.js): `lib/orchestrator/loop.js`
- [Knowledge retrieval policy](https://github.com/tahaishfaq/ai-customer-support-agent/blob/main/lib/services/ai/source-policy.js): `lib/services/ai/source-policy.js`

### Chat and desk

- [Embedded webchat](https://github.com/tahaishfaq/ai-customer-support-agent/blob/main/app/w/%5BpublicKey%5D/page.jsx): `app/w/[publicKey]/page.jsx`
- [Public chat API](https://github.com/tahaishfaq/ai-customer-support-agent/blob/main/app/api/public/agents/%5BpublicKey%5D/chat/route.js): `app/api/public/agents/[publicKey]/chat/route.js`
- [Chat service](https://github.com/tahaishfaq/ai-customer-support-agent/blob/main/lib/services/chat.service.js): `lib/services/chat.service.js`
- [Conversation management](https://github.com/tahaishfaq/ai-customer-support-agent/blob/main/app/api/conversations/route.js): `app/api/conversations/route.js`
- [Human support desk](https://github.com/tahaishfaq/ai-customer-support-agent/blob/main/components/desk/InboxShell.jsx): `components/desk/InboxShell.jsx`
- [Customer insights](https://github.com/tahaishfaq/ai-customer-support-agent/blob/main/app/api/analytics/overview/route.js): `app/api/analytics/overview/route.js`

### Platform services

- [Authentication](https://github.com/tahaishfaq/ai-customer-support-agent/blob/main/auth.js): `auth.js`
- [Access control](https://github.com/tahaishfaq/ai-customer-support-agent/blob/main/lib/require-product.js): `lib/require-product.js`
- [Workspace management](https://github.com/tahaishfaq/ai-customer-support-agent/blob/main/lib/services/workspace.service.js): `lib/services/workspace.service.js`
- [Application database](https://github.com/tahaishfaq/ai-customer-support-agent/blob/main/lib/prisma.js): `lib/prisma.js`
- [Realtime gateway](https://github.com/tahaishfaq/ai-customer-support-agent/blob/main/realtime-gateway/attach.js): `realtime-gateway/attach.js`

### Billing

- [Subscription service](https://github.com/tahaishfaq/ai-customer-support-agent/blob/main/lib/billing/subscription.service.js): `lib/billing/subscription.service.js`
- [Product entitlements](https://github.com/tahaishfaq/ai-customer-support-agent/blob/main/lib/billing/entitlements.service.js): `lib/billing/entitlements.service.js`

### Administration

- [Admin console](https://github.com/tahaishfaq/ai-customer-support-agent/blob/main/app/admin/(console)/page.jsx): `app/admin/(console)/page.jsx`
- [Platform settings](https://github.com/tahaishfaq/ai-customer-support-agent/blob/main/lib/services/platform-settings.service.js): `lib/services/platform-settings.service.js`

### Other components

- **Support operator**
- **Web customer**

## Connections

- Support operator → Authentication: signs in
- Support operator → Agent console: builds agent
- Agent console → Agent management API: manages agents
- Agent management API → Agent service: calls service (evidence: `app/api/agents/route.js`)
- Agent console → Knowledge management: adds knowledge
- Agent console → Widget customization: configures widget
- Agent console → Agent actions: configures tools
- Embedded webchat → Web customer: serves widget
- Web customer → Public chat API: sends messages
- Support operator → Conversation management: reviews chats
- Support operator → Human support desk: handles handoff
- Support operator → Customer insights: reads insights
- Access control → Authentication: checks session
- Access control → Subscription service: checks subscription (evidence: `lib/require-product.js`)
- Access control → Product entitlements: checks entitlements (evidence: `lib/require-product.js`)
- Workspace management → Application database: reads and writes (evidence: `lib/services/workspace.service.js`)
- Agent service → Application database: reads and writes
- Chat service → Agent orchestration: runs agent
- Agent orchestration → Knowledge retrieval policy: applies policy (evidence: `lib/orchestrator/index.js`)
- Agent orchestration → Agent actions: uses action config (evidence: `lib/orchestrator/index.js`)
- Subscription service → Application database: reads and writes (evidence: `lib/billing/subscription.service.js`)
- Subscription service → Product entitlements: supplies access state
- Support operator → Admin console: administers platform
- Admin console → Platform settings: manages settings
- Realtime gateway → Application database: session checks
