๐๏ธ 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โ
- Page Requests โ GET to
/inbox,/contacts, etc. โ loads HTML + JS - API Requests โ GET/POST/PATCH/DELETE to
/api/...โ returns JSON - Webhook Requests โ POST from providers to
/webhooks/{type}/{id}โ processes inbound messages - 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