Skip to main content

๐Ÿ—๏ธ How PulseHub Works

PulseHub is a classic MVC (Model-View-Controller) web application with a flat, readable structure. There is no framework โ€” routing, database access, authentication, and rendering are all implemented directly in PHP.

Browser / Channel Provider
โ”‚
โ–ผ
index.php โ† Front controller
โ”‚
โ–ผ
app/router.php โ† URL โ†’ [Controller, method]
โ”‚
โ–ผ
app/Controllers/ โ† Business logic
โ”‚
โ”Œโ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ–ผ โ–ผ
app/Views/ app/Helpers/db.php
(HTML templates) (PDO MySQL queries)

The Four Request Typesโ€‹

  1. Page Requests โ€” GET to /inbox, /contacts, etc. โ†’ loads HTML + JS
  2. API Requests โ€” GET/POST/PATCH/DELETE to /api/... โ†’ returns JSON
  3. Webhook Requests โ€” POST from providers to /webhooks/{type}/{id} โ†’ processes inbound messages
  4. SSE Stream โ€” persistent connection to /sse โ†’ pushes real-time events to browser

Data Flow: Inbound Messageโ€‹

1. Customer sends message on WhatsApp
2. Meta POSTs to /webhooks/whatsapp/{channel_id}
3. WebhookController verifies signature, normalizes payload
4. Finds/creates contact, finds/creates conversation
5. Saves message, fires SSE events, queues automation events
6. Returns 200 to Meta
7. SSE pushes to all connected agent browsers within 2 seconds

Data Flow: Outbound Messageโ€‹

1. Agent types reply and clicks Send
2. Browser POSTs to /api/conversations/{id}/messages
3. Saves message, calls channel API (WhatsApp, Twilio, etc.)
4. Pushes SSE event to other agents
5. Returns 201