# webzygo/wacrm architecture

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

- Interactive diagram: https://gitdiagram.com/webzygo/wacrm
- Repository: https://github.com/webzygo/wacrm

## Overview

wacrm is a self-hostable WhatsApp CRM. The main workflow is customer messages arriving through Meta’s webhook, becoming contacts and conversations for agents in the shared inbox, with optional automation and AI handling. The product also includes contact management, sales pipelines, broadcasts, team/account administration, a dashboard, a scoped REST API, and an MCP server. Paths and links reflect the README and supplied source index/excerpts; unsampled subsystem internals are represented at their existing directory or route paths.

Main entry points: [`src/app/api/whatsapp/webhook/route.ts`](https://github.com/webzygo/wacrm/blob/main/src/app/api/whatsapp/webhook/route.ts) (Inbound webhook), [`src/lib/whatsapp`](https://github.com/webzygo/wacrm/tree/main/src/lib/whatsapp) (WhatsApp messaging core), [`src/lib/supabase/server.ts`](https://github.com/webzygo/wacrm/blob/main/src/lib/supabase/server.ts) (Supabase data and auth), [`src/app/api/whatsapp/broadcast/route.ts`](https://github.com/webzygo/wacrm/blob/main/src/app/api/whatsapp/broadcast/route.ts) (Broadcasts)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_messaging["Messaging"]
  node_webhook["Inbound webhook<br/>[route.ts]"]
  node_inbox["Shared inbox<br/>[page.tsx]"]
  node_send["WhatsApp send<br/>[route.ts]"]
  node_wa_core["WhatsApp messaging core"]
  node_broadcasts["Broadcasts<br/>[route.ts]"]
  node_templates["Message templates"]
end

subgraph group_customer_ops["Customer operations"]
  node_contacts["Contacts and tags<br/>[page.tsx]"]
  node_contact_import["Contact import"]
  node_pipelines["Sales pipelines<br/>[pipeline-board.tsx]"]
  node_dashboard["Analytics dashboard<br/>[queries.ts]"]
end

subgraph group_automation_ai["Automation and AI"]
  node_automation_builder["Automation builder"]
  node_automation_engine["Automation engine<br/>[engine.ts]"]
  node_flow_builder["Flow builder<br/>[flow-builder.tsx]"]
  node_flow_engine["Flow engine<br/>[engine.ts]"]
  node_ai["AI assistance and knowledge"]
end

subgraph group_team_platform["Team and platform"]
  node_account["Team and account access<br/>[account.ts]"]
  node_auth_ui["Sign-in and signup<br/>[use-auth.tsx]"]
  node_database[("Supabase data and auth<br/>[server.ts]")]
end

subgraph group_integrations["External interfaces"]
  node_rest_api["Scoped REST API"]
  node_mcp["MCP server"]
end

node_customer(("WhatsApp customer"))
node_agent(("CRM agent"))
node_meta{{"WhatsApp Business API"}}
node_api_user(("API or MCP client"))

node_customer -->|"sends messages"| node_meta
node_meta -->|"delivers events"| node_webhook
node_webhook -->|"resolves identity"| node_contacts
node_webhook -.->|"records conversation"| node_inbox
node_webhook -->|"dispatches triggers"| node_automation_engine
node_webhook -.->|"dispatches inbound"| node_flow_engine
node_webhook -.->|"may auto-reply"| node_ai
node_agent -->|"handles conversations"| node_inbox
node_inbox -.->|"sends replies"| node_send
node_send -->|"uses messaging logic"| node_wa_core
node_wa_core -->|"sends via API"| node_meta
node_contacts -->|"imports CSV"| node_contact_import
node_agent -->|"manages deals"| node_pipelines
node_agent -->|"creates campaigns"| node_broadcasts
node_broadcasts -->|"uses templates"| node_templates
node_broadcasts -->|"delivers broadcasts"| node_meta
node_agent -->|"configures rules"| node_automation_builder
node_automation_builder -.->|"defines automations"| node_automation_engine
node_automation_engine -->|"sends messages"| node_wa_core
node_agent -->|"builds flows"| node_flow_builder
node_flow_builder -.->|"configures flow"| node_flow_engine
node_flow_engine -->|"sends messages"| node_wa_core
node_agent -->|"drafts replies"| node_ai
node_ai -->|"retrieves knowledge"| node_database
node_agent -->|"views metrics"| node_dashboard
node_auth_ui -->|"authenticates"| node_database
node_account -->|"loads account context"| node_database
node_api_user -->|"calls endpoints"| node_rest_api
node_api_user -->|"connects assistants"| node_mcp
node_rest_api -.->|"accesses CRM data"| node_database

click node_webhook "https://github.com/webzygo/wacrm/blob/main/src/app/api/whatsapp/webhook/route.ts"
click node_inbox "https://github.com/webzygo/wacrm/blob/main/src/app/(dashboard)/inbox/page.tsx"
click node_send "https://github.com/webzygo/wacrm/blob/main/src/app/api/whatsapp/send/route.ts"
click node_wa_core "https://github.com/webzygo/wacrm/tree/main/src/lib/whatsapp"
click node_contacts "https://github.com/webzygo/wacrm/blob/main/src/app/(dashboard)/contacts/page.tsx"
click node_contact_import "https://github.com/webzygo/wacrm/blob/main/src/lib/contacts/parse-contact-csv.ts"
click node_pipelines "https://github.com/webzygo/wacrm/blob/main/src/components/pipelines/pipeline-board.tsx"
click node_broadcasts "https://github.com/webzygo/wacrm/blob/main/src/app/api/whatsapp/broadcast/route.ts"
click node_templates "https://github.com/webzygo/wacrm/blob/main/src/components/settings/template-manager.tsx"
click node_automation_builder "https://github.com/webzygo/wacrm/blob/main/src/components/automations/automation-builder.tsx"
click node_automation_engine "https://github.com/webzygo/wacrm/blob/main/src/lib/automations/engine.ts"
click node_flow_builder "https://github.com/webzygo/wacrm/blob/main/src/components/flows/flow-builder.tsx"
click node_flow_engine "https://github.com/webzygo/wacrm/blob/main/src/lib/flows/engine.ts"
click node_ai "https://github.com/webzygo/wacrm/tree/main/src/lib/ai"
click node_dashboard "https://github.com/webzygo/wacrm/blob/main/src/lib/dashboard/queries.ts"
click node_account "https://github.com/webzygo/wacrm/blob/main/src/lib/auth/account.ts"
click node_auth_ui "https://github.com/webzygo/wacrm/blob/main/src/hooks/use-auth.tsx"
click node_database "https://github.com/webzygo/wacrm/blob/main/src/lib/supabase/server.ts"
click node_rest_api "https://github.com/webzygo/wacrm/tree/main/src/app/api/v1"
click node_mcp "https://github.com/webzygo/wacrm/tree/main/mcp-server/src"

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_webhook,node_inbox,node_send,node_wa_core,node_broadcasts,node_templates,node_api_user toneBlue
class node_contacts,node_contact_import,node_pipelines,node_dashboard toneAmber
class node_automation_builder,node_automation_engine,node_flow_builder,node_flow_engine,node_ai,node_meta toneMint
class node_account,node_auth_ui,node_database toneRose
class node_rest_api,node_mcp,node_customer,node_agent toneIndigo
```

## Components

### Messaging

- [Inbound webhook](https://github.com/webzygo/wacrm/blob/main/src/app/api/whatsapp/webhook/route.ts): `src/app/api/whatsapp/webhook/route.ts`
- [Shared inbox](https://github.com/webzygo/wacrm/blob/main/src/app/(dashboard)/inbox/page.tsx): `src/app/(dashboard)/inbox/page.tsx`
- [WhatsApp send](https://github.com/webzygo/wacrm/blob/main/src/app/api/whatsapp/send/route.ts): `src/app/api/whatsapp/send/route.ts`
- [WhatsApp messaging core](https://github.com/webzygo/wacrm/tree/main/src/lib/whatsapp): `src/lib/whatsapp`
- [Broadcasts](https://github.com/webzygo/wacrm/blob/main/src/app/api/whatsapp/broadcast/route.ts): `src/app/api/whatsapp/broadcast/route.ts`
- [Message templates](https://github.com/webzygo/wacrm/blob/main/src/components/settings/template-manager.tsx): `src/components/settings/template-manager.tsx`

### Customer operations

- [Contacts and tags](https://github.com/webzygo/wacrm/blob/main/src/app/(dashboard)/contacts/page.tsx): `src/app/(dashboard)/contacts/page.tsx`
- [Contact import](https://github.com/webzygo/wacrm/blob/main/src/lib/contacts/parse-contact-csv.ts): `src/lib/contacts/parse-contact-csv.ts`
- [Sales pipelines](https://github.com/webzygo/wacrm/blob/main/src/components/pipelines/pipeline-board.tsx): `src/components/pipelines/pipeline-board.tsx`
- [Analytics dashboard](https://github.com/webzygo/wacrm/blob/main/src/lib/dashboard/queries.ts): `src/lib/dashboard/queries.ts`

### Automation and AI

- [Automation builder](https://github.com/webzygo/wacrm/blob/main/src/components/automations/automation-builder.tsx): `src/components/automations/automation-builder.tsx`
- [Automation engine](https://github.com/webzygo/wacrm/blob/main/src/lib/automations/engine.ts): `src/lib/automations/engine.ts`
- [Flow builder](https://github.com/webzygo/wacrm/blob/main/src/components/flows/flow-builder.tsx): `src/components/flows/flow-builder.tsx`
- [Flow engine](https://github.com/webzygo/wacrm/blob/main/src/lib/flows/engine.ts): `src/lib/flows/engine.ts`
- [AI assistance and knowledge](https://github.com/webzygo/wacrm/tree/main/src/lib/ai): `src/lib/ai`

### Team and platform

- [Team and account access](https://github.com/webzygo/wacrm/blob/main/src/lib/auth/account.ts): `src/lib/auth/account.ts`
- [Sign-in and signup](https://github.com/webzygo/wacrm/blob/main/src/hooks/use-auth.tsx): `src/hooks/use-auth.tsx`
- [Supabase data and auth](https://github.com/webzygo/wacrm/blob/main/src/lib/supabase/server.ts): `src/lib/supabase/server.ts`

### External interfaces

- [Scoped REST API](https://github.com/webzygo/wacrm/tree/main/src/app/api/v1): `src/app/api/v1`
- [MCP server](https://github.com/webzygo/wacrm/tree/main/mcp-server/src): `mcp-server/src`

### Other components

- **WhatsApp customer**
- **CRM agent**
- **WhatsApp Business API**
- **API or MCP client**

## Connections

- WhatsApp customer → WhatsApp Business API: sends messages (evidence: `README.md`)
- WhatsApp Business API → Inbound webhook: delivers events (evidence: `README.md`)
- Inbound webhook → Contacts and tags: resolves identity (evidence: `src/app/api/whatsapp/webhook/route.ts`)
- Inbound webhook → Shared inbox: records conversation
- Inbound webhook → Automation engine: dispatches triggers (evidence: `src/app/api/whatsapp/webhook/route.ts`)
- Inbound webhook → Flow engine: dispatches inbound (evidence: `src/app/api/whatsapp/webhook/route.ts`)
- Inbound webhook → AI assistance and knowledge: may auto-reply (evidence: `src/app/api/whatsapp/webhook/route.ts`)
- CRM agent → Shared inbox: handles conversations (evidence: `README.md`)
- Shared inbox → WhatsApp send: sends replies
- WhatsApp send → WhatsApp messaging core: uses messaging logic (evidence: `src/app/api/whatsapp/send/route.ts`)
- WhatsApp messaging core → WhatsApp Business API: sends via API (evidence: `README.md`)
- Contacts and tags → Contact import: imports CSV (evidence: `README.md`)
- CRM agent → Sales pipelines: manages deals (evidence: `README.md`)
- CRM agent → Broadcasts: creates campaigns (evidence: `README.md`)
- Broadcasts → Message templates: uses templates (evidence: `README.md`)
- Broadcasts → WhatsApp Business API: delivers broadcasts (evidence: `README.md`)
- CRM agent → Automation builder: configures rules (evidence: `README.md`)
- Automation builder → Automation engine: defines automations
- Automation engine → WhatsApp messaging core: sends messages (evidence: `src/lib/automations/engine.ts`)
- CRM agent → Flow builder: builds flows (evidence: `README.md`)
- Flow builder → Flow engine: configures flow
- Flow engine → WhatsApp messaging core: sends messages (evidence: `src/lib/flows/engine.ts`)
- CRM agent → AI assistance and knowledge: drafts replies (evidence: `README.md`)
- AI assistance and knowledge → Supabase data and auth: retrieves knowledge (evidence: `README.md`)
- CRM agent → Analytics dashboard: views metrics (evidence: `README.md`)
- Sign-in and signup → Supabase data and auth: authenticates (evidence: `src/hooks/use-auth.tsx`)
- Team and account access → Supabase data and auth: loads account context (evidence: `src/lib/auth/account.ts`)
- API or MCP client → Scoped REST API: calls endpoints (evidence: `README.md`)
- API or MCP client → MCP server: connects assistants (evidence: `README.md`)
- Scoped REST API → Supabase data and auth: accesses CRM data
