# kurmamadhav/wacrm architecture

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

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

## Overview

wacrm is a self-hostable WhatsApp CRM. Agents work shared conversations and contacts, then manage deals, send template-based broadcasts, and automate follow-ups; inbound WhatsApp events enter through a webhook that updates CRM records and dispatches automation. The product also provides AI assistance, reporting, team/account management, a scoped REST API, and an MCP server. The graph reflects README capabilities and the supplied source excerpts; unsampled wiring is omitted where it cannot be established.

Main entry points: [`src/lib/supabase/server.ts`](https://github.com/kurmamadhav/wacrm/blob/main/src/lib/supabase/server.ts) (Supabase data), [`src/lib/automations/engine.ts`](https://github.com/kurmamadhav/wacrm/blob/main/src/lib/automations/engine.ts) (No-code automations), [`src/app/api/whatsapp/webhook/route.ts`](https://github.com/kurmamadhav/wacrm/blob/main/src/app/api/whatsapp/webhook/route.ts) (Inbound webhook), [`src/lib/flows/engine.ts`](https://github.com/kurmamadhav/wacrm/blob/main/src/lib/flows/engine.ts) (Conversation flows)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_engage["Customer engagement"]
  node_inbox["Shared inbox<br/>[page.tsx]"]
  node_webhook["Inbound webhook<br/>[route.ts]"]
  node_waapi["WhatsApp API<br/>[meta-api.ts]"]
  node_broadcasts["Broadcasts<br/>[route.ts]"]
end

subgraph group_manage["CRM management"]
  node_contacts["Contacts and tags<br/>[page.tsx]"]
  node_pipelines["Sales pipelines<br/>[page.tsx]"]
  node_dashboard["Reporting dashboard<br/>[queries.ts]"]
end

subgraph group_automate["Automation and AI"]
  node_automations["No-code automations<br/>[engine.ts]"]
  node_flows["Conversation flows<br/>[engine.ts]"]
  node_ai["AI assistant<br/>[auto-reply.ts]"]
  node_knowledge["AI knowledge base<br/>[knowledge.ts]"]
end

subgraph group_platform["Access and platform"]
  node_rest["Public REST API<br/>[route.ts]"]
  node_mcp["MCP server<br/>[index.ts]"]
  node_account["Team and account<br/>[account.ts]"]
  node_database[("Supabase data<br/>[server.ts]")]
end

node_agents(("CRM agents"))
node_whatsapp(("WhatsApp Business"))

node_agents -->|"work conversations"| node_inbox
node_whatsapp -->|"send events"| node_webhook
node_webhook -->|"write inbound data"| node_database
node_webhook -->|"resolve contacts"| node_contacts
node_webhook -->|"dispatch triggers"| node_automations
node_webhook -->|"dispatch inbound"| node_flows
node_inbox -->|"read and update"| node_database
node_inbox -->|"send messages"| node_waapi
node_broadcasts -->|"read recipients"| node_database
node_broadcasts -->|"send campaigns"| node_waapi
node_contacts -->|"manage records"| node_database
node_pipelines -->|"manage deals"| node_database
node_dashboard -->|"query metrics"| node_database
node_automations -->|"load and log runs"| node_database
node_automations -->|"send messages"| node_waapi
node_automations -->|"add tags"| node_contacts
node_automations -.->|"post webhook"| node_whatsapp
node_flows -->|"load and update runs"| node_database
node_flows -->|"send flow messages"| node_waapi
node_flows -->|"dispatch tag updates"| node_contacts
node_ai -->|"retrieve context"| node_knowledge
node_rest -->|"read and write"| node_database
node_mcp -.->|"access CRM API"| node_rest
node_account -->|"manage membership"| node_database
node_agents -->|"create campaigns"| node_broadcasts
node_agents -->|"manage deals"| node_pipelines
node_agents -->|"configure rules"| node_automations
node_agents -->|"draft replies"| node_ai

click node_inbox "https://github.com/kurmamadhav/wacrm/blob/main/src/app/(dashboard)/inbox/page.tsx"
click node_webhook "https://github.com/kurmamadhav/wacrm/blob/main/src/app/api/whatsapp/webhook/route.ts"
click node_waapi "https://github.com/kurmamadhav/wacrm/blob/main/src/lib/whatsapp/meta-api.ts"
click node_broadcasts "https://github.com/kurmamadhav/wacrm/blob/main/src/app/api/whatsapp/broadcast/route.ts"
click node_contacts "https://github.com/kurmamadhav/wacrm/blob/main/src/app/(dashboard)/contacts/page.tsx"
click node_pipelines "https://github.com/kurmamadhav/wacrm/blob/main/src/app/(dashboard)/pipelines/page.tsx"
click node_dashboard "https://github.com/kurmamadhav/wacrm/blob/main/src/lib/dashboard/queries.ts"
click node_automations "https://github.com/kurmamadhav/wacrm/blob/main/src/lib/automations/engine.ts"
click node_flows "https://github.com/kurmamadhav/wacrm/blob/main/src/lib/flows/engine.ts"
click node_ai "https://github.com/kurmamadhav/wacrm/blob/main/src/lib/ai/auto-reply.ts"
click node_knowledge "https://github.com/kurmamadhav/wacrm/blob/main/src/lib/ai/knowledge.ts"
click node_rest "https://github.com/kurmamadhav/wacrm/blob/main/src/app/api/v1/contacts/route.ts"
click node_mcp "https://github.com/kurmamadhav/wacrm/blob/main/mcp-server/src/index.ts"
click node_account "https://github.com/kurmamadhav/wacrm/blob/main/src/lib/auth/account.ts"
click node_database "https://github.com/kurmamadhav/wacrm/blob/main/src/lib/supabase/server.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_inbox,node_webhook,node_waapi,node_broadcasts toneBlue
class node_contacts,node_pipelines,node_dashboard toneAmber
class node_automations,node_flows,node_ai,node_knowledge toneMint
class node_rest,node_mcp,node_account,node_database toneRose
class node_agents,node_whatsapp toneIndigo
```

## Components

### Customer engagement

- [Shared inbox](https://github.com/kurmamadhav/wacrm/blob/main/src/app/(dashboard)/inbox/page.tsx): `src/app/(dashboard)/inbox/page.tsx`
- [Inbound webhook](https://github.com/kurmamadhav/wacrm/blob/main/src/app/api/whatsapp/webhook/route.ts): `src/app/api/whatsapp/webhook/route.ts`
- [WhatsApp API](https://github.com/kurmamadhav/wacrm/blob/main/src/lib/whatsapp/meta-api.ts): `src/lib/whatsapp/meta-api.ts`
- [Broadcasts](https://github.com/kurmamadhav/wacrm/blob/main/src/app/api/whatsapp/broadcast/route.ts): `src/app/api/whatsapp/broadcast/route.ts`

### CRM management

- [Contacts and tags](https://github.com/kurmamadhav/wacrm/blob/main/src/app/(dashboard)/contacts/page.tsx): `src/app/(dashboard)/contacts/page.tsx`
- [Sales pipelines](https://github.com/kurmamadhav/wacrm/blob/main/src/app/(dashboard)/pipelines/page.tsx): `src/app/(dashboard)/pipelines/page.tsx`
- [Reporting dashboard](https://github.com/kurmamadhav/wacrm/blob/main/src/lib/dashboard/queries.ts): `src/lib/dashboard/queries.ts`

### Automation and AI

- [No-code automations](https://github.com/kurmamadhav/wacrm/blob/main/src/lib/automations/engine.ts): `src/lib/automations/engine.ts`
- [Conversation flows](https://github.com/kurmamadhav/wacrm/blob/main/src/lib/flows/engine.ts): `src/lib/flows/engine.ts`
- [AI assistant](https://github.com/kurmamadhav/wacrm/blob/main/src/lib/ai/auto-reply.ts): `src/lib/ai/auto-reply.ts`
- [AI knowledge base](https://github.com/kurmamadhav/wacrm/blob/main/src/lib/ai/knowledge.ts): `src/lib/ai/knowledge.ts`

### Access and platform

- [Public REST API](https://github.com/kurmamadhav/wacrm/blob/main/src/app/api/v1/contacts/route.ts): `src/app/api/v1/contacts/route.ts`
- [MCP server](https://github.com/kurmamadhav/wacrm/blob/main/mcp-server/src/index.ts): `mcp-server/src/index.ts`
- [Team and account](https://github.com/kurmamadhav/wacrm/blob/main/src/lib/auth/account.ts): `src/lib/auth/account.ts`
- [Supabase data](https://github.com/kurmamadhav/wacrm/blob/main/src/lib/supabase/server.ts): `src/lib/supabase/server.ts`

### Other components

- **CRM agents**
- **WhatsApp Business**

## Connections

- CRM agents → Shared inbox: work conversations
- WhatsApp Business → Inbound webhook: send events
- Inbound webhook → Supabase data: write inbound data
- Inbound webhook → Contacts and tags: resolve contacts
- Inbound webhook → No-code automations: dispatch triggers
- Inbound webhook → Conversation flows: dispatch inbound
- Shared inbox → Supabase data: read and update
- Shared inbox → WhatsApp API: send messages
- Broadcasts → Supabase data: read recipients
- Broadcasts → WhatsApp API: send campaigns
- Contacts and tags → Supabase data: manage records
- Sales pipelines → Supabase data: manage deals
- Reporting dashboard → Supabase data: query metrics
- No-code automations → Supabase data: load and log runs
- No-code automations → WhatsApp API: send messages
- No-code automations → Contacts and tags: add tags
- No-code automations → WhatsApp Business: post webhook
- Conversation flows → Supabase data: load and update runs
- Conversation flows → WhatsApp API: send flow messages
- Conversation flows → Contacts and tags: dispatch tag updates
- AI assistant → AI knowledge base: retrieve context
- Public REST API → Supabase data: read and write
- MCP server → Public REST API: access CRM API
- Team and account → Supabase data: manage membership
- CRM agents → Broadcasts: create campaigns
- CRM agents → Sales pipelines: manage deals
- CRM agents → No-code automations: configure rules
- CRM agents → AI assistant: draft replies
