# luciano-watanabe/canal_comunicacao architecture

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

- Interactive diagram: https://gitdiagram.com/luciano-watanabe/canal_comunicacao
- Repository: https://github.com/luciano-watanabe/canal_comunicacao

## Overview

Canal de Comunicação is a WhatsApp customer-service and sales-prospecting system. Staff use its protected dashboard to manage conversations, customers, SAC triage, campaigns and sales operations; the backend exposes these capabilities through HTTP routes, realtime sockets and background services, with Oracle-backed state and WhatsApp/AI/geolocation integrations. The graph preserves documented product branches even where their implementation was not sampled. Edges are limited to relationships visible in excerpts, the source index or README; unsampled route internals are not inferred.

Main entry points: [`frontend/src/App.tsx`](https://github.com/luciano-watanabe/canal_comunicacao/blob/main/frontend/src/App.tsx) (Protected dashboard), [`backend/src/server.js`](https://github.com/luciano-watanabe/canal_comunicacao/blob/main/backend/src/server.js) (HTTP and socket server), [`backend/src/routes/clientes.js`](https://github.com/luciano-watanabe/canal_comunicacao/blob/main/backend/src/routes/clientes.js) (Customer API), [`frontend/src/pages/Chat.tsx`](https://github.com/luciano-watanabe/canal_comunicacao/blob/main/frontend/src/pages/Chat.tsx) (Chat workspace)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["Staff interface"]
  node_app["Protected dashboard<br/>[App.tsx]"]
  node_chatui["Chat workspace<br/>[Chat.tsx]"]
  node_customerui["Customer management<br/>[Clientes.tsx]"]
  node_sacui["SAC console<br/>[SAC.tsx]"]
  node_settingsui["System settings<br/>[Configuracoes.tsx]"]
  node_campaignui["Campaigns<br/>[Campanhas.tsx]"]
  node_dashboardui["Analytics dashboard<br/>[Dashboard.tsx]"]
  node_searchui["Price research<br/>[PesquisaPrecos.tsx]"]
  node_routesui["Sales routes<br/>[Rotas.tsx]"]
  node_reactivationui["Customer reactivation<br/>[Reativacao.tsx]"]
  node_socket["Realtime client<br/>[SocketContext.tsx]"]
  node_privacy["Privacy masking<br/>[PrivacyContext.tsx]"]
  node_cart["Order cart<br/>[CartContext.tsx]"]
end

subgraph group_service["Messaging and SAC"]
  node_botservice["SAC bot<br/>[SacBotService.js]"]
  node_messagecache["Bot message service"]
  node_webhook["Evolution webhook"]
  node_nativehook["Native webhook receiver"]
end

subgraph group_sales["Sales operations"]
  node_salesfeatures["Sales and prospecting features"]
end

subgraph group_backend["Backend platform"]
  node_server["HTTP and socket server<br/>[server.js]"]
  node_customerapi["Customer API<br/>[clientes.js]"]
  node_chatapi["Chat API<br/>[chat.js]"]
  node_sacapi["SAC API<br/>[sac.js]"]
  node_productroutes["Sales APIs"]
end

subgraph group_data["Data and integrations"]
  node_oraclepool["Oracle connection pool<br/>[oraclePool.js]"]
  node_oracle[("Oracle database")]
  node_evolution["Evolution API"]
  node_ai["Grok and Groq"]
  node_geo["Geolocation providers"]
end

node_staff(("Staff user"))

node_staff -->|"uses"| node_app
node_app -->|"routes to"| node_chatui
node_app -->|"routes to"| node_customerui
node_app -->|"routes to"| node_sacui
node_app -->|"routes to"| node_settingsui
node_app -->|"routes to"| node_campaignui
node_app -->|"routes to"| node_dashboardui
node_app -->|"routes to"| node_searchui
node_app -->|"routes to"| node_routesui
node_app -->|"routes to"| node_reactivationui
node_app -->|"provides"| node_socket
node_app -->|"provides"| node_privacy
node_app -->|"provides"| node_cart
node_customerui -->|"masks data"| node_privacy
node_customerui -->|"requests"| node_customerapi
node_server -->|"mounts"| node_customerapi
node_server -->|"mounts"| node_chatapi
node_server -->|"mounts"| node_sacapi
node_server -->|"mounts"| node_productroutes
node_server -->|"mounts route"| node_webhook
node_webhook -->|"emits events"| node_socket
node_server -->|"initializes"| node_oraclepool
node_server -->|"loads and refreshes"| node_messagecache
node_nativehook -->|"acquires connection"| node_oraclepool
node_oraclepool -->|"opens pooled connections"| node_oracle
node_customerapi -->|"queries customer data"| node_oracle
node_customerapi -->|"reads cache"| node_messagecache
node_botservice -->|"uses messages"| node_messagecache
node_chatui -->|"uses realtime"| node_socket
node_chatui -->|"uses cart"| node_cart
node_campaignui -.->|"sends WhatsApp"| node_evolution
node_botservice -.->|"suggests responses"| node_ai
node_salesfeatures -.->|"geocodes addresses"| node_geo

click node_app "https://github.com/luciano-watanabe/canal_comunicacao/blob/main/frontend/src/App.tsx"
click node_chatui "https://github.com/luciano-watanabe/canal_comunicacao/blob/main/frontend/src/pages/Chat.tsx"
click node_customerui "https://github.com/luciano-watanabe/canal_comunicacao/blob/main/frontend/src/pages/Clientes.tsx"
click node_sacui "https://github.com/luciano-watanabe/canal_comunicacao/blob/main/frontend/src/pages/SAC.tsx"
click node_settingsui "https://github.com/luciano-watanabe/canal_comunicacao/blob/main/frontend/src/pages/Configuracoes.tsx"
click node_campaignui "https://github.com/luciano-watanabe/canal_comunicacao/blob/main/frontend/src/pages/Campanhas.tsx"
click node_dashboardui "https://github.com/luciano-watanabe/canal_comunicacao/blob/main/frontend/src/pages/Dashboard.tsx"
click node_searchui "https://github.com/luciano-watanabe/canal_comunicacao/blob/main/frontend/src/pages/PesquisaPrecos.tsx"
click node_routesui "https://github.com/luciano-watanabe/canal_comunicacao/blob/main/frontend/src/pages/Rotas.tsx"
click node_reactivationui "https://github.com/luciano-watanabe/canal_comunicacao/blob/main/frontend/src/pages/Reativacao.tsx"
click node_socket "https://github.com/luciano-watanabe/canal_comunicacao/blob/main/frontend/src/contexts/SocketContext.tsx"
click node_privacy "https://github.com/luciano-watanabe/canal_comunicacao/blob/main/frontend/src/contexts/PrivacyContext.tsx"
click node_cart "https://github.com/luciano-watanabe/canal_comunicacao/blob/main/frontend/src/contexts/CartContext.tsx"
click node_server "https://github.com/luciano-watanabe/canal_comunicacao/blob/main/backend/src/server.js"
click node_customerapi "https://github.com/luciano-watanabe/canal_comunicacao/blob/main/backend/src/routes/clientes.js"
click node_chatapi "https://github.com/luciano-watanabe/canal_comunicacao/blob/main/backend/src/routes/chat.js"
click node_sacapi "https://github.com/luciano-watanabe/canal_comunicacao/blob/main/backend/src/routes/sac.js"
click node_productroutes "https://github.com/luciano-watanabe/canal_comunicacao/tree/main/backend/src/routes"
click node_botservice "https://github.com/luciano-watanabe/canal_comunicacao/blob/main/backend/src/services/SacBotService.js"
click node_messagecache "https://github.com/luciano-watanabe/canal_comunicacao/blob/main/backend/src/services/botMensagensService.js"
click node_webhook "https://github.com/luciano-watanabe/canal_comunicacao/blob/main/backend/src/controllers/webhookController.js"
click node_nativehook "https://github.com/luciano-watanabe/canal_comunicacao/blob/main/backend/src/services/webhookServerManager.js"
click node_oraclepool "https://github.com/luciano-watanabe/canal_comunicacao/blob/main/backend/src/services/oraclePool.js"
click node_salesfeatures "https://github.com/luciano-watanabe/canal_comunicacao/tree/main/frontend/src/pages"

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_chatui,node_customerui,node_sacui,node_settingsui,node_campaignui,node_dashboardui,node_searchui,node_routesui,node_reactivationui,node_socket,node_privacy,node_cart,node_staff toneBlue
class node_botservice,node_messagecache,node_webhook,node_nativehook toneAmber
class node_salesfeatures toneMint
class node_server,node_customerapi,node_chatapi,node_sacapi,node_productroutes toneRose
class node_oraclepool,node_oracle,node_evolution,node_ai,node_geo toneIndigo
```

## Components

### Staff interface

- [Protected dashboard](https://github.com/luciano-watanabe/canal_comunicacao/blob/main/frontend/src/App.tsx): `frontend/src/App.tsx`
- [Chat workspace](https://github.com/luciano-watanabe/canal_comunicacao/blob/main/frontend/src/pages/Chat.tsx): `frontend/src/pages/Chat.tsx`
- [Customer management](https://github.com/luciano-watanabe/canal_comunicacao/blob/main/frontend/src/pages/Clientes.tsx): `frontend/src/pages/Clientes.tsx`
- [SAC console](https://github.com/luciano-watanabe/canal_comunicacao/blob/main/frontend/src/pages/SAC.tsx): `frontend/src/pages/SAC.tsx`
- [System settings](https://github.com/luciano-watanabe/canal_comunicacao/blob/main/frontend/src/pages/Configuracoes.tsx): `frontend/src/pages/Configuracoes.tsx`
- [Campaigns](https://github.com/luciano-watanabe/canal_comunicacao/blob/main/frontend/src/pages/Campanhas.tsx): `frontend/src/pages/Campanhas.tsx`
- [Analytics dashboard](https://github.com/luciano-watanabe/canal_comunicacao/blob/main/frontend/src/pages/Dashboard.tsx): `frontend/src/pages/Dashboard.tsx`
- [Price research](https://github.com/luciano-watanabe/canal_comunicacao/blob/main/frontend/src/pages/PesquisaPrecos.tsx): `frontend/src/pages/PesquisaPrecos.tsx`
- [Sales routes](https://github.com/luciano-watanabe/canal_comunicacao/blob/main/frontend/src/pages/Rotas.tsx): `frontend/src/pages/Rotas.tsx`
- [Customer reactivation](https://github.com/luciano-watanabe/canal_comunicacao/blob/main/frontend/src/pages/Reativacao.tsx): `frontend/src/pages/Reativacao.tsx`
- [Realtime client](https://github.com/luciano-watanabe/canal_comunicacao/blob/main/frontend/src/contexts/SocketContext.tsx): `frontend/src/contexts/SocketContext.tsx`
- [Privacy masking](https://github.com/luciano-watanabe/canal_comunicacao/blob/main/frontend/src/contexts/PrivacyContext.tsx): `frontend/src/contexts/PrivacyContext.tsx`
- [Order cart](https://github.com/luciano-watanabe/canal_comunicacao/blob/main/frontend/src/contexts/CartContext.tsx): `frontend/src/contexts/CartContext.tsx`

### Messaging and SAC

- [SAC bot](https://github.com/luciano-watanabe/canal_comunicacao/blob/main/backend/src/services/SacBotService.js): `backend/src/services/SacBotService.js`
- [Bot message service](https://github.com/luciano-watanabe/canal_comunicacao/blob/main/backend/src/services/botMensagensService.js): `backend/src/services/botMensagensService.js`
- [Evolution webhook](https://github.com/luciano-watanabe/canal_comunicacao/blob/main/backend/src/controllers/webhookController.js): `backend/src/controllers/webhookController.js`
- [Native webhook receiver](https://github.com/luciano-watanabe/canal_comunicacao/blob/main/backend/src/services/webhookServerManager.js): `backend/src/services/webhookServerManager.js`

### Sales operations

- [Sales and prospecting features](https://github.com/luciano-watanabe/canal_comunicacao/tree/main/frontend/src/pages): `frontend/src/pages`

### Backend platform

- [HTTP and socket server](https://github.com/luciano-watanabe/canal_comunicacao/blob/main/backend/src/server.js): `backend/src/server.js`
- [Customer API](https://github.com/luciano-watanabe/canal_comunicacao/blob/main/backend/src/routes/clientes.js): `backend/src/routes/clientes.js`
- [Chat API](https://github.com/luciano-watanabe/canal_comunicacao/blob/main/backend/src/routes/chat.js): `backend/src/routes/chat.js`
- [SAC API](https://github.com/luciano-watanabe/canal_comunicacao/blob/main/backend/src/routes/sac.js): `backend/src/routes/sac.js`
- [Sales APIs](https://github.com/luciano-watanabe/canal_comunicacao/tree/main/backend/src/routes): `backend/src/routes`

### Data and integrations

- [Oracle connection pool](https://github.com/luciano-watanabe/canal_comunicacao/blob/main/backend/src/services/oraclePool.js): `backend/src/services/oraclePool.js`
- **Oracle database**
- **Evolution API**
- **Grok and Groq**
- **Geolocation providers**

### Other components

- **Staff user**

## Connections

- Staff user → Protected dashboard: uses (evidence: `README.md`)
- Protected dashboard → Chat workspace: routes to (evidence: `frontend/src/App.tsx`)
- Protected dashboard → Customer management: routes to (evidence: `frontend/src/App.tsx`)
- Protected dashboard → SAC console: routes to (evidence: `frontend/src/App.tsx`)
- Protected dashboard → System settings: routes to (evidence: `frontend/src/App.tsx`)
- Protected dashboard → Campaigns: routes to (evidence: `frontend/src/App.tsx`)
- Protected dashboard → Analytics dashboard: routes to (evidence: `frontend/src/App.tsx`)
- Protected dashboard → Price research: routes to (evidence: `frontend/src/App.tsx`)
- Protected dashboard → Sales routes: routes to (evidence: `frontend/src/App.tsx`)
- Protected dashboard → Customer reactivation: routes to (evidence: `frontend/src/App.tsx`)
- Protected dashboard → Realtime client: provides (evidence: `frontend/src/App.tsx`)
- Protected dashboard → Privacy masking: provides (evidence: `frontend/src/App.tsx`)
- Protected dashboard → Order cart: provides (evidence: `frontend/src/App.tsx`)
- Customer management → Privacy masking: masks data (evidence: `frontend/src/pages/Clientes.tsx`)
- Customer management → Customer API: requests (evidence: `frontend/src/pages/Clientes.tsx`)
- HTTP and socket server → Customer API: mounts (evidence: `backend/src/server.js`)
- HTTP and socket server → Chat API: mounts (evidence: `backend/src/server.js`)
- HTTP and socket server → SAC API: mounts (evidence: `backend/src/server.js`)
- HTTP and socket server → Sales APIs: mounts (evidence: `backend/src/server.js`)
- HTTP and socket server → Evolution webhook: mounts route (evidence: `backend/src/server.js`)
- Evolution webhook → Realtime client: emits events (evidence: `backend/src/controllers/webhookController.js`)
- HTTP and socket server → Oracle connection pool: initializes (evidence: `backend/src/server.js`)
- HTTP and socket server → Bot message service: loads and refreshes (evidence: `backend/src/server.js`)
- Native webhook receiver → Oracle connection pool: acquires connection (evidence: `backend/src/services/webhookServerManager.js`)
- Oracle connection pool → Oracle database: opens pooled connections (evidence: `backend/src/services/oraclePool.js`)
- Customer API → Oracle database: queries customer data (evidence: `backend/src/routes/clientes.js`)
- Customer API → Bot message service: reads cache (evidence: `backend/src/routes/clientes.js`)
- SAC bot → Bot message service: uses messages (evidence: `backend/src/services/SacBotService.js`)
- Chat workspace → Realtime client: uses realtime (evidence: `frontend/src/pages/Chat.tsx`)
- Chat workspace → Order cart: uses cart (evidence: `frontend/src/pages/Chat.tsx`)
- Campaigns → Evolution API: sends WhatsApp (evidence: `README.md`)
- SAC bot → Grok and Groq: suggests responses (evidence: `README.md`)
- Sales and prospecting features → Geolocation providers: geocodes addresses (evidence: `README.md`)
