# mubashir-786/n8n-whatsapp-automation architecture

> Architecture diagram of the GitHub repository mubashir-786/n8n-whatsapp-automation, 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/mubashir-786/n8n-whatsapp-automation
- Repository: https://github.com/mubashir-786/n8n-whatsapp-automation

## Overview

This is a WhatsApp ordering service backed by an Express API, SQLite, and an optional n8n workflow. Customers send menu, order, confirmation, and tracking messages through WhatsApp; the webhook hands messages to the processor, which looks up products or orders, persists customer and order state, and sends replies. Separate API routes provide customer and order administration, while the README documents additional n8n menu, parser, creator, tracker, and response workflow capabilities. The workflow JSON and public page were not sampled, so their internal connections are not asserted.

Main entry points: [`database/orders.db`](https://github.com/mubashir-786/n8n-whatsapp-automation/blob/master/database/orders.db) (SQLite records), [`routes/webhook.js`](https://github.com/mubashir-786/n8n-whatsapp-automation/blob/master/routes/webhook.js) (Message webhook), [`services/orderProcessor.js`](https://github.com/mubashir-786/n8n-whatsapp-automation/blob/master/services/orderProcessor.js) (Message processor), [`server.js`](https://github.com/mubashir-786/n8n-whatsapp-automation/blob/master/server.js) (HTTP server)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ingress["Message ingress"]
  node_server["HTTP server<br/>[server.js]"]
  node_webhook["Message webhook<br/>[webhook.js]"]
  node_n8nservice["n8n webhook service<br/>[webhook.js]"]
end

subgraph group_ordering["Order lifecycle"]
  node_processor["Message processor<br/>[orderProcessor.js]"]
  node_menu["Menu delivery<br/>[whatsappService.js]"]
end

subgraph group_api["Management API"]
  node_orderapi["Order endpoints<br/>[orders.js]"]
  node_customerapi["Customer endpoints<br/>[customers.js]"]
end

subgraph group_persistence["Persistence and integrations"]
  node_databaseinit["SQLite initialization<br/>[init.js]"]
  node_sqlite[("SQLite records<br/>[orders.db]")]
end

node_customer(("WhatsApp customer"))
node_whatsapp{{"WhatsApp Business API"}}
node_n8n["n8n workflow"]

node_customer -->|"sends messages"| node_whatsapp
node_whatsapp -->|"posts messages"| node_webhook
node_server -->|"mounts route"| node_webhook
node_webhook -->|"processes message"| node_processor
node_webhook -->|"records inbound"| node_sqlite
node_processor -->|"requests menu"| node_menu
node_menu -->|"reads products"| node_sqlite
node_processor -->|"reads and writes"| node_sqlite
node_processor -->|"sends replies"| node_whatsapp
node_menu -->|"sends menu"| node_whatsapp
node_server -->|"mounts route"| node_orderapi
node_server -->|"mounts route"| node_customerapi
node_orderapi -->|"reads and writes"| node_sqlite
node_customerapi -->|"reads and writes"| node_sqlite
node_databaseinit -->|"initializes schema"| node_sqlite
node_webhook -->|"triggers optionally"| node_n8nservice
node_n8nservice -.->|"posts event"| node_n8n
node_n8n -.->|"sends responses"| node_whatsapp

click node_server "https://github.com/mubashir-786/n8n-whatsapp-automation/blob/master/server.js"
click node_webhook "https://github.com/mubashir-786/n8n-whatsapp-automation/blob/master/routes/webhook.js"
click node_processor "https://github.com/mubashir-786/n8n-whatsapp-automation/blob/master/services/orderProcessor.js"
click node_menu "https://github.com/mubashir-786/n8n-whatsapp-automation/blob/master/services/whatsappService.js"
click node_orderapi "https://github.com/mubashir-786/n8n-whatsapp-automation/blob/master/routes/orders.js"
click node_customerapi "https://github.com/mubashir-786/n8n-whatsapp-automation/blob/master/routes/customers.js"
click node_n8n "https://github.com/mubashir-786/n8n-whatsapp-automation/blob/master/n8n-workflows/whatsapp-order-automation.json"
click node_databaseinit "https://github.com/mubashir-786/n8n-whatsapp-automation/blob/master/database/init.js"
click node_sqlite "https://github.com/mubashir-786/n8n-whatsapp-automation/blob/master/database/orders.db"
click node_n8nservice "https://github.com/mubashir-786/n8n-whatsapp-automation/blob/master/routes/webhook.js"

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_server,node_webhook,node_n8nservice toneBlue
class node_processor,node_menu toneAmber
class node_orderapi,node_customerapi,node_whatsapp toneMint
class node_databaseinit,node_sqlite toneRose
class node_customer toneIndigo
class node_n8n toneTeal
```

## Components

### Message ingress

- [HTTP server](https://github.com/mubashir-786/n8n-whatsapp-automation/blob/master/server.js): `server.js`
- [Message webhook](https://github.com/mubashir-786/n8n-whatsapp-automation/blob/master/routes/webhook.js): `routes/webhook.js`
- [n8n webhook service](https://github.com/mubashir-786/n8n-whatsapp-automation/blob/master/routes/webhook.js): `routes/webhook.js`

### Order lifecycle

- [Message processor](https://github.com/mubashir-786/n8n-whatsapp-automation/blob/master/services/orderProcessor.js): `services/orderProcessor.js`
- [Menu delivery](https://github.com/mubashir-786/n8n-whatsapp-automation/blob/master/services/whatsappService.js): `services/whatsappService.js`

### Management API

- [Order endpoints](https://github.com/mubashir-786/n8n-whatsapp-automation/blob/master/routes/orders.js): `routes/orders.js`
- [Customer endpoints](https://github.com/mubashir-786/n8n-whatsapp-automation/blob/master/routes/customers.js): `routes/customers.js`

### Persistence and integrations

- [SQLite initialization](https://github.com/mubashir-786/n8n-whatsapp-automation/blob/master/database/init.js): `database/init.js`
- [SQLite records](https://github.com/mubashir-786/n8n-whatsapp-automation/blob/master/database/orders.db): `database/orders.db`

### Other components

- **WhatsApp customer**
- **WhatsApp Business API**
- [n8n workflow](https://github.com/mubashir-786/n8n-whatsapp-automation/blob/master/n8n-workflows/whatsapp-order-automation.json): `n8n-workflows/whatsapp-order-automation.json`

## Connections

- WhatsApp customer → WhatsApp Business API: sends messages (evidence: `README.md`)
- WhatsApp Business API → Message webhook: posts messages (evidence: `README.md`)
- HTTP server → Message webhook: mounts route (evidence: `server.js`)
- Message webhook → Message processor: processes message (evidence: `routes/webhook.js`)
- Message webhook → SQLite records: records inbound (evidence: `routes/webhook.js`)
- Message processor → Menu delivery: requests menu (evidence: `services/orderProcessor.js`)
- Menu delivery → SQLite records: reads products (evidence: `services/whatsappService.js`)
- Message processor → SQLite records: reads and writes (evidence: `services/orderProcessor.js`)
- Message processor → WhatsApp Business API: sends replies (evidence: `services/orderProcessor.js`)
- Menu delivery → WhatsApp Business API: sends menu (evidence: `services/whatsappService.js`)
- HTTP server → Order endpoints: mounts route (evidence: `server.js`)
- HTTP server → Customer endpoints: mounts route (evidence: `server.js`)
- Order endpoints → SQLite records: reads and writes (evidence: `routes/orders.js`)
- Customer endpoints → SQLite records: reads and writes (evidence: `routes/customers.js`)
- SQLite initialization → SQLite records: initializes schema (evidence: `database/init.js`)
- Message webhook → n8n webhook service: triggers optionally (evidence: `routes/webhook.js`)
- n8n webhook service → n8n workflow: posts event (evidence: `routes/webhook.js`)
- n8n workflow → WhatsApp Business API: sends responses (evidence: `README.md`)
