# awais-p/assistdesk-ai architecture

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

- Interactive diagram: https://gitdiagram.com/awais-p/assistdesk-ai
- Repository: https://github.com/awais-p/assistdesk-ai

## Overview

Assistdesk is a customer-support and engagement platform: workspace staff configure chatbots, AI agents, knowledge sources and channels, while customers contact support through the widget or email; incoming work becomes tickets that staff handle in the dashboard. The implementation also includes lead management, appointments, analytics, notifications and outgoing webhooks. The graph follows only relationships shown in sampled excerpts or the SOURCE INDEX; many listed capabilities have no sampled call path, so their internal links are intentionally omitted.

Main entry points: [`src/lib/prisma.ts`](https://github.com/awais-p/assistdesk-ai/blob/main/src/lib/prisma.ts) (Application database), [`src/lib/ticket-workflow.ts`](https://github.com/awais-p/assistdesk-ai/blob/main/src/lib/ticket-workflow.ts) (Ticket workflow), [`src/lib/notifications.ts`](https://github.com/awais-p/assistdesk-ai/blob/main/src/lib/notifications.ts) (Notifications), [`src/lib/email-ingestion.ts`](https://github.com/awais-p/assistdesk-ai/blob/main/src/lib/email-ingestion.ts) (Email ingestion)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["User surfaces"]
  node_dashboard["Staff dashboard<br/>[page.tsx]"]
  node_ticketui["Ticket workspace<br/>[tickets-client.tsx]"]
  node_widgetui["Chat widget"]
end

subgraph group_support["Support operations"]
  node_ticketapi["Ticket endpoints<br/>[route.ts]"]
  node_ticketflow["Ticket workflow<br/>[ticket-workflow.ts]"]
  node_emailingest["Email ingestion<br/>[email-ingestion.ts]"]
  node_contacts["Contact management<br/>[contacts.ts]"]
  node_analytics["Analytics<br/>[route.ts]"]
end

subgraph group_automation["AI and knowledge"]
  node_agentapi["Agent configuration<br/>[route.ts]"]
  node_agentengine["Agent runtime<br/>[run-agent.ts]"]
  node_knowledgeapi["Knowledge sources<br/>[route.ts]"]
  node_knowledgeindex["Knowledge indexing"]
end

subgraph group_channels["Channels and engagement"]
  node_chatbotapi["Chatbot configuration<br/>[route.ts]"]
  node_widgetapi["Widget attachments<br/>[route.ts]"]
  node_integrationsapi["Integration setup<br/>[route.ts]"]
  node_leadsapi["Lead management<br/>[route.ts]"]
  node_appointments["Appointments<br/>[route.ts]"]
end

subgraph group_platform["Workspace platform"]
  node_auth["Authentication<br/>[auth.ts]"]
  node_notifications["Notifications<br/>[notifications.ts]"]
  node_database[("Application database<br/>[prisma.ts]")]
end

node_staff(("Support staff"))
node_customer(("Customer"))

node_staff -->|"uses"| node_dashboard
node_staff -->|"handles tickets"| node_ticketui
node_customer -->|"contacts support"| node_widgetui
node_ticketapi -->|"processes tickets"| node_ticketflow
node_emailingest -->|"resolves contact"| node_contacts
node_emailingest -->|"processes incoming work"| node_ticketflow
node_ticketflow -->|"runs agent"| node_agentengine
node_ticketflow -->|"raises alerts"| node_notifications
node_ticketflow -->|"reads and writes"| node_database
node_agentapi -->|"stores configuration"| node_database
node_knowledgeapi -->|"queues processing"| node_knowledgeindex
node_knowledgeapi -->|"stores sources"| node_database
node_chatbotapi -->|"stores configuration"| node_database
node_widgetui -->|"uploads attachments"| node_widgetapi
node_integrationsapi -->|"raises alerts"| node_notifications
node_integrationsapi -->|"stores integrations"| node_database
node_leadsapi -->|"reads and writes"| node_database
node_appointments -->|"reads and writes"| node_database
node_analytics -.->|"queries data"| node_database
node_auth -->|"stores sessions"| node_database
node_ticketui -.->|"loads tickets"| node_ticketapi
node_dashboard -->|"loads alerts"| node_notifications

click node_dashboard "https://github.com/awais-p/assistdesk-ai/blob/main/app/dashboard/page.tsx"
click node_ticketui "https://github.com/awais-p/assistdesk-ai/blob/main/src/components/dashboard/tickets-client.tsx"
click node_widgetui "https://github.com/awais-p/assistdesk-ai/blob/main/src/components/widget/chatbot-widget-client.tsx"
click node_ticketapi "https://github.com/awais-p/assistdesk-ai/blob/main/app/api/tickets/route.ts"
click node_ticketflow "https://github.com/awais-p/assistdesk-ai/blob/main/src/lib/ticket-workflow.ts"
click node_emailingest "https://github.com/awais-p/assistdesk-ai/blob/main/src/lib/email-ingestion.ts"
click node_contacts "https://github.com/awais-p/assistdesk-ai/blob/main/src/lib/contacts.ts"
click node_agentapi "https://github.com/awais-p/assistdesk-ai/blob/main/app/api/ai-agents/route.ts"
click node_agentengine "https://github.com/awais-p/assistdesk-ai/blob/main/src/lib/agent-engine/run-agent.ts"
click node_knowledgeapi "https://github.com/awais-p/assistdesk-ai/blob/main/app/api/knowledge-sources/route.ts"
click node_knowledgeindex "https://github.com/awais-p/assistdesk-ai/blob/main/src/lib/knowledge-indexing.ts"
click node_chatbotapi "https://github.com/awais-p/assistdesk-ai/blob/main/app/api/chatbots/route.ts"
click node_widgetapi "https://github.com/awais-p/assistdesk-ai/blob/main/app/api/widget/%5BwidgetId%5D/attachments/route.ts"
click node_integrationsapi "https://github.com/awais-p/assistdesk-ai/blob/main/app/api/integrations/route.ts"
click node_leadsapi "https://github.com/awais-p/assistdesk-ai/blob/main/app/api/leads/route.ts"
click node_appointments "https://github.com/awais-p/assistdesk-ai/blob/main/app/api/appointments/route.ts"
click node_analytics "https://github.com/awais-p/assistdesk-ai/blob/main/app/api/analytics/route.ts"
click node_auth "https://github.com/awais-p/assistdesk-ai/blob/main/src/lib/auth.ts"
click node_notifications "https://github.com/awais-p/assistdesk-ai/blob/main/src/lib/notifications.ts"
click node_database "https://github.com/awais-p/assistdesk-ai/blob/main/src/lib/prisma.ts"

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_dashboard,node_ticketui,node_widgetui toneBlue
class node_ticketapi,node_ticketflow,node_emailingest,node_contacts,node_analytics toneAmber
class node_agentapi,node_agentengine,node_knowledgeapi,node_knowledgeindex toneMint
class node_chatbotapi,node_widgetapi,node_integrationsapi,node_leadsapi,node_appointments toneRose
class node_auth,node_notifications,node_database,node_staff,node_customer toneIndigo
```

## Components

### User surfaces

- [Staff dashboard](https://github.com/awais-p/assistdesk-ai/blob/main/app/dashboard/page.tsx): `app/dashboard/page.tsx`
- [Ticket workspace](https://github.com/awais-p/assistdesk-ai/blob/main/src/components/dashboard/tickets-client.tsx): `src/components/dashboard/tickets-client.tsx`
- [Chat widget](https://github.com/awais-p/assistdesk-ai/blob/main/src/components/widget/chatbot-widget-client.tsx): `src/components/widget/chatbot-widget-client.tsx`

### Support operations

- [Ticket endpoints](https://github.com/awais-p/assistdesk-ai/blob/main/app/api/tickets/route.ts): `app/api/tickets/route.ts`
- [Ticket workflow](https://github.com/awais-p/assistdesk-ai/blob/main/src/lib/ticket-workflow.ts): `src/lib/ticket-workflow.ts`
- [Email ingestion](https://github.com/awais-p/assistdesk-ai/blob/main/src/lib/email-ingestion.ts): `src/lib/email-ingestion.ts`
- [Contact management](https://github.com/awais-p/assistdesk-ai/blob/main/src/lib/contacts.ts): `src/lib/contacts.ts`
- [Analytics](https://github.com/awais-p/assistdesk-ai/blob/main/app/api/analytics/route.ts): `app/api/analytics/route.ts`

### AI and knowledge

- [Agent configuration](https://github.com/awais-p/assistdesk-ai/blob/main/app/api/ai-agents/route.ts): `app/api/ai-agents/route.ts`
- [Agent runtime](https://github.com/awais-p/assistdesk-ai/blob/main/src/lib/agent-engine/run-agent.ts): `src/lib/agent-engine/run-agent.ts`
- [Knowledge sources](https://github.com/awais-p/assistdesk-ai/blob/main/app/api/knowledge-sources/route.ts): `app/api/knowledge-sources/route.ts`
- [Knowledge indexing](https://github.com/awais-p/assistdesk-ai/blob/main/src/lib/knowledge-indexing.ts): `src/lib/knowledge-indexing.ts`

### Channels and engagement

- [Chatbot configuration](https://github.com/awais-p/assistdesk-ai/blob/main/app/api/chatbots/route.ts): `app/api/chatbots/route.ts`
- [Widget attachments](https://github.com/awais-p/assistdesk-ai/blob/main/app/api/widget/%5BwidgetId%5D/attachments/route.ts): `app/api/widget/[widgetId]/attachments/route.ts`
- [Integration setup](https://github.com/awais-p/assistdesk-ai/blob/main/app/api/integrations/route.ts): `app/api/integrations/route.ts`
- [Lead management](https://github.com/awais-p/assistdesk-ai/blob/main/app/api/leads/route.ts): `app/api/leads/route.ts`
- [Appointments](https://github.com/awais-p/assistdesk-ai/blob/main/app/api/appointments/route.ts): `app/api/appointments/route.ts`

### Workspace platform

- [Authentication](https://github.com/awais-p/assistdesk-ai/blob/main/src/lib/auth.ts): `src/lib/auth.ts`
- [Notifications](https://github.com/awais-p/assistdesk-ai/blob/main/src/lib/notifications.ts): `src/lib/notifications.ts`
- [Application database](https://github.com/awais-p/assistdesk-ai/blob/main/src/lib/prisma.ts): `src/lib/prisma.ts`

### Other components

- **Support staff**
- **Customer**

## Connections

- Support staff → Staff dashboard: uses (evidence: `app/dashboard/page.tsx`)
- Support staff → Ticket workspace: handles tickets
- Customer → Chat widget: contacts support
- Ticket endpoints → Ticket workflow: processes tickets (evidence: `app/api/tickets/route.ts`)
- Email ingestion → Contact management: resolves contact (evidence: `src/lib/email-ingestion.ts`)
- Email ingestion → Ticket workflow: processes incoming work (evidence: `src/lib/email-ingestion.ts`)
- Ticket workflow → Agent runtime: runs agent (evidence: `src/lib/ticket-workflow.ts`)
- Ticket workflow → Notifications: raises alerts (evidence: `src/lib/ticket-workflow.ts`)
- Ticket workflow → Application database: reads and writes (evidence: `src/lib/ticket-workflow.ts`)
- Agent configuration → Application database: stores configuration (evidence: `app/api/ai-agents/route.ts`)
- Knowledge sources → Knowledge indexing: queues processing (evidence: `app/api/knowledge-sources/route.ts`)
- Knowledge sources → Application database: stores sources (evidence: `app/api/knowledge-sources/route.ts`)
- Chatbot configuration → Application database: stores configuration (evidence: `app/api/chatbots/route.ts`)
- Chat widget → Widget attachments: uploads attachments (evidence: `src/components/widget/chatbot-widget-client.tsx`)
- Integration setup → Notifications: raises alerts (evidence: `app/api/integrations/route.ts`)
- Integration setup → Application database: stores integrations (evidence: `app/api/integrations/route.ts`)
- Lead management → Application database: reads and writes (evidence: `app/api/leads/route.ts`)
- Appointments → Application database: reads and writes (evidence: `app/api/appointments/route.ts`)
- Analytics → Application database: queries data
- Authentication → Application database: stores sessions (evidence: `src/lib/auth.ts`)
- Ticket workspace → Ticket endpoints: loads tickets
- Staff dashboard → Notifications: loads alerts (evidence: `app/dashboard/page.tsx`)
