# hamza92ra/repliq architecture

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

- Interactive diagram: https://gitdiagram.com/hamza92ra/repliq
- Repository: https://github.com/hamza92ra/repliq

## Overview

RepliQ is a WhatsApp customer-support and lead-management bot. Its main workflow receives a Meta webhook, handles incoming text or voice messages, uses AI to draft a reply, records the conversation, and sends the response through WhatsApp. Separate dashboard and signup flows support human takeover, business prompt configuration, order tracking, and lead follow-up. The sampled webhook excerpt omits some processing, so links for order creation and AI replies reflect the documented and imported responsibilities; other uncertain wiring is not shown.

Main entry points: [`api/webhook.js`](https://github.com/hamza92ra/repliq/blob/main/api/webhook.js) (Message webhook), [`lib/db.js`](https://github.com/hamza92ra/repliq/blob/main/lib/db.js) (Conversation store), [`api/lead.js`](https://github.com/hamza92ra/repliq/blob/main/api/lead.js) (Lead intake), [`lib/whatsapp.js`](https://github.com/hamza92ra/repliq/blob/main/lib/whatsapp.js) (WhatsApp client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_messaging["WhatsApp messaging"]
  node_webhook["Message webhook<br/>[webhook.js]"]
  node_whatsapp["WhatsApp client<br/>[whatsapp.js]"]
  node_ai["AI and audio<br/>[ai.js]"]
end

subgraph group_operations["Conversation operations"]
  node_conversations["Conversation API<br/>[conversation.js]"]
  node_db["Conversation store<br/>[db.js]"]
  node_dashboard_ui["Operations dashboard<br/>[dashboard.html]"]
  node_dashboard_api["Dashboard API<br/>[dashboard.js]"]
  node_config_api["Business config API<br/>[business-config.js]"]
end

subgraph group_sales["Lead and orders"]
  node_lead_form["Signup form<br/>[formulaire.html]"]
  node_lead_api["Lead intake<br/>[lead.js]"]
  node_notify["Team notification<br/>[notify.js]"]
  node_orders_api["Orders API<br/>[orders.js]"]
  node_orders["Order store<br/>[orders.js]"]
end

subgraph group_integrations["External services"]
  node_meta["Meta WhatsApp"]
  node_ai_provider["Groq AI"]
  node_redis[("Upstash Redis")]
  node_resend["Resend email"]
end

node_customer(("Customer"))

node_customer -->|"sends message"| node_meta
node_meta -->|"posts event"| node_webhook
node_webhook -->|"handles media"| node_whatsapp
node_webhook -->|"requests reply or transcription"| node_ai
node_webhook -->|"reads and records"| node_db
node_webhook -->|"creates order"| node_orders
node_ai -->|"requests inference"| node_ai_provider
node_whatsapp -->|"sends and retrieves"| node_meta
node_webhook -->|"sends reply"| node_whatsapp
node_webhook -->|"replies via WhatsApp"| node_customer
node_dashboard_ui -->|"loads conversations"| node_dashboard_api
node_dashboard_ui -->|"manages conversations"| node_conversations
node_dashboard_ui -->|"views and updates orders"| node_orders_api
node_dashboard_ui -->|"configures business"| node_config_api
node_dashboard_api -->|"lists conversations"| node_db
node_conversations -->|"reads and updates"| node_db
node_conversations -->|"sends agent reply"| node_whatsapp
node_config_api -->|"reads and saves config"| node_db
node_lead_form -->|"submits signup"| node_lead_api
node_lead_api -->|"records lead"| node_db
node_lead_api -->|"sends confirmation"| node_whatsapp
node_lead_api -->|"requests alert"| node_notify
node_notify -.->|"sends email"| node_resend
node_lead_api -->|"confirms via WhatsApp"| node_customer
node_orders_api -->|"lists and updates"| node_orders
node_db -->|"reads and writes"| node_redis
node_orders -->|"reads and writes"| node_redis

click node_webhook "https://github.com/hamza92ra/repliq/blob/main/api/webhook.js"
click node_whatsapp "https://github.com/hamza92ra/repliq/blob/main/lib/whatsapp.js"
click node_ai "https://github.com/hamza92ra/repliq/blob/main/lib/ai.js"
click node_conversations "https://github.com/hamza92ra/repliq/blob/main/api/conversation.js"
click node_db "https://github.com/hamza92ra/repliq/blob/main/lib/db.js"
click node_dashboard_ui "https://github.com/hamza92ra/repliq/blob/main/dashboard.html"
click node_dashboard_api "https://github.com/hamza92ra/repliq/blob/main/api/dashboard.js"
click node_config_api "https://github.com/hamza92ra/repliq/blob/main/api/business-config.js"
click node_lead_form "https://github.com/hamza92ra/repliq/blob/main/formulaire.html"
click node_lead_api "https://github.com/hamza92ra/repliq/blob/main/api/lead.js"
click node_notify "https://github.com/hamza92ra/repliq/blob/main/lib/notify.js"
click node_orders_api "https://github.com/hamza92ra/repliq/blob/main/api/orders.js"
click node_orders "https://github.com/hamza92ra/repliq/blob/main/lib/orders.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_webhook,node_whatsapp,node_ai toneBlue
class node_conversations,node_db,node_dashboard_ui,node_dashboard_api,node_config_api toneAmber
class node_lead_form,node_lead_api,node_notify,node_orders_api,node_orders toneMint
class node_meta,node_ai_provider,node_redis,node_resend toneRose
class node_customer toneIndigo
```

## Components

### WhatsApp messaging

- [Message webhook](https://github.com/hamza92ra/repliq/blob/main/api/webhook.js): `api/webhook.js`
- [WhatsApp client](https://github.com/hamza92ra/repliq/blob/main/lib/whatsapp.js): `lib/whatsapp.js`
- [AI and audio](https://github.com/hamza92ra/repliq/blob/main/lib/ai.js): `lib/ai.js`

### Conversation operations

- [Conversation API](https://github.com/hamza92ra/repliq/blob/main/api/conversation.js): `api/conversation.js`
- [Conversation store](https://github.com/hamza92ra/repliq/blob/main/lib/db.js): `lib/db.js`
- [Operations dashboard](https://github.com/hamza92ra/repliq/blob/main/dashboard.html): `dashboard.html`
- [Dashboard API](https://github.com/hamza92ra/repliq/blob/main/api/dashboard.js): `api/dashboard.js`
- [Business config API](https://github.com/hamza92ra/repliq/blob/main/api/business-config.js): `api/business-config.js`

### Lead and orders

- [Signup form](https://github.com/hamza92ra/repliq/blob/main/formulaire.html): `formulaire.html`
- [Lead intake](https://github.com/hamza92ra/repliq/blob/main/api/lead.js): `api/lead.js`
- [Team notification](https://github.com/hamza92ra/repliq/blob/main/lib/notify.js): `lib/notify.js`
- [Orders API](https://github.com/hamza92ra/repliq/blob/main/api/orders.js): `api/orders.js`
- [Order store](https://github.com/hamza92ra/repliq/blob/main/lib/orders.js): `lib/orders.js`

### External services

- **Meta WhatsApp**
- **Groq AI**
- **Upstash Redis**
- **Resend email**

### Other components

- **Customer**

## Connections

- Customer → Meta WhatsApp: sends message
- Meta WhatsApp → Message webhook: posts event
- Message webhook → WhatsApp client: handles media
- Message webhook → AI and audio: requests reply or transcription
- Message webhook → Conversation store: reads and records
- Message webhook → Order store: creates order
- AI and audio → Groq AI: requests inference
- WhatsApp client → Meta WhatsApp: sends and retrieves
- Message webhook → WhatsApp client: sends reply
- Message webhook → Customer: replies via WhatsApp
- Operations dashboard → Dashboard API: loads conversations
- Operations dashboard → Conversation API: manages conversations
- Operations dashboard → Orders API: views and updates orders
- Operations dashboard → Business config API: configures business
- Dashboard API → Conversation store: lists conversations
- Conversation API → Conversation store: reads and updates
- Conversation API → WhatsApp client: sends agent reply
- Business config API → Conversation store: reads and saves config
- Signup form → Lead intake: submits signup
- Lead intake → Conversation store: records lead
- Lead intake → WhatsApp client: sends confirmation
- Lead intake → Team notification: requests alert
- Team notification → Resend email: sends email
- Lead intake → Customer: confirms via WhatsApp
- Orders API → Order store: lists and updates
- Conversation store → Upstash Redis: reads and writes
- Order store → Upstash Redis: reads and writes
