# samuelklausfischer-rgb/central-whatsapp architecture

> Architecture diagram of the GitHub repository samuelklausfischer-rgb/central-whatsapp, 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/samuelklausfischer-rgb/central-whatsapp
- Repository: https://github.com/samuelklausfischer-rgb/central-whatsapp

## Overview

Central Whats is a team WhatsApp service desk with web and Electron clients sharing a React application. The principal workflow is an authenticated agent entering the chat hub, working conversations, and sending or receiving messages through Supabase Edge Functions and Evolution API. The repository also exposes email, campaigns, scheduling, analytics, and hosted business tools. Edges reflect the README’s stated backend boundary and sampled webhook/worker behavior; unsampled page-to-service wiring is left out.

Main entry points: [`src/lib/supabase/client.ts`](https://github.com/samuelklausfischer-rgb/central-whatsapp/blob/main/src/lib/supabase/client.ts) (Supabase services), [`src/App.tsx`](https://github.com/samuelklausfischer-rgb/central-whatsapp/blob/main/src/App.tsx) (App routes), [`src/pages/ChatHub.tsx`](https://github.com/samuelklausfischer-rgb/central-whatsapp/blob/main/src/pages/ChatHub.tsx) (Chat hub), [`worker/src/engine.ts`](https://github.com/samuelklausfischer-rgb/central-whatsapp/blob/main/worker/src/engine.ts) (Campaign worker)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Client application"]
  node_app["App routes<br/>[App.tsx]"]
  node_auth["Authentication<br/>[use-auth.tsx]"]
end

subgraph group_messaging["WhatsApp operations"]
  node_chat["Chat hub<br/>[ChatHub.tsx]"]
  node_messages["Message services<br/>[messages.ts]"]
  node_attachments["Attachment storage<br/>[storage.ts]"]
  node_sendfn["Message function<br/>[index.ts]"]
  node_webhook["Inbound webhook<br/>[index.ts]"]
  node_pbhook["Legacy webhook hook"]
  node_worker["Campaign worker<br/>[engine.ts]"]
  node_campaigns["Bulk campaigns"]
end

subgraph group_communications["Other communications"]
  node_email["Email hub<br/>[EmailHub.tsx]"]
  node_emailfn["Email functions<br/>[index.ts]"]
  node_schedule["Scheduled messages"]
  node_agenda["Agenda<br/>[Agenda.tsx]"]
end

subgraph group_business["Business tools"]
  node_dashboard["Service dashboard<br/>[Index.tsx]"]
  node_prn["PRN analysis<br/>[AnalisePrn.tsx]"]
  node_prnservice["PRN processing<br/>[prn-service.ts]"]
  node_tools["Hosted tools"]
end

subgraph group_backend["Backend and state"]
  node_supabase["Supabase services<br/>[client.ts]"]
  node_database[("Supabase data")]
  node_edge["Edge functions"]
  node_evolution["Evolution API"]
  node_pocketbase[("PocketBase")]
  node_mcp["Evolution MCP<br/>[index.ts]"]
end

node_agent(("Support agent"))

node_agent -->|"uses"| node_app
node_app -->|"provides auth"| node_auth
node_app -->|"routes to"| node_chat
node_chat -->|"works with"| node_messages
node_messages -->|"uses"| node_supabase
node_supabase -->|"reads and writes"| node_database
node_chat -->|"uploads media"| node_attachments
node_attachments -->|"stores files"| node_supabase
node_sendfn -->|"sends messages"| node_evolution
node_webhook -->|"uses backend"| node_supabase
node_pbhook -->|"writes contacts/messages"| node_pocketbase
node_campaigns -->|"campaign sending"| node_worker
node_worker -->|"leases and updates targets"| node_supabase
node_worker -->|"sends messages"| node_evolution
node_email -->|"uses backend"| node_supabase
node_emailfn -->|"uses backend"| node_supabase
node_schedule -->|"uses backend"| node_supabase
node_agenda -->|"uses backend"| node_supabase
node_dashboard -->|"uses backend"| node_supabase
node_prn -->|"submits analysis"| node_prnservice
node_prnservice -->|"records runs"| node_supabase
node_prnservice -->|"uses proxy"| node_edge
node_tools -->|"checks tool access"| node_supabase
node_mcp -.->|"calls API"| node_evolution

click node_app "https://github.com/samuelklausfischer-rgb/central-whatsapp/blob/main/src/App.tsx"
click node_auth "https://github.com/samuelklausfischer-rgb/central-whatsapp/blob/main/src/hooks/use-auth.tsx"
click node_chat "https://github.com/samuelklausfischer-rgb/central-whatsapp/blob/main/src/pages/ChatHub.tsx"
click node_messages "https://github.com/samuelklausfischer-rgb/central-whatsapp/blob/main/src/services/messages.ts"
click node_attachments "https://github.com/samuelklausfischer-rgb/central-whatsapp/blob/main/src/services/storage.ts"
click node_sendfn "https://github.com/samuelklausfischer-rgb/central-whatsapp/blob/main/supabase/functions/send-message/index.ts"
click node_webhook "https://github.com/samuelklausfischer-rgb/central-whatsapp/blob/main/supabase/functions/evolution-webhook/index.ts"
click node_pbhook "https://github.com/samuelklausfischer-rgb/central-whatsapp/blob/main/pocketbase/hooks/evolution_webhook.js"
click node_worker "https://github.com/samuelklausfischer-rgb/central-whatsapp/blob/main/worker/src/engine.ts"
click node_campaigns "https://github.com/samuelklausfischer-rgb/central-whatsapp/blob/main/src/pages/tools/DisparadorEmMassa.tsx"
click node_email "https://github.com/samuelklausfischer-rgb/central-whatsapp/blob/main/src/pages/EmailHub.tsx"
click node_emailfn "https://github.com/samuelklausfischer-rgb/central-whatsapp/blob/main/supabase/functions/email-send/index.ts"
click node_schedule "https://github.com/samuelklausfischer-rgb/central-whatsapp/blob/main/src/pages/ScheduledMessages.tsx"
click node_agenda "https://github.com/samuelklausfischer-rgb/central-whatsapp/blob/main/src/pages/Agenda.tsx"
click node_dashboard "https://github.com/samuelklausfischer-rgb/central-whatsapp/blob/main/src/pages/Index.tsx"
click node_prn "https://github.com/samuelklausfischer-rgb/central-whatsapp/blob/main/src/pages/tools/AnalisePrn.tsx"
click node_prnservice "https://github.com/samuelklausfischer-rgb/central-whatsapp/blob/main/src/services/prn-analise/prn-service.ts"
click node_tools "https://github.com/samuelklausfischer-rgb/central-whatsapp/blob/main/src/components/tools/FerramentaHospedada.tsx"
click node_supabase "https://github.com/samuelklausfischer-rgb/central-whatsapp/blob/main/src/lib/supabase/client.ts"
click node_edge "https://github.com/samuelklausfischer-rgb/central-whatsapp/tree/main/supabase/functions"
click node_mcp "https://github.com/samuelklausfischer-rgb/central-whatsapp/blob/main/evolution-api-mcp/src/index.ts"

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_app,node_auth toneBlue
class node_chat,node_messages,node_attachments,node_sendfn,node_webhook,node_pbhook,node_worker,node_campaigns toneAmber
class node_email,node_emailfn,node_schedule,node_agenda toneMint
class node_dashboard,node_prn,node_prnservice,node_tools toneRose
class node_supabase,node_database,node_edge,node_evolution,node_pocketbase,node_mcp,node_agent toneIndigo
```

## Components

### Client application

- [App routes](https://github.com/samuelklausfischer-rgb/central-whatsapp/blob/main/src/App.tsx): `src/App.tsx`
- [Authentication](https://github.com/samuelklausfischer-rgb/central-whatsapp/blob/main/src/hooks/use-auth.tsx): `src/hooks/use-auth.tsx`

### WhatsApp operations

- [Chat hub](https://github.com/samuelklausfischer-rgb/central-whatsapp/blob/main/src/pages/ChatHub.tsx): `src/pages/ChatHub.tsx`
- [Message services](https://github.com/samuelklausfischer-rgb/central-whatsapp/blob/main/src/services/messages.ts): `src/services/messages.ts`
- [Attachment storage](https://github.com/samuelklausfischer-rgb/central-whatsapp/blob/main/src/services/storage.ts): `src/services/storage.ts`
- [Message function](https://github.com/samuelklausfischer-rgb/central-whatsapp/blob/main/supabase/functions/send-message/index.ts): `supabase/functions/send-message/index.ts`
- [Inbound webhook](https://github.com/samuelklausfischer-rgb/central-whatsapp/blob/main/supabase/functions/evolution-webhook/index.ts): `supabase/functions/evolution-webhook/index.ts`
- [Legacy webhook hook](https://github.com/samuelklausfischer-rgb/central-whatsapp/blob/main/pocketbase/hooks/evolution_webhook.js): `pocketbase/hooks/evolution_webhook.js`
- [Campaign worker](https://github.com/samuelklausfischer-rgb/central-whatsapp/blob/main/worker/src/engine.ts): `worker/src/engine.ts`
- [Bulk campaigns](https://github.com/samuelklausfischer-rgb/central-whatsapp/blob/main/src/pages/tools/DisparadorEmMassa.tsx): `src/pages/tools/DisparadorEmMassa.tsx`

### Other communications

- [Email hub](https://github.com/samuelklausfischer-rgb/central-whatsapp/blob/main/src/pages/EmailHub.tsx): `src/pages/EmailHub.tsx`
- [Email functions](https://github.com/samuelklausfischer-rgb/central-whatsapp/blob/main/supabase/functions/email-send/index.ts): `supabase/functions/email-send/index.ts`
- [Scheduled messages](https://github.com/samuelklausfischer-rgb/central-whatsapp/blob/main/src/pages/ScheduledMessages.tsx): `src/pages/ScheduledMessages.tsx`
- [Agenda](https://github.com/samuelklausfischer-rgb/central-whatsapp/blob/main/src/pages/Agenda.tsx): `src/pages/Agenda.tsx`

### Business tools

- [Service dashboard](https://github.com/samuelklausfischer-rgb/central-whatsapp/blob/main/src/pages/Index.tsx): `src/pages/Index.tsx`
- [PRN analysis](https://github.com/samuelklausfischer-rgb/central-whatsapp/blob/main/src/pages/tools/AnalisePrn.tsx): `src/pages/tools/AnalisePrn.tsx`
- [PRN processing](https://github.com/samuelklausfischer-rgb/central-whatsapp/blob/main/src/services/prn-analise/prn-service.ts): `src/services/prn-analise/prn-service.ts`
- [Hosted tools](https://github.com/samuelklausfischer-rgb/central-whatsapp/blob/main/src/components/tools/FerramentaHospedada.tsx): `src/components/tools/FerramentaHospedada.tsx`

### Backend and state

- [Supabase services](https://github.com/samuelklausfischer-rgb/central-whatsapp/blob/main/src/lib/supabase/client.ts): `src/lib/supabase/client.ts`
- **Supabase data**
- [Edge functions](https://github.com/samuelklausfischer-rgb/central-whatsapp/tree/main/supabase/functions): `supabase/functions`
- **Evolution API**
- **PocketBase**
- [Evolution MCP](https://github.com/samuelklausfischer-rgb/central-whatsapp/blob/main/evolution-api-mcp/src/index.ts): `evolution-api-mcp/src/index.ts`

### Other components

- **Support agent**

## Connections

- Support agent → App routes: uses
- App routes → Authentication: provides auth
- App routes → Chat hub: routes to
- Chat hub → Message services: works with
- Message services → Supabase services: uses
- Supabase services → Supabase data: reads and writes
- Chat hub → Attachment storage: uploads media
- Attachment storage → Supabase services: stores files
- Message function → Evolution API: sends messages
- Inbound webhook → Supabase services: uses backend
- Legacy webhook hook → PocketBase: writes contacts/messages
- Bulk campaigns → Campaign worker: campaign sending
- Campaign worker → Supabase services: leases and updates targets
- Campaign worker → Evolution API: sends messages
- Email hub → Supabase services: uses backend
- Email functions → Supabase services: uses backend
- Scheduled messages → Supabase services: uses backend
- Agenda → Supabase services: uses backend
- Service dashboard → Supabase services: uses backend
- PRN analysis → PRN processing: submits analysis
- PRN processing → Supabase services: records runs
- PRN processing → Edge functions: uses proxy
- Hosted tools → Supabase services: checks tool access
- Evolution MCP → Evolution API: calls API
