# 1120-estudio/atiendo-crm architecture

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

- Interactive diagram: https://gitdiagram.com/1120-estudio/atiendo-crm
- Repository: https://github.com/1120-estudio/atiendo-crm

## Overview

Atiendo CRM is a multi-company WhatsApp CRM: an incoming customer message reaches the inbox, creates or updates a lead in a configurable Kanban funnel, and an AI agent responds or hands the conversation to a person. Workspace setup connects WhatsApp and configures the agent; optional knowledge files support answers. The README documents these product relationships, but the relevant webhook and worker implementations were not sampled, so internal links are limited to documented behavior rather than assumed call chains.

Main entry points: [`app/api/v1/conversations/route.ts`](https://github.com/1120-estudio/atiendo-crm/blob/main/app/api/v1/conversations/route.ts) (Conversation inbox), [`workers/agent-worker/main.ts`](https://github.com/1120-estudio/atiendo-crm/blob/main/workers/agent-worker/main.ts) (AI agent), [`app/api/v1/ai/knowledge/sources/route.ts`](https://github.com/1120-estudio/atiendo-crm/blob/main/app/api/v1/ai/knowledge/sources/route.ts) (Knowledge base), [`app/api/v1/webhooks/channel/[token]/route.ts`](https://github.com/1120-estudio/atiendo-crm/blob/main/app/api/v1/webhooks/channel/%5Btoken%5D/route.ts) (WhatsApp webhook)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_conversation["Conversations"]
  node_inbound["WhatsApp webhook<br/>[route.ts]"]
  node_inbox["Conversation inbox<br/>[route.ts]"]
  node_handoff["Human handoff<br/>[route.ts]"]
end

subgraph group_sales["Lead management"]
  node_lead["Lead records<br/>[_handler.ts]"]
  node_kanban["Kanban pipeline<br/>[route.ts]"]
end

subgraph group_ai["AI engagement"]
  node_agent["AI agent<br/>[main.ts]"]
  node_agent_api["Agent management<br/>[route.ts]"]
  node_knowledge["Knowledge base<br/>[route.ts]"]
  node_rag["Knowledge indexing<br/>[rag-indexer.ts]"]
end

subgraph group_workspace["Workspace setup"]
  node_signup["Account signup<br/>[signUp.ts]"]
  node_onboarding["Workspace onboarding"]
  node_connections["Channel connections<br/>[route.ts]"]
end

subgraph group_platform["Platform services"]
  node_tenant[("Organization isolation<br/>[server.ts]")]
  node_api["API client<br/>[client.ts]"]
end

node_customer(("WhatsApp customer"))
node_admin(("Workspace admin"))
node_zernio["Zernio WhatsApp"]

node_customer -->|"sends message"| node_zernio
node_zernio -->|"delivers webhook"| node_inbound
node_inbound -->|"arrives in"| node_inbox
node_inbox -->|"creates lead"| node_lead
node_lead -->|"appears in"| node_kanban
node_agent -->|"responds in"| node_inbox
node_agent -->|"moves lead"| node_kanban
node_inbox -->|"hands off"| node_handoff
node_admin -->|"creates account"| node_signup
node_signup -->|"starts setup"| node_onboarding
node_admin -->|"connects channel"| node_connections
node_admin -->|"configures agent"| node_agent_api
node_admin -->|"adds files"| node_knowledge
node_knowledge -.->|"indexes sources"| node_rag
node_agent -.->|"consults materials"| node_knowledge

click node_inbound "https://github.com/1120-estudio/atiendo-crm/blob/main/app/api/v1/webhooks/channel/%5Btoken%5D/route.ts"
click node_inbox "https://github.com/1120-estudio/atiendo-crm/blob/main/app/api/v1/conversations/route.ts"
click node_handoff "https://github.com/1120-estudio/atiendo-crm/blob/main/app/api/v1/conversations/%5Bid%5D/transfer/route.ts"
click node_lead "https://github.com/1120-estudio/atiendo-crm/blob/main/app/api/v1/leads/_handler.ts"
click node_kanban "https://github.com/1120-estudio/atiendo-crm/blob/main/app/api/v1/pipelines/%5Bid%5D/board/route.ts"
click node_agent "https://github.com/1120-estudio/atiendo-crm/blob/main/workers/agent-worker/main.ts"
click node_agent_api "https://github.com/1120-estudio/atiendo-crm/blob/main/app/api/v1/ai/agents/route.ts"
click node_knowledge "https://github.com/1120-estudio/atiendo-crm/blob/main/app/api/v1/ai/knowledge/sources/route.ts"
click node_rag "https://github.com/1120-estudio/atiendo-crm/blob/main/workers/rag-indexer.ts"
click node_signup "https://github.com/1120-estudio/atiendo-crm/blob/main/app/actions/auth/signUp.ts"
click node_onboarding "https://github.com/1120-estudio/atiendo-crm/blob/main/app/actions/onboarding/finishOnboarding.ts"
click node_connections "https://github.com/1120-estudio/atiendo-crm/blob/main/app/api/v1/channel-sessions/route.ts"
click node_tenant "https://github.com/1120-estudio/atiendo-crm/blob/main/lib/supabase/server.ts"
click node_api "https://github.com/1120-estudio/atiendo-crm/blob/main/lib/api/client.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_inbound,node_inbox,node_handoff toneBlue
class node_lead,node_kanban toneAmber
class node_agent,node_agent_api,node_knowledge,node_rag toneMint
class node_signup,node_onboarding,node_connections toneRose
class node_tenant,node_api,node_customer,node_admin,node_zernio toneIndigo
```

## Components

### Conversations

- [WhatsApp webhook](https://github.com/1120-estudio/atiendo-crm/blob/main/app/api/v1/webhooks/channel/%5Btoken%5D/route.ts): `app/api/v1/webhooks/channel/[token]/route.ts`
- [Conversation inbox](https://github.com/1120-estudio/atiendo-crm/blob/main/app/api/v1/conversations/route.ts): `app/api/v1/conversations/route.ts`
- [Human handoff](https://github.com/1120-estudio/atiendo-crm/blob/main/app/api/v1/conversations/%5Bid%5D/transfer/route.ts): `app/api/v1/conversations/[id]/transfer/route.ts`

### Lead management

- [Lead records](https://github.com/1120-estudio/atiendo-crm/blob/main/app/api/v1/leads/_handler.ts): `app/api/v1/leads/_handler.ts`
- [Kanban pipeline](https://github.com/1120-estudio/atiendo-crm/blob/main/app/api/v1/pipelines/%5Bid%5D/board/route.ts): `app/api/v1/pipelines/[id]/board/route.ts`

### AI engagement

- [AI agent](https://github.com/1120-estudio/atiendo-crm/blob/main/workers/agent-worker/main.ts): `workers/agent-worker/main.ts`
- [Agent management](https://github.com/1120-estudio/atiendo-crm/blob/main/app/api/v1/ai/agents/route.ts): `app/api/v1/ai/agents/route.ts`
- [Knowledge base](https://github.com/1120-estudio/atiendo-crm/blob/main/app/api/v1/ai/knowledge/sources/route.ts): `app/api/v1/ai/knowledge/sources/route.ts`
- [Knowledge indexing](https://github.com/1120-estudio/atiendo-crm/blob/main/workers/rag-indexer.ts): `workers/rag-indexer.ts`

### Workspace setup

- [Account signup](https://github.com/1120-estudio/atiendo-crm/blob/main/app/actions/auth/signUp.ts): `app/actions/auth/signUp.ts`
- [Workspace onboarding](https://github.com/1120-estudio/atiendo-crm/blob/main/app/actions/onboarding/finishOnboarding.ts): `app/actions/onboarding/finishOnboarding.ts`
- [Channel connections](https://github.com/1120-estudio/atiendo-crm/blob/main/app/api/v1/channel-sessions/route.ts): `app/api/v1/channel-sessions/route.ts`

### Platform services

- [Organization isolation](https://github.com/1120-estudio/atiendo-crm/blob/main/lib/supabase/server.ts): `lib/supabase/server.ts`
- [API client](https://github.com/1120-estudio/atiendo-crm/blob/main/lib/api/client.ts): `lib/api/client.ts`

### Other components

- **WhatsApp customer**
- **Workspace admin**
- **Zernio WhatsApp**

## Connections

- WhatsApp customer → Zernio WhatsApp: sends message
- Zernio WhatsApp → WhatsApp webhook: delivers webhook
- WhatsApp webhook → Conversation inbox: arrives in
- Conversation inbox → Lead records: creates lead
- Lead records → Kanban pipeline: appears in
- AI agent → Conversation inbox: responds in
- AI agent → Kanban pipeline: moves lead
- Conversation inbox → Human handoff: hands off
- Workspace admin → Account signup: creates account
- Account signup → Workspace onboarding: starts setup
- Workspace admin → Channel connections: connects channel
- Workspace admin → Agent management: configures agent
- Workspace admin → Knowledge base: adds files
- Knowledge base → Knowledge indexing: indexes sources
- AI agent → Knowledge base: consults materials
