# cloudfarmenterprisesinfo-max/avirochat architecture

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

- Interactive diagram: https://gitdiagram.com/cloudfarmenterprisesinfo-max/avirochat
- Repository: https://github.com/cloudfarmenterprisesinfo-max/avirochat

## Overview

AviroChat is a multi-tenant WhatsApp sales, support, and marketing platform. Operators sign in to a workspace, manage leads and conversations, and use campaign, automation, catalog, and order tools; inbound WhatsApp messages are routed through a webhook into tenant-scoped lead and chat records. The dashboard page explicitly renders the feature views, while sampled API routes use Prisma for persistence. The README documents additional Meta and AI capabilities, but unsampled UI-to-API wiring and some integrations cannot be verified from the excerpts.

Main entry points: [`src/app/page.tsx`](https://github.com/cloudfarmenterprisesinfo-max/avirochat/blob/main/src/app/page.tsx) (Dashboard shell), [`src/lib/prisma.ts`](https://github.com/cloudfarmenterprisesinfo-max/avirochat/blob/main/src/lib/prisma.ts) (Prisma client), [`src/app/api/whatsapp/webhook/route.ts`](https://github.com/cloudfarmenterprisesinfo-max/avirochat/blob/main/src/app/api/whatsapp/webhook/route.ts) (WhatsApp webhook), [`src/components/MetaEmbeddedSignupButton.tsx`](https://github.com/cloudfarmenterprisesinfo-max/avirochat/blob/main/src/components/MetaEmbeddedSignupButton.tsx) (Meta signup)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_dashboard["Workspace Dashboard"]
  node_dashboard_page["Dashboard shell<br/>[page.tsx]"]
  node_login["Login view<br/>[LoginPage.tsx]"]
  node_clients["Client workspaces<br/>[ClientManager.tsx]"]
  node_workspace_switcher["Workspace switcher<br/>[ClientSwitcher.tsx]"]
  node_users_view["User management<br/>[UserManagement.tsx]"]
  node_overview["Dashboard overview"]
  node_settings_view["Workspace settings<br/>[SettingsView.tsx]"]
  node_meta_signup["Meta signup"]
end

subgraph group_engagement["Messaging and Automation"]
  node_ai_settings["AI agent settings<br/>[AIBotSettings.tsx]"]
  node_automation_builder["Automation flows"]
  node_inbox["Shared chat inbox<br/>[WhatsAppInbox.tsx]"]
  node_widget["Website chat widget"]
  node_campaigns_view["Broadcast manager"]
end

subgraph group_sales["Sales Operations"]
  node_crm["Lead CRM<br/>[LeadCRM.tsx]"]
  node_catalog["Product catalog<br/>[EcommerceCMS.tsx]"]
  node_orders_view["Orders and invoices<br/>[OrderManager.tsx]"]
end

subgraph group_api["Application API"]
  node_lead_api["Leads API<br/>[route.ts]"]
  node_chat_api["Chat API<br/>[route.ts]"]
  node_webhook["WhatsApp webhook<br/>[route.ts]"]
  node_org_api["Organizations API<br/>[route.ts]"]
  node_automation_api["Automations API<br/>[route.ts]"]
  node_template_api["Templates API<br/>[route.ts]"]
  node_campaign_api["Campaigns API<br/>[route.ts]"]
  node_product_api["Products API<br/>[route.ts]"]
  node_orders_api["Orders API<br/>[route.ts]"]
  node_stats_api["Statistics API<br/>[route.ts]"]
end

subgraph group_persistence["Persistence"]
  node_prisma_client["Prisma client<br/>[prisma.ts]"]
  node_database[("Tenant data store")]
end

node_operator(("Workspace operator"))
node_meta["Meta Cloud API"]
node_gemini["Google Gemini"]

node_operator -->|"uses"| node_dashboard_page
node_dashboard_page -->|"renders"| node_login
node_dashboard_page -->|"renders"| node_clients
node_dashboard_page -->|"renders"| node_workspace_switcher
node_dashboard_page -->|"renders"| node_users_view
node_dashboard_page -->|"renders"| node_overview
node_dashboard_page -->|"renders"| node_ai_settings
node_dashboard_page -->|"renders"| node_automation_builder
node_dashboard_page -->|"renders"| node_inbox
node_dashboard_page -->|"renders"| node_widget
node_dashboard_page -->|"renders"| node_campaigns_view
node_dashboard_page -->|"renders"| node_crm
node_dashboard_page -->|"renders"| node_catalog
node_dashboard_page -->|"renders"| node_orders_view
node_dashboard_page -->|"renders"| node_settings_view
node_clients -->|"embeds"| node_meta_signup
node_settings_view -->|"embeds"| node_meta_signup
node_meta -->|"sends events"| node_webhook
node_meta -->|"onboards accounts"| node_meta_signup
node_webhook -->|"updates messages and leads"| node_database
node_chat_api -->|"dispatches messages"| node_meta
node_template_api -->|"syncs templates"| node_meta
node_webhook -->|"queries and writes"| node_prisma_client
node_chat_api -->|"queries and writes"| node_prisma_client
node_lead_api -->|"queries and writes"| node_prisma_client
node_org_api -->|"queries and writes"| node_prisma_client
node_automation_api -->|"queries and writes"| node_prisma_client
node_template_api -->|"queries and writes"| node_prisma_client
node_campaign_api -->|"queries and writes"| node_prisma_client
node_product_api -->|"queries and writes"| node_prisma_client
node_orders_api -->|"queries and writes"| node_prisma_client
node_stats_api -->|"queries"| node_prisma_client
node_prisma_client -.->|"persists data"| node_database
node_gemini -.->|"AI replies"| node_webhook

click node_dashboard_page "https://github.com/cloudfarmenterprisesinfo-max/avirochat/blob/main/src/app/page.tsx"
click node_login "https://github.com/cloudfarmenterprisesinfo-max/avirochat/blob/main/src/components/LoginPage.tsx"
click node_clients "https://github.com/cloudfarmenterprisesinfo-max/avirochat/blob/main/src/components/ClientManager.tsx"
click node_workspace_switcher "https://github.com/cloudfarmenterprisesinfo-max/avirochat/blob/main/src/components/ClientSwitcher.tsx"
click node_users_view "https://github.com/cloudfarmenterprisesinfo-max/avirochat/blob/main/src/components/UserManagement.tsx"
click node_overview "https://github.com/cloudfarmenterprisesinfo-max/avirochat/blob/main/src/components/DashboardOverview.tsx"
click node_ai_settings "https://github.com/cloudfarmenterprisesinfo-max/avirochat/blob/main/src/components/AIBotSettings.tsx"
click node_automation_builder "https://github.com/cloudfarmenterprisesinfo-max/avirochat/blob/main/src/components/AutomationFlowBuilder.tsx"
click node_inbox "https://github.com/cloudfarmenterprisesinfo-max/avirochat/blob/main/src/components/WhatsAppInbox.tsx"
click node_widget "https://github.com/cloudfarmenterprisesinfo-max/avirochat/blob/main/src/components/WhatsAppWidgetGenerator.tsx"
click node_campaigns_view "https://github.com/cloudfarmenterprisesinfo-max/avirochat/blob/main/src/components/CampaignManager.tsx"
click node_crm "https://github.com/cloudfarmenterprisesinfo-max/avirochat/blob/main/src/components/LeadCRM.tsx"
click node_catalog "https://github.com/cloudfarmenterprisesinfo-max/avirochat/blob/main/src/components/EcommerceCMS.tsx"
click node_orders_view "https://github.com/cloudfarmenterprisesinfo-max/avirochat/blob/main/src/components/OrderManager.tsx"
click node_settings_view "https://github.com/cloudfarmenterprisesinfo-max/avirochat/blob/main/src/components/SettingsView.tsx"
click node_meta_signup "https://github.com/cloudfarmenterprisesinfo-max/avirochat/blob/main/src/components/MetaEmbeddedSignupButton.tsx"
click node_lead_api "https://github.com/cloudfarmenterprisesinfo-max/avirochat/blob/main/src/app/api/leads/route.ts"
click node_chat_api "https://github.com/cloudfarmenterprisesinfo-max/avirochat/blob/main/src/app/api/chat/route.ts"
click node_webhook "https://github.com/cloudfarmenterprisesinfo-max/avirochat/blob/main/src/app/api/whatsapp/webhook/route.ts"
click node_org_api "https://github.com/cloudfarmenterprisesinfo-max/avirochat/blob/main/src/app/api/organizations/route.ts"
click node_automation_api "https://github.com/cloudfarmenterprisesinfo-max/avirochat/blob/main/src/app/api/automations/route.ts"
click node_template_api "https://github.com/cloudfarmenterprisesinfo-max/avirochat/blob/main/src/app/api/templates/route.ts"
click node_campaign_api "https://github.com/cloudfarmenterprisesinfo-max/avirochat/blob/main/src/app/api/campaigns/route.ts"
click node_product_api "https://github.com/cloudfarmenterprisesinfo-max/avirochat/blob/main/src/app/api/products/route.ts"
click node_orders_api "https://github.com/cloudfarmenterprisesinfo-max/avirochat/blob/main/src/app/api/orders/route.ts"
click node_stats_api "https://github.com/cloudfarmenterprisesinfo-max/avirochat/blob/main/src/app/api/stats/route.ts"
click node_prisma_client "https://github.com/cloudfarmenterprisesinfo-max/avirochat/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_page,node_login,node_clients,node_workspace_switcher,node_users_view,node_overview,node_settings_view,node_meta_signup toneBlue
class node_ai_settings,node_automation_builder,node_inbox,node_widget,node_campaigns_view toneAmber
class node_crm,node_catalog,node_orders_view,node_meta toneMint
class node_lead_api,node_chat_api,node_webhook,node_org_api,node_automation_api,node_template_api,node_campaign_api,node_product_api,node_orders_api,node_stats_api toneRose
class node_prisma_client,node_database,node_operator,node_gemini toneIndigo
```

## Components

### Workspace Dashboard

- [Dashboard shell](https://github.com/cloudfarmenterprisesinfo-max/avirochat/blob/main/src/app/page.tsx): `src/app/page.tsx`
- [Login view](https://github.com/cloudfarmenterprisesinfo-max/avirochat/blob/main/src/components/LoginPage.tsx): `src/components/LoginPage.tsx`
- [Client workspaces](https://github.com/cloudfarmenterprisesinfo-max/avirochat/blob/main/src/components/ClientManager.tsx): `src/components/ClientManager.tsx`
- [Workspace switcher](https://github.com/cloudfarmenterprisesinfo-max/avirochat/blob/main/src/components/ClientSwitcher.tsx): `src/components/ClientSwitcher.tsx`
- [User management](https://github.com/cloudfarmenterprisesinfo-max/avirochat/blob/main/src/components/UserManagement.tsx): `src/components/UserManagement.tsx`
- [Dashboard overview](https://github.com/cloudfarmenterprisesinfo-max/avirochat/blob/main/src/components/DashboardOverview.tsx): `src/components/DashboardOverview.tsx`
- [Workspace settings](https://github.com/cloudfarmenterprisesinfo-max/avirochat/blob/main/src/components/SettingsView.tsx): `src/components/SettingsView.tsx`
- [Meta signup](https://github.com/cloudfarmenterprisesinfo-max/avirochat/blob/main/src/components/MetaEmbeddedSignupButton.tsx): `src/components/MetaEmbeddedSignupButton.tsx`

### Messaging and Automation

- [AI agent settings](https://github.com/cloudfarmenterprisesinfo-max/avirochat/blob/main/src/components/AIBotSettings.tsx): `src/components/AIBotSettings.tsx`
- [Automation flows](https://github.com/cloudfarmenterprisesinfo-max/avirochat/blob/main/src/components/AutomationFlowBuilder.tsx): `src/components/AutomationFlowBuilder.tsx`
- [Shared chat inbox](https://github.com/cloudfarmenterprisesinfo-max/avirochat/blob/main/src/components/WhatsAppInbox.tsx): `src/components/WhatsAppInbox.tsx`
- [Website chat widget](https://github.com/cloudfarmenterprisesinfo-max/avirochat/blob/main/src/components/WhatsAppWidgetGenerator.tsx): `src/components/WhatsAppWidgetGenerator.tsx`
- [Broadcast manager](https://github.com/cloudfarmenterprisesinfo-max/avirochat/blob/main/src/components/CampaignManager.tsx): `src/components/CampaignManager.tsx`

### Sales Operations

- [Lead CRM](https://github.com/cloudfarmenterprisesinfo-max/avirochat/blob/main/src/components/LeadCRM.tsx): `src/components/LeadCRM.tsx`
- [Product catalog](https://github.com/cloudfarmenterprisesinfo-max/avirochat/blob/main/src/components/EcommerceCMS.tsx): `src/components/EcommerceCMS.tsx`
- [Orders and invoices](https://github.com/cloudfarmenterprisesinfo-max/avirochat/blob/main/src/components/OrderManager.tsx): `src/components/OrderManager.tsx`

### Application API

- [Leads API](https://github.com/cloudfarmenterprisesinfo-max/avirochat/blob/main/src/app/api/leads/route.ts): `src/app/api/leads/route.ts`
- [Chat API](https://github.com/cloudfarmenterprisesinfo-max/avirochat/blob/main/src/app/api/chat/route.ts): `src/app/api/chat/route.ts`
- [WhatsApp webhook](https://github.com/cloudfarmenterprisesinfo-max/avirochat/blob/main/src/app/api/whatsapp/webhook/route.ts): `src/app/api/whatsapp/webhook/route.ts`
- [Organizations API](https://github.com/cloudfarmenterprisesinfo-max/avirochat/blob/main/src/app/api/organizations/route.ts): `src/app/api/organizations/route.ts`
- [Automations API](https://github.com/cloudfarmenterprisesinfo-max/avirochat/blob/main/src/app/api/automations/route.ts): `src/app/api/automations/route.ts`
- [Templates API](https://github.com/cloudfarmenterprisesinfo-max/avirochat/blob/main/src/app/api/templates/route.ts): `src/app/api/templates/route.ts`
- [Campaigns API](https://github.com/cloudfarmenterprisesinfo-max/avirochat/blob/main/src/app/api/campaigns/route.ts): `src/app/api/campaigns/route.ts`
- [Products API](https://github.com/cloudfarmenterprisesinfo-max/avirochat/blob/main/src/app/api/products/route.ts): `src/app/api/products/route.ts`
- [Orders API](https://github.com/cloudfarmenterprisesinfo-max/avirochat/blob/main/src/app/api/orders/route.ts): `src/app/api/orders/route.ts`
- [Statistics API](https://github.com/cloudfarmenterprisesinfo-max/avirochat/blob/main/src/app/api/stats/route.ts): `src/app/api/stats/route.ts`

### Persistence

- [Prisma client](https://github.com/cloudfarmenterprisesinfo-max/avirochat/blob/main/src/lib/prisma.ts): `src/lib/prisma.ts`
- **Tenant data store**

### Other components

- **Workspace operator**
- **Meta Cloud API**
- **Google Gemini**

## Connections

- Workspace operator → Dashboard shell: uses
- Dashboard shell → Login view: renders (evidence: `src/app/page.tsx`)
- Dashboard shell → Client workspaces: renders (evidence: `src/app/page.tsx`)
- Dashboard shell → Workspace switcher: renders (evidence: `src/app/page.tsx`)
- Dashboard shell → User management: renders (evidence: `src/app/page.tsx`)
- Dashboard shell → Dashboard overview: renders (evidence: `src/app/page.tsx`)
- Dashboard shell → AI agent settings: renders (evidence: `src/app/page.tsx`)
- Dashboard shell → Automation flows: renders (evidence: `src/app/page.tsx`)
- Dashboard shell → Shared chat inbox: renders (evidence: `src/app/page.tsx`)
- Dashboard shell → Website chat widget: renders (evidence: `src/app/page.tsx`)
- Dashboard shell → Broadcast manager: renders (evidence: `src/app/page.tsx`)
- Dashboard shell → Lead CRM: renders (evidence: `src/app/page.tsx`)
- Dashboard shell → Product catalog: renders (evidence: `src/app/page.tsx`)
- Dashboard shell → Orders and invoices: renders (evidence: `src/app/page.tsx`)
- Dashboard shell → Workspace settings: renders (evidence: `src/app/page.tsx`)
- Client workspaces → Meta signup: embeds (evidence: `src/components/ClientManager.tsx`)
- Workspace settings → Meta signup: embeds (evidence: `src/components/SettingsView.tsx`)
- Meta Cloud API → WhatsApp webhook: sends events
- Meta Cloud API → Meta signup: onboards accounts
- WhatsApp webhook → Tenant data store: updates messages and leads (evidence: `src/app/api/whatsapp/webhook/route.ts`)
- Chat API → Meta Cloud API: dispatches messages (evidence: `src/app/api/chat/route.ts`)
- Templates API → Meta Cloud API: syncs templates (evidence: `src/app/api/templates/route.ts`)
- WhatsApp webhook → Prisma client: queries and writes (evidence: `src/app/api/whatsapp/webhook/route.ts`)
- Chat API → Prisma client: queries and writes (evidence: `src/app/api/chat/route.ts`)
- Leads API → Prisma client: queries and writes (evidence: `src/app/api/leads/route.ts`)
- Organizations API → Prisma client: queries and writes (evidence: `src/app/api/organizations/route.ts`)
- Automations API → Prisma client: queries and writes (evidence: `src/app/api/automations/route.ts`)
- Templates API → Prisma client: queries and writes (evidence: `src/app/api/templates/route.ts`)
- Campaigns API → Prisma client: queries and writes (evidence: `src/app/api/campaigns/route.ts`)
- Products API → Prisma client: queries and writes (evidence: `src/app/api/products/route.ts`)
- Orders API → Prisma client: queries and writes (evidence: `src/app/api/orders/route.ts`)
- Statistics API → Prisma client: queries (evidence: `src/app/api/stats/route.ts`)
- Prisma client → Tenant data store: persists data
- Google Gemini → WhatsApp webhook: AI replies
