# engmohamadalagha/wasl-command-center architecture

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

- Interactive diagram: https://gitdiagram.com/engmohamadalagha/wasl-command-center
- Repository: https://github.com/engmohamadalagha/wasl-command-center
- Video tour (about a minute): https://gitdiagram.com/engmohamadalagha/wasl-command-center/video

## Overview

Wasl Command Center is a multi-tenant WhatsApp automation and business-management platform, with a web admin console and an Electron desktop shell. The principal customer flow is an inbound WhatsApp webhook, message processing and domain-specific handling, then an automated response through a channel sender. Separate admin workflows manage tenants, inbox conversations, bookings, orders, and templates; payment-proof handling can verify receipts. The README is empty, and excerpts are partial, so some route wiring and persistence details cannot be confirmed and are left unconnected.

Main entry points: [`src/ai/engine.mjs`](https://github.com/engmohamadalagha/wasl-command-center/blob/main/src/ai/engine.mjs) (AI conversation engine), [`src/web/routes/webhook/process.mjs`](https://github.com/engmohamadalagha/wasl-command-center/blob/main/src/web/routes/webhook/process.mjs) (Webhook processing), [`src/inbox/service.mjs`](https://github.com/engmohamadalagha/wasl-command-center/blob/main/src/inbox/service.mjs) (Inbox service), [`db.mjs`](https://github.com/engmohamadalagha/wasl-command-center/blob/main/db.mjs) (Database access)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Runtime and web"]
  node_desktop["Desktop shell<br/>[main.cjs]"]
  node_server["Server bootstrap<br/>[server.mjs]"]
  node_agent["Agent runtime<br/>[agent.mjs]"]
  node_web_app["Web application<br/>[app.mjs]"]
end

subgraph group_messaging["Messaging and AI"]
  node_webhook["Webhook routes<br/>[index.mjs]"]
  node_webhook_process["Webhook processing<br/>[process.mjs]"]
  node_ai_handler["AI handler<br/>[ai.mjs]"]
  node_ai_engine["AI conversation engine<br/>[engine.mjs]"]
  node_channel_send["Channel sending<br/>[send.mjs]"]
  node_channels["Channel adapters<br/>[registry.mjs]"]
end

subgraph group_business["Business workflows"]
  node_booking_handler["Booking handler<br/>[booking.mjs]"]
  node_order_handler["Order handler<br/>[orders.mjs]"]
  node_receipt["Receipt verification<br/>[paymentProof.mjs]"]
  node_calendar["Google Calendar<br/>[googleCalendar.mjs]"]
  node_crm["CRM<br/>[crm.mjs]"]
end

subgraph group_admin["Management console"]
  node_admin_routes["Admin routes<br/>[index.mjs]"]
  node_inbox["Inbox service<br/>[service.mjs]"]
  node_templates["Template lifecycle"]
end

subgraph group_platform["State and integrations"]
  node_tenants["Tenant configuration<br/>[tenants.mjs]"]
  node_database["Database access<br/>[db.mjs]"]
  node_conversations["Conversation memory<br/>[conversations.mjs]"]
  node_store["Key-value store<br/>[store.mjs]"]
  node_queue["Job queues<br/>[queue.mjs]"]
  node_redis_client["Redis client<br/>[redisClient.mjs]"]
end

node_customer(("WhatsApp customer"))
node_operator(("Business operator"))
node_meta{{"Meta WhatsApp"}}
node_ai_provider{{"AI provider"}}
node_postgres[("PostgreSQL")]
node_redis[("Redis")]

node_desktop -->|"starts backend"| node_server
node_server -->|"starts runtime"| node_agent
node_customer -->|"sends message"| node_meta
node_meta -->|"posts webhook"| node_webhook
node_webhook -->|"dispatches processing"| node_webhook_process
node_webhook_process -->|"dispatches AI"| node_ai_handler
node_webhook_process -->|"dispatches bookings"| node_booking_handler
node_webhook_process -->|"dispatches orders"| node_order_handler
node_ai_handler -->|"requests reply"| node_ai_engine
node_ai_engine -->|"resolves tenant"| node_tenants
node_ai_engine -->|"reads and writes history"| node_conversations
node_ai_engine -.->|"requests completion"| node_ai_provider
node_ai_engine -->|"returns reply for sending"| node_channels
node_channels -->|"selects sender"| node_channel_send
node_channel_send -->|"sends message"| node_meta
node_booking_handler -.->|"calendar integration"| node_calendar
node_order_handler -->|"handles receipt image"| node_receipt
node_receipt -->|"downloads media"| node_meta
node_receipt -->|"logs payment event"| node_crm
node_operator -->|"manages business"| node_admin_routes
node_admin_routes -->|"uses inbox service"| node_inbox
node_admin_routes -->|"manages templates"| node_templates
node_inbox -->|"reads conversation"| node_conversations
node_inbox -->|"reads takeover state"| node_store
node_inbox -->|"queries messages"| node_database
node_templates -->|"scoped template access"| node_database
node_templates -.->|"submits and syncs templates"| node_meta
node_web_app -->|"checks database health"| node_database
node_database -->|"queries"| node_postgres
node_queue -->|"requests Redis"| node_redis_client
node_redis_client -.->|"connects optionally"| node_redis

click node_desktop "https://github.com/engmohamadalagha/wasl-command-center/blob/main/electron/main.cjs"
click node_server "https://github.com/engmohamadalagha/wasl-command-center/blob/main/server.mjs"
click node_agent "https://github.com/engmohamadalagha/wasl-command-center/blob/main/agent.mjs"
click node_web_app "https://github.com/engmohamadalagha/wasl-command-center/blob/main/src/web/app.mjs"
click node_webhook "https://github.com/engmohamadalagha/wasl-command-center/blob/main/src/web/routes/webhook/index.mjs"
click node_webhook_process "https://github.com/engmohamadalagha/wasl-command-center/blob/main/src/web/routes/webhook/process.mjs"
click node_ai_handler "https://github.com/engmohamadalagha/wasl-command-center/blob/main/src/web/routes/webhook/handlers/ai.mjs"
click node_ai_engine "https://github.com/engmohamadalagha/wasl-command-center/blob/main/src/ai/engine.mjs"
click node_channel_send "https://github.com/engmohamadalagha/wasl-command-center/blob/main/src/channels/send.mjs"
click node_booking_handler "https://github.com/engmohamadalagha/wasl-command-center/blob/main/src/web/routes/webhook/handlers/booking.mjs"
click node_order_handler "https://github.com/engmohamadalagha/wasl-command-center/blob/main/src/web/routes/webhook/handlers/orders.mjs"
click node_receipt "https://github.com/engmohamadalagha/wasl-command-center/blob/main/src/media/paymentProof.mjs"
click node_admin_routes "https://github.com/engmohamadalagha/wasl-command-center/blob/main/src/web/routes/admin/index.mjs"
click node_inbox "https://github.com/engmohamadalagha/wasl-command-center/blob/main/src/inbox/service.mjs"
click node_templates "https://github.com/engmohamadalagha/wasl-command-center/blob/main/src/services/templateService.mjs"
click node_tenants "https://github.com/engmohamadalagha/wasl-command-center/blob/main/tenants.mjs"
click node_database "https://github.com/engmohamadalagha/wasl-command-center/blob/main/db.mjs"
click node_conversations "https://github.com/engmohamadalagha/wasl-command-center/blob/main/src/memory/conversations.mjs"
click node_store "https://github.com/engmohamadalagha/wasl-command-center/blob/main/store.mjs"
click node_queue "https://github.com/engmohamadalagha/wasl-command-center/blob/main/src/jobs/queue.mjs"
click node_redis_client "https://github.com/engmohamadalagha/wasl-command-center/blob/main/src/jobs/redisClient.mjs"
click node_channels "https://github.com/engmohamadalagha/wasl-command-center/blob/main/src/channels/registry.mjs"
click node_calendar "https://github.com/engmohamadalagha/wasl-command-center/blob/main/src/integrations/googleCalendar.mjs"
click node_crm "https://github.com/engmohamadalagha/wasl-command-center/blob/main/crm.mjs"

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_desktop,node_server,node_agent,node_web_app toneBlue
class node_webhook,node_webhook_process,node_ai_handler,node_ai_engine,node_channel_send,node_channels,node_postgres,node_redis toneAmber
class node_booking_handler,node_order_handler,node_receipt,node_calendar,node_crm toneMint
class node_admin_routes,node_inbox,node_templates toneRose
class node_tenants,node_database,node_conversations,node_store,node_queue,node_redis_client,node_customer,node_operator,node_meta,node_ai_provider toneIndigo
```

## Components

### Runtime and web

- [Desktop shell](https://github.com/engmohamadalagha/wasl-command-center/blob/main/electron/main.cjs): `electron/main.cjs`
- [Server bootstrap](https://github.com/engmohamadalagha/wasl-command-center/blob/main/server.mjs): `server.mjs`
- [Agent runtime](https://github.com/engmohamadalagha/wasl-command-center/blob/main/agent.mjs): `agent.mjs`
- [Web application](https://github.com/engmohamadalagha/wasl-command-center/blob/main/src/web/app.mjs): `src/web/app.mjs`

### Messaging and AI

- [Webhook routes](https://github.com/engmohamadalagha/wasl-command-center/blob/main/src/web/routes/webhook/index.mjs): `src/web/routes/webhook/index.mjs`
- [Webhook processing](https://github.com/engmohamadalagha/wasl-command-center/blob/main/src/web/routes/webhook/process.mjs): `src/web/routes/webhook/process.mjs`
- [AI handler](https://github.com/engmohamadalagha/wasl-command-center/blob/main/src/web/routes/webhook/handlers/ai.mjs): `src/web/routes/webhook/handlers/ai.mjs`
- [AI conversation engine](https://github.com/engmohamadalagha/wasl-command-center/blob/main/src/ai/engine.mjs): `src/ai/engine.mjs`
- [Channel sending](https://github.com/engmohamadalagha/wasl-command-center/blob/main/src/channels/send.mjs): `src/channels/send.mjs`
- [Channel adapters](https://github.com/engmohamadalagha/wasl-command-center/blob/main/src/channels/registry.mjs): `src/channels/registry.mjs`

### Business workflows

- [Booking handler](https://github.com/engmohamadalagha/wasl-command-center/blob/main/src/web/routes/webhook/handlers/booking.mjs): `src/web/routes/webhook/handlers/booking.mjs`
- [Order handler](https://github.com/engmohamadalagha/wasl-command-center/blob/main/src/web/routes/webhook/handlers/orders.mjs): `src/web/routes/webhook/handlers/orders.mjs`
- [Receipt verification](https://github.com/engmohamadalagha/wasl-command-center/blob/main/src/media/paymentProof.mjs): `src/media/paymentProof.mjs`
- [Google Calendar](https://github.com/engmohamadalagha/wasl-command-center/blob/main/src/integrations/googleCalendar.mjs): `src/integrations/googleCalendar.mjs`
- [CRM](https://github.com/engmohamadalagha/wasl-command-center/blob/main/crm.mjs): `crm.mjs`

### Management console

- [Admin routes](https://github.com/engmohamadalagha/wasl-command-center/blob/main/src/web/routes/admin/index.mjs): `src/web/routes/admin/index.mjs`
- [Inbox service](https://github.com/engmohamadalagha/wasl-command-center/blob/main/src/inbox/service.mjs): `src/inbox/service.mjs`
- [Template lifecycle](https://github.com/engmohamadalagha/wasl-command-center/blob/main/src/services/templateService.mjs): `src/services/templateService.mjs`

### State and integrations

- [Tenant configuration](https://github.com/engmohamadalagha/wasl-command-center/blob/main/tenants.mjs): `tenants.mjs`
- [Database access](https://github.com/engmohamadalagha/wasl-command-center/blob/main/db.mjs): `db.mjs`
- [Conversation memory](https://github.com/engmohamadalagha/wasl-command-center/blob/main/src/memory/conversations.mjs): `src/memory/conversations.mjs`
- [Key-value store](https://github.com/engmohamadalagha/wasl-command-center/blob/main/store.mjs): `store.mjs`
- [Job queues](https://github.com/engmohamadalagha/wasl-command-center/blob/main/src/jobs/queue.mjs): `src/jobs/queue.mjs`
- [Redis client](https://github.com/engmohamadalagha/wasl-command-center/blob/main/src/jobs/redisClient.mjs): `src/jobs/redisClient.mjs`

### Other components

- **WhatsApp customer**
- **Business operator**
- **Meta WhatsApp**
- **AI provider**
- **PostgreSQL**
- **Redis**

## Connections

- Desktop shell → Server bootstrap: starts backend
- Server bootstrap → Agent runtime: starts runtime
- WhatsApp customer → Meta WhatsApp: sends message
- Meta WhatsApp → Webhook routes: posts webhook
- Webhook routes → Webhook processing: dispatches processing
- Webhook processing → AI handler: dispatches AI
- Webhook processing → Booking handler: dispatches bookings
- Webhook processing → Order handler: dispatches orders
- AI handler → AI conversation engine: requests reply
- AI conversation engine → Tenant configuration: resolves tenant
- AI conversation engine → Conversation memory: reads and writes history
- AI conversation engine → AI provider: requests completion
- AI conversation engine → Channel adapters: returns reply for sending
- Channel adapters → Channel sending: selects sender
- Channel sending → Meta WhatsApp: sends message
- Booking handler → Google Calendar: calendar integration
- Order handler → Receipt verification: handles receipt image
- Receipt verification → Meta WhatsApp: downloads media
- Receipt verification → CRM: logs payment event
- Business operator → Admin routes: manages business
- Admin routes → Inbox service: uses inbox service
- Admin routes → Template lifecycle: manages templates
- Inbox service → Conversation memory: reads conversation
- Inbox service → Key-value store: reads takeover state
- Inbox service → Database access: queries messages
- Template lifecycle → Database access: scoped template access
- Template lifecycle → Meta WhatsApp: submits and syncs templates
- Web application → Database access: checks database health
- Database access → PostgreSQL: queries
- Job queues → Redis client: requests Redis
- Redis client → Redis: connects optionally
