# luisbedinot/atendezap-turbosaas architecture

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

- Interactive diagram: https://gitdiagram.com/luisbedinot/atendezap-turbosaas
- Repository: https://github.com/luisbedinot/atendezap-turbosaas

## Overview

AtendeZap is a multi-company WhatsApp support SaaS centered on an inbound-message workflow: WhatsApp events are received and validated, handled with business rules and AI, and used to update CRM state and reply. Users access the product through an authenticated workspace; major documented branches include campaigns, team management, reports, integrations, finance, and commercial plans. The webhook excerpt and source index support the key runtime connections; some feature internals were not sampled, so those branches are shown without speculative implementation links.

Main entry points: [`src/routes/api/public/whatsapp-webhook.ts`](https://github.com/luisbedinot/atendezap-turbosaas/blob/main/src/routes/api/public/whatsapp-webhook.ts) (WhatsApp webhook), [`src/integrations/supabase/client.server.ts`](https://github.com/luisbedinot/atendezap-turbosaas/blob/main/src/integrations/supabase/client.server.ts) (Supabase data and auth), [`src/routes/app.tsx`](https://github.com/luisbedinot/atendezap-turbosaas/blob/main/src/routes/app.tsx) (App access gate), [`src/lib/evolution.server.ts`](https://github.com/luisbedinot/atendezap-turbosaas/blob/main/src/lib/evolution.server.ts) (Evolution server client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_workspace["Workspace access"]
  node_app_gate["App access gate<br/>[app.tsx]"]
  node_shell["Workspace shell<br/>[app-shell.tsx]"]
end

subgraph group_messaging["WhatsApp and AI"]
  node_conversations["Conversations<br/>[conversas.tsx]"]
  node_whatsapp_hook["WhatsApp webhook"]
  node_ai_prompt["AI instructions<br/>[ai-prompt.ts]"]
  node_evolution_ops["WhatsApp operations"]
  node_evolution_server["Evolution server client"]
end

subgraph group_sales["CRM and engagement"]
  node_crm["CRM Kanban<br/>[crm.tsx]"]
  node_lead_drawer["Lead details<br/>[lead-drawer.tsx]"]
  node_campaigns["Campaigns<br/>[campanhas.tsx]"]
  node_campaign_worker["Campaign worker"]
  node_csat["Customer satisfaction<br/>[csat.$token.tsx]"]
end

subgraph group_management["Business management"]
  node_dashboard["Dashboard and reports<br/>[dashboard.tsx]"]
  node_team["Team management<br/>[equipe.tsx]"]
  node_finance["Financial records<br/>[financeiro.tsx]"]
  node_plans["Plans and billing<br/>[plan.functions.ts]"]
  node_integration_settings["Integration settings<br/>[integracoes.tsx]"]
end

subgraph group_platform["Platform services"]
  node_database[("Supabase data and auth<br/>[client.server.ts]")]
  node_browser_db["Browser Supabase client<br/>[client.ts]"]
  node_tenant["Tenant resolution<br/>[tenant.ts]"]
  node_plan_limits["Plan entitlements"]
  node_google_ops["Google integration<br/>[google.server.ts]"]
end

node_user(("Workspace user"))
node_whatsapp(("WhatsApp sender"))
node_evolution["Evolution API"]
node_google["Google Calendar"]

node_user -->|"opens workspace"| node_app_gate
node_app_gate -->|"checks session"| node_browser_db
node_app_gate -->|"renders"| node_shell
node_app_gate -->|"uses tenant types"| node_tenant
node_shell -->|"shows navigation"| node_user
node_whatsapp -.->|"posts events"| node_whatsapp_hook
node_whatsapp_hook -->|"reads and writes"| node_database
node_whatsapp_hook -->|"uses instructions"| node_ai_prompt
node_whatsapp_hook -->|"sends replies"| node_evolution_server
node_evolution_ops -->|"delegates operations"| node_evolution_server
node_evolution_server -.->|"calls API"| node_evolution
node_whatsapp_hook -->|"creates calendar events"| node_google_ops
node_google_ops -.->|"integrates calendar"| node_google
node_conversations -.->|"supports inbox work"| node_user
node_crm -->|"opens lead details"| node_lead_drawer
node_campaign_worker -.->|"reserves recipients"| node_database
node_campaigns -.->|"offers campaign tools"| node_user
node_csat -.->|"collects feedback"| node_user
node_dashboard -.->|"shows metrics"| node_user
node_team -.->|"manages agents"| node_user
node_finance -.->|"tracks finances"| node_user
node_plans -.->|"manages plan data"| node_database
node_integration_settings -.->|"configures integrations"| node_user
node_browser_db -.->|"queries Supabase"| node_database
node_plan_limits -.->|"checks limits"| node_database

click node_app_gate "https://github.com/luisbedinot/atendezap-turbosaas/blob/main/src/routes/app.tsx"
click node_shell "https://github.com/luisbedinot/atendezap-turbosaas/blob/main/src/components/app-shell.tsx"
click node_conversations "https://github.com/luisbedinot/atendezap-turbosaas/blob/main/src/routes/app/conversas.tsx"
click node_whatsapp_hook "https://github.com/luisbedinot/atendezap-turbosaas/blob/main/src/routes/api/public/whatsapp-webhook.ts"
click node_ai_prompt "https://github.com/luisbedinot/atendezap-turbosaas/blob/main/src/lib/ai-prompt.ts"
click node_evolution_ops "https://github.com/luisbedinot/atendezap-turbosaas/blob/main/src/lib/evolution.functions.ts"
click node_evolution_server "https://github.com/luisbedinot/atendezap-turbosaas/blob/main/src/lib/evolution.server.ts"
click node_crm "https://github.com/luisbedinot/atendezap-turbosaas/blob/main/src/routes/app/crm.tsx"
click node_lead_drawer "https://github.com/luisbedinot/atendezap-turbosaas/blob/main/src/components/crm/lead-drawer.tsx"
click node_campaigns "https://github.com/luisbedinot/atendezap-turbosaas/blob/main/src/routes/app/campanhas.tsx"
click node_campaign_worker "https://github.com/luisbedinot/atendezap-turbosaas/blob/main/src/routes/api/public/hooks/process-campaigns.ts"
click node_csat "https://github.com/luisbedinot/atendezap-turbosaas/blob/main/src/routes/csat.%24token.tsx"
click node_dashboard "https://github.com/luisbedinot/atendezap-turbosaas/blob/main/src/routes/app/dashboard.tsx"
click node_team "https://github.com/luisbedinot/atendezap-turbosaas/blob/main/src/routes/app/equipe.tsx"
click node_finance "https://github.com/luisbedinot/atendezap-turbosaas/blob/main/src/routes/app/financeiro.tsx"
click node_plans "https://github.com/luisbedinot/atendezap-turbosaas/blob/main/src/lib/plan.functions.ts"
click node_integration_settings "https://github.com/luisbedinot/atendezap-turbosaas/blob/main/src/routes/app/integracoes.tsx"
click node_database "https://github.com/luisbedinot/atendezap-turbosaas/blob/main/src/integrations/supabase/client.server.ts"
click node_browser_db "https://github.com/luisbedinot/atendezap-turbosaas/blob/main/src/integrations/supabase/client.ts"
click node_tenant "https://github.com/luisbedinot/atendezap-turbosaas/blob/main/src/lib/tenant.ts"
click node_plan_limits "https://github.com/luisbedinot/atendezap-turbosaas/blob/main/src/lib/plan-limits.server.ts"
click node_google_ops "https://github.com/luisbedinot/atendezap-turbosaas/blob/main/src/lib/google.server.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_gate,node_shell,node_user toneBlue
class node_conversations,node_whatsapp_hook,node_ai_prompt,node_evolution_ops,node_evolution_server toneAmber
class node_crm,node_lead_drawer,node_campaigns,node_campaign_worker,node_csat,node_evolution toneMint
class node_dashboard,node_team,node_finance,node_plans,node_integration_settings toneRose
class node_database,node_browser_db,node_tenant,node_plan_limits,node_google_ops,node_whatsapp,node_google toneIndigo
```

## Components

### Workspace access

- [App access gate](https://github.com/luisbedinot/atendezap-turbosaas/blob/main/src/routes/app.tsx): `src/routes/app.tsx`
- [Workspace shell](https://github.com/luisbedinot/atendezap-turbosaas/blob/main/src/components/app-shell.tsx): `src/components/app-shell.tsx`

### WhatsApp and AI

- [Conversations](https://github.com/luisbedinot/atendezap-turbosaas/blob/main/src/routes/app/conversas.tsx): `src/routes/app/conversas.tsx`
- [WhatsApp webhook](https://github.com/luisbedinot/atendezap-turbosaas/blob/main/src/routes/api/public/whatsapp-webhook.ts): `src/routes/api/public/whatsapp-webhook.ts`
- [AI instructions](https://github.com/luisbedinot/atendezap-turbosaas/blob/main/src/lib/ai-prompt.ts): `src/lib/ai-prompt.ts`
- [WhatsApp operations](https://github.com/luisbedinot/atendezap-turbosaas/blob/main/src/lib/evolution.functions.ts): `src/lib/evolution.functions.ts`
- [Evolution server client](https://github.com/luisbedinot/atendezap-turbosaas/blob/main/src/lib/evolution.server.ts): `src/lib/evolution.server.ts`

### CRM and engagement

- [CRM Kanban](https://github.com/luisbedinot/atendezap-turbosaas/blob/main/src/routes/app/crm.tsx): `src/routes/app/crm.tsx`
- [Lead details](https://github.com/luisbedinot/atendezap-turbosaas/blob/main/src/components/crm/lead-drawer.tsx): `src/components/crm/lead-drawer.tsx`
- [Campaigns](https://github.com/luisbedinot/atendezap-turbosaas/blob/main/src/routes/app/campanhas.tsx): `src/routes/app/campanhas.tsx`
- [Campaign worker](https://github.com/luisbedinot/atendezap-turbosaas/blob/main/src/routes/api/public/hooks/process-campaigns.ts): `src/routes/api/public/hooks/process-campaigns.ts`
- [Customer satisfaction](https://github.com/luisbedinot/atendezap-turbosaas/blob/main/src/routes/csat.%24token.tsx): `src/routes/csat.$token.tsx`

### Business management

- [Dashboard and reports](https://github.com/luisbedinot/atendezap-turbosaas/blob/main/src/routes/app/dashboard.tsx): `src/routes/app/dashboard.tsx`
- [Team management](https://github.com/luisbedinot/atendezap-turbosaas/blob/main/src/routes/app/equipe.tsx): `src/routes/app/equipe.tsx`
- [Financial records](https://github.com/luisbedinot/atendezap-turbosaas/blob/main/src/routes/app/financeiro.tsx): `src/routes/app/financeiro.tsx`
- [Plans and billing](https://github.com/luisbedinot/atendezap-turbosaas/blob/main/src/lib/plan.functions.ts): `src/lib/plan.functions.ts`
- [Integration settings](https://github.com/luisbedinot/atendezap-turbosaas/blob/main/src/routes/app/integracoes.tsx): `src/routes/app/integracoes.tsx`

### Platform services

- [Supabase data and auth](https://github.com/luisbedinot/atendezap-turbosaas/blob/main/src/integrations/supabase/client.server.ts): `src/integrations/supabase/client.server.ts`
- [Browser Supabase client](https://github.com/luisbedinot/atendezap-turbosaas/blob/main/src/integrations/supabase/client.ts): `src/integrations/supabase/client.ts`
- [Tenant resolution](https://github.com/luisbedinot/atendezap-turbosaas/blob/main/src/lib/tenant.ts): `src/lib/tenant.ts`
- [Plan entitlements](https://github.com/luisbedinot/atendezap-turbosaas/blob/main/src/lib/plan-limits.server.ts): `src/lib/plan-limits.server.ts`
- [Google integration](https://github.com/luisbedinot/atendezap-turbosaas/blob/main/src/lib/google.server.ts): `src/lib/google.server.ts`

### Other components

- **Workspace user**
- **WhatsApp sender**
- **Evolution API**
- **Google Calendar**

## Connections

- Workspace user → App access gate: opens workspace (evidence: `src/routes/app.tsx`)
- App access gate → Browser Supabase client: checks session (evidence: `src/routes/app.tsx`)
- App access gate → Workspace shell: renders (evidence: `src/routes/app.tsx`)
- App access gate → Tenant resolution: uses tenant types (evidence: `src/routes/app.tsx`)
- Workspace shell → Workspace user: shows navigation (evidence: `src/components/app-shell.tsx`)
- WhatsApp sender → WhatsApp webhook: posts events
- WhatsApp webhook → Supabase data and auth: reads and writes (evidence: `src/routes/api/public/whatsapp-webhook.ts`)
- WhatsApp webhook → AI instructions: uses instructions (evidence: `src/routes/api/public/whatsapp-webhook.ts`)
- WhatsApp webhook → Evolution server client: sends replies (evidence: `src/routes/api/public/whatsapp-webhook.ts`)
- WhatsApp operations → Evolution server client: delegates operations (evidence: `src/lib/evolution.functions.ts`)
- Evolution server client → Evolution API: calls API
- WhatsApp webhook → Google integration: creates calendar events (evidence: `src/routes/api/public/whatsapp-webhook.ts`)
- Google integration → Google Calendar: integrates calendar
- Conversations → Workspace user: supports inbox work
- CRM Kanban → Lead details: opens lead details (evidence: `src/components/crm/lead-drawer.tsx`)
- Campaign worker → Supabase data and auth: reserves recipients
- Campaigns → Workspace user: offers campaign tools
- Customer satisfaction → Workspace user: collects feedback
- Dashboard and reports → Workspace user: shows metrics
- Team management → Workspace user: manages agents
- Financial records → Workspace user: tracks finances
- Plans and billing → Supabase data and auth: manages plan data
- Integration settings → Workspace user: configures integrations
- Browser Supabase client → Supabase data and auth: queries Supabase
- Plan entitlements → Supabase data and auth: checks limits
