# waliedmohamed999-max/dms-chat-boot-new architecture

> Architecture diagram of the GitHub repository waliedmohamed999-max/dms-chat-boot-new, 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/waliedmohamed999-max/dms-chat-boot-new
- Repository: https://github.com/waliedmohamed999-max/dms-chat-boot-new

## Overview

واصل is a multi-tenant WhatsApp CRM SaaS for merchants. Its principal workflow is managing contacts and campaigns in a merchant workspace, queueing campaign sends, and delivering messages through connected WhatsApp channels; inbound WhatsApp messages are recorded and can enter chatbot automation. The README also documents inbox, chatbot, templates, orders, billing, and integrations, plus platform-wide administration. Source excerpts show the database isolation layer, campaign queue/worker, and inbound processing; unsampled feature connections are included only where the README documents them.

Main entry points: [`src/app/dashboard/page.tsx`](https://github.com/waliedmohamed999-max/dms-chat-boot-new/blob/main/src/app/dashboard/page.tsx) (Workspace dashboard), [`src/lib/db.ts`](https://github.com/waliedmohamed999-max/dms-chat-boot-new/blob/main/src/lib/db.ts) (Postgres tenant store), [`src/lib/queue/worker.ts`](https://github.com/waliedmohamed999-max/dms-chat-boot-new/blob/main/src/lib/queue/worker.ts) (Message worker), [`src/lib/chatbot/engine.ts`](https://github.com/waliedmohamed999-max/dms-chat-boot-new/blob/main/src/lib/chatbot/engine.ts) (Chatbot flows)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_merchant["Merchant workspace"]
  node_workspace["Workspace dashboard<br/>[page.tsx]"]
  node_contacts["Contacts CRM"]
  node_campaigns["Campaign management"]
  node_inbox["Unified inbox"]
  node_orders["Orders"]
  node_billing["Subscriptions"]
end

subgraph group_messaging["Messaging automation"]
  node_chatbot["Chatbot flows<br/>[engine.ts]"]
  node_campaign_scan["Trigger scanner<br/>[triggerEngine.ts]"]
  node_send_queue["Campaign queue<br/>[campaignQueue.ts]"]
  node_worker["Message worker<br/>[worker.ts]"]
end

subgraph group_connectors["Channels and commerce"]
  node_meta_webhook["Meta webhook<br/>[route.ts]"]
  node_inbound_handler["Inbound processor<br/>[webhookHandler.ts]"]
  node_channel_registry["Channel adapters<br/>[registry.ts]"]
  node_commerce["Zid and Salla"]
end

subgraph group_platform["Platform operations"]
  node_admin["Admin console"]
end

subgraph group_security["Shared foundations"]
  node_database[("Postgres tenant store<br/>[db.ts]")]
  node_access["Sessions and permissions<br/>[session.ts]"]
  node_limits["Plan limits<br/>[planLimits.ts]"]
  node_redis[("Redis and rate limits<br/>[rateLimit.ts]")]
end

node_merchant(("Merchant"))
node_platform_admin(("Platform admin"))
node_customer(("WhatsApp customer"))
node_meta["Meta WhatsApp"]
node_zid_salla["Zid and Salla services"]

node_merchant -->|"uses"| node_workspace
node_workspace -->|"manages"| node_contacts
node_workspace -->|"manages"| node_campaigns
node_workspace -->|"opens"| node_inbox
node_workspace -->|"manages"| node_orders
node_workspace -->|"manages"| node_billing
node_campaign_scan -->|"reads and writes"| node_database
node_campaign_scan -->|"enqueues"| node_send_queue
node_worker -->|"processes"| node_send_queue
node_worker -->|"resolves adapter"| node_channel_registry
node_worker -->|"checks send limit"| node_redis
node_worker -->|"updates campaign"| node_database
node_channel_registry -.->|"selects channel"| node_meta
node_meta -->|"sends events"| node_meta_webhook
node_meta_webhook -->|"checks limits"| node_redis
node_meta_webhook -->|"parses and applies"| node_inbound_handler
node_inbound_handler -->|"stores messages"| node_database
node_inbound_handler -.->|"returns conversations"| node_chatbot
node_chatbot -->|"loads flow and conversation"| node_database
node_chatbot -->|"sends replies"| node_channel_registry
node_commerce -->|"connects stores"| node_zid_salla
node_zid_salla -.->|"webhook sync"| node_database
node_platform_admin -->|"administers platform"| node_admin
node_workspace -.->|"requires session"| node_access
node_access -.->|"uses tenant scope"| node_database
node_billing -.->|"governs usage"| node_limits

click node_workspace "https://github.com/waliedmohamed999-max/dms-chat-boot-new/blob/main/src/app/dashboard/page.tsx"
click node_contacts "https://github.com/waliedmohamed999-max/dms-chat-boot-new/tree/main/src/app/dashboard/contacts"
click node_campaigns "https://github.com/waliedmohamed999-max/dms-chat-boot-new/tree/main/src/app/dashboard/campaigns"
click node_inbox "https://github.com/waliedmohamed999-max/dms-chat-boot-new/tree/main/src/app/dashboard/inbox"
click node_orders "https://github.com/waliedmohamed999-max/dms-chat-boot-new/tree/main/src/app/dashboard/orders"
click node_billing "https://github.com/waliedmohamed999-max/dms-chat-boot-new/tree/main/src/app/dashboard/billing"
click node_chatbot "https://github.com/waliedmohamed999-max/dms-chat-boot-new/blob/main/src/lib/chatbot/engine.ts"
click node_campaign_scan "https://github.com/waliedmohamed999-max/dms-chat-boot-new/blob/main/src/lib/campaigns/triggerEngine.ts"
click node_send_queue "https://github.com/waliedmohamed999-max/dms-chat-boot-new/blob/main/src/lib/queue/campaignQueue.ts"
click node_worker "https://github.com/waliedmohamed999-max/dms-chat-boot-new/blob/main/src/lib/queue/worker.ts"
click node_meta_webhook "https://github.com/waliedmohamed999-max/dms-chat-boot-new/blob/main/src/app/api/webhooks/meta/route.ts"
click node_inbound_handler "https://github.com/waliedmohamed999-max/dms-chat-boot-new/blob/main/src/lib/integrations/meta/webhookHandler.ts"
click node_channel_registry "https://github.com/waliedmohamed999-max/dms-chat-boot-new/blob/main/src/lib/integrations/registry.ts"
click node_commerce "https://github.com/waliedmohamed999-max/dms-chat-boot-new/tree/main/src/lib/integrations"
click node_admin "https://github.com/waliedmohamed999-max/dms-chat-boot-new/tree/main/src/app/admin"
click node_database "https://github.com/waliedmohamed999-max/dms-chat-boot-new/blob/main/src/lib/db.ts"
click node_access "https://github.com/waliedmohamed999-max/dms-chat-boot-new/blob/main/src/lib/session.ts"
click node_limits "https://github.com/waliedmohamed999-max/dms-chat-boot-new/blob/main/src/lib/planLimits.ts"
click node_redis "https://github.com/waliedmohamed999-max/dms-chat-boot-new/blob/main/src/lib/rateLimit.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_workspace,node_contacts,node_campaigns,node_inbox,node_orders,node_billing toneBlue
class node_chatbot,node_campaign_scan,node_send_queue,node_worker toneAmber
class node_meta_webhook,node_inbound_handler,node_channel_registry,node_commerce toneMint
class node_admin toneRose
class node_database,node_access,node_limits,node_redis,node_merchant,node_platform_admin,node_customer,node_meta,node_zid_salla toneIndigo
```

## Components

### Merchant workspace

- [Workspace dashboard](https://github.com/waliedmohamed999-max/dms-chat-boot-new/blob/main/src/app/dashboard/page.tsx): `src/app/dashboard/page.tsx`
- [Contacts CRM](https://github.com/waliedmohamed999-max/dms-chat-boot-new/tree/main/src/app/dashboard/contacts): `src/app/dashboard/contacts`
- [Campaign management](https://github.com/waliedmohamed999-max/dms-chat-boot-new/tree/main/src/app/dashboard/campaigns): `src/app/dashboard/campaigns`
- [Unified inbox](https://github.com/waliedmohamed999-max/dms-chat-boot-new/tree/main/src/app/dashboard/inbox): `src/app/dashboard/inbox`
- [Orders](https://github.com/waliedmohamed999-max/dms-chat-boot-new/tree/main/src/app/dashboard/orders): `src/app/dashboard/orders`
- [Subscriptions](https://github.com/waliedmohamed999-max/dms-chat-boot-new/tree/main/src/app/dashboard/billing): `src/app/dashboard/billing`

### Messaging automation

- [Chatbot flows](https://github.com/waliedmohamed999-max/dms-chat-boot-new/blob/main/src/lib/chatbot/engine.ts): `src/lib/chatbot/engine.ts`
- [Trigger scanner](https://github.com/waliedmohamed999-max/dms-chat-boot-new/blob/main/src/lib/campaigns/triggerEngine.ts): `src/lib/campaigns/triggerEngine.ts`
- [Campaign queue](https://github.com/waliedmohamed999-max/dms-chat-boot-new/blob/main/src/lib/queue/campaignQueue.ts): `src/lib/queue/campaignQueue.ts`
- [Message worker](https://github.com/waliedmohamed999-max/dms-chat-boot-new/blob/main/src/lib/queue/worker.ts): `src/lib/queue/worker.ts`

### Channels and commerce

- [Meta webhook](https://github.com/waliedmohamed999-max/dms-chat-boot-new/blob/main/src/app/api/webhooks/meta/route.ts): `src/app/api/webhooks/meta/route.ts`
- [Inbound processor](https://github.com/waliedmohamed999-max/dms-chat-boot-new/blob/main/src/lib/integrations/meta/webhookHandler.ts): `src/lib/integrations/meta/webhookHandler.ts`
- [Channel adapters](https://github.com/waliedmohamed999-max/dms-chat-boot-new/blob/main/src/lib/integrations/registry.ts): `src/lib/integrations/registry.ts`
- [Zid and Salla](https://github.com/waliedmohamed999-max/dms-chat-boot-new/tree/main/src/lib/integrations): `src/lib/integrations`

### Platform operations

- [Admin console](https://github.com/waliedmohamed999-max/dms-chat-boot-new/tree/main/src/app/admin): `src/app/admin`

### Shared foundations

- [Postgres tenant store](https://github.com/waliedmohamed999-max/dms-chat-boot-new/blob/main/src/lib/db.ts): `src/lib/db.ts`
- [Sessions and permissions](https://github.com/waliedmohamed999-max/dms-chat-boot-new/blob/main/src/lib/session.ts): `src/lib/session.ts`
- [Plan limits](https://github.com/waliedmohamed999-max/dms-chat-boot-new/blob/main/src/lib/planLimits.ts): `src/lib/planLimits.ts`
- [Redis and rate limits](https://github.com/waliedmohamed999-max/dms-chat-boot-new/blob/main/src/lib/rateLimit.ts): `src/lib/rateLimit.ts`

### Other components

- **Merchant**
- **Platform admin**
- **WhatsApp customer**
- **Meta WhatsApp**
- **Zid and Salla services**

## Connections

- Merchant → Workspace dashboard: uses (evidence: `README.md`)
- Workspace dashboard → Contacts CRM: manages (evidence: `README.md`)
- Workspace dashboard → Campaign management: manages (evidence: `README.md`)
- Workspace dashboard → Unified inbox: opens (evidence: `README.md`)
- Workspace dashboard → Orders: manages (evidence: `README.md`)
- Workspace dashboard → Subscriptions: manages (evidence: `README.md`)
- Trigger scanner → Postgres tenant store: reads and writes (evidence: `src/lib/campaigns/triggerEngine.ts`)
- Trigger scanner → Campaign queue: enqueues (evidence: `src/lib/campaigns/triggerEngine.ts`)
- Message worker → Campaign queue: processes (evidence: `src/lib/queue/worker.ts`)
- Message worker → Channel adapters: resolves adapter (evidence: `src/lib/queue/worker.ts`)
- Message worker → Redis and rate limits: checks send limit (evidence: `src/lib/queue/worker.ts`)
- Message worker → Postgres tenant store: updates campaign (evidence: `src/lib/queue/worker.ts`)
- Channel adapters → Meta WhatsApp: selects channel (evidence: `src/lib/integrations/registry.ts`)
- Meta WhatsApp → Meta webhook: sends events (evidence: `README.md`)
- Meta webhook → Redis and rate limits: checks limits (evidence: `src/app/api/webhooks/meta/route.ts`)
- Meta webhook → Inbound processor: parses and applies (evidence: `src/app/api/webhooks/meta/route.ts`)
- Inbound processor → Postgres tenant store: stores messages (evidence: `src/lib/integrations/meta/webhookHandler.ts`)
- Inbound processor → Chatbot flows: returns conversations
- Chatbot flows → Postgres tenant store: loads flow and conversation (evidence: `src/lib/chatbot/engine.ts`)
- Chatbot flows → Channel adapters: sends replies (evidence: `src/lib/chatbot/engine.ts`)
- Zid and Salla → Zid and Salla services: connects stores (evidence: `README.md`)
- Zid and Salla services → Postgres tenant store: webhook sync (evidence: `README.md`)
- Platform admin → Admin console: administers platform (evidence: `README.md`)
- Workspace dashboard → Sessions and permissions: requires session
- Sessions and permissions → Postgres tenant store: uses tenant scope (evidence: `src/lib/session.ts`)
- Subscriptions → Plan limits: governs usage
