# viniciosragazzidev/ancorahub architecture

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

- Interactive diagram: https://gitdiagram.com/viniciosragazzidev/ancorahub
- Repository: https://github.com/viniciosragazzidev/ancorahub

## Overview

CorreTop is a multi-tenant CRM SaaS for health-plan brokerages. The principal workflow is lead intake, qualification, distribution to brokers, conversation and follow-up, then sales and commission tracking; reporting and tenant administration support that work. The graph also captures documented AI, WhatsApp, marketing, and document capabilities. Several routes and feature directories are represented from the tree rather than inspected source, so their internal wiring is intentionally not inferred; direct engine calls shown are supported by sampled excerpts.

Main entry points: [`src/features/ai-agent/capability-execution-engine.ts`](https://github.com/viniciosragazzidev/ancorahub/blob/main/src/features/ai-agent/capability-execution-engine.ts) (Agent execution), [`src/features/tenant-intelligence/ingestion/pipeline.ts`](https://github.com/viniciosragazzidev/ancorahub/blob/main/src/features/tenant-intelligence/ingestion/pipeline.ts) (Tenant knowledge ingestion), [`src/features/automations/engine.ts`](https://github.com/viniciosragazzidev/ancorahub/blob/main/src/features/automations/engine.ts) (Automation engine), [`src/app/(auth)/login/page.tsx`](https://github.com/viniciosragazzidev/ancorahub/blob/main/src/app/(auth)/login/page.tsx) (Authentication)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_access["Access and tenancy"]
  node_portal["CRM portal<br/>[layout.tsx]"]
  node_auth["Authentication<br/>[page.tsx]"]
  node_tenant_admin["Platform administration<br/>[page.tsx]"]
end

subgraph group_crm["CRM operations"]
  node_leads["Lead workspace<br/>[page.tsx]"]
  node_intake["Lead intake APIs<br/>[route.ts]"]
  node_distribution["Lead routing<br/>[routing-engine.ts]"]
  node_conversations["Conversations<br/>[page.tsx]"]
  node_sales["Sales and commissions<br/>[page.tsx]"]
  node_automation["Automation engine<br/>[engine.ts]"]
end

subgraph group_intelligence["AI and qualification"]
  node_qualification["Qualification workspace<br/>[page.tsx]"]
  node_agent["Agent execution"]
  node_triggers["Agent triggers"]
  node_ai["AI engine<br/>[engine.ts]"]
  node_knowledge["Tenant knowledge ingestion<br/>[pipeline.ts]"]
end

subgraph group_communications["Messaging and integrations"]
  node_whatsapp["WhatsApp service<br/>[app.ts]"]
  node_meta["Meta integrations<br/>[route.ts]"]
  node_documents["Document storage<br/>[r2-storage.ts]"]
end

subgraph group_oversight["Sales and oversight"]
  node_reports["Reports and exports<br/>[page.tsx]"]
  node_dashboard["Operational dashboards<br/>[page.tsx]"]
end

node_broker(("Brokerage users"))
node_prospect(("Prospects"))
node_messaging_provider{{"WhatsApp provider"}}
node_object_store[("Cloudflare R2")]
node_db[("CRM database")]

node_broker -->|"signs in"| node_auth
node_auth -->|"opens workspace"| node_portal
node_broker -->|"manages leads"| node_leads
node_prospect -->|"submits lead"| node_intake
node_intake -->|"writes lead data"| node_db
node_leads -->|"requests routing"| node_distribution
node_distribution -->|"reads routing rules"| node_db
node_broker -->|"handles conversations"| node_conversations
node_broker -->|"reviews qualification"| node_qualification
node_qualification -->|"requests capability"| node_agent
node_agent -->|"reads and records"| node_db
node_agent -.->|"executes trigger"| node_triggers
node_agent -.->|"requests AI"| node_ai
node_agent -->|"updates conversation"| node_db
node_knowledge -->|"classifies and extracts"| node_ai
node_knowledge -->|"stores knowledge"| node_db
node_knowledge -.->|"stores documents"| node_documents
node_documents -->|"uploads and downloads"| node_object_store
node_automation -->|"reads and updates"| node_db
node_automation -.->|"sends relay message"| node_messaging_provider
node_whatsapp -.->|"integrates messaging"| node_messaging_provider
node_meta -.->|"records integration data"| node_db
node_broker -->|"tracks sales"| node_sales
node_sales -->|"reads sales data"| node_db
node_broker -->|"views reports"| node_reports
node_broker -->|"views operations"| node_dashboard
node_tenant_admin -->|"administers tenants"| node_db

click node_portal "https://github.com/viniciosragazzidev/ancorahub/blob/main/src/app/(dashboard)/layout.tsx"
click node_auth "https://github.com/viniciosragazzidev/ancorahub/blob/main/src/app/(auth)/login/page.tsx"
click node_tenant_admin "https://github.com/viniciosragazzidev/ancorahub/blob/main/src/app/(platform-admin)/super-admin/page.tsx"
click node_leads "https://github.com/viniciosragazzidev/ancorahub/blob/main/src/app/(dashboard)/leads/page.tsx"
click node_intake "https://github.com/viniciosragazzidev/ancorahub/blob/main/src/app/api/webhooks/leads/route.ts"
click node_distribution "https://github.com/viniciosragazzidev/ancorahub/blob/main/src/features/lead-distribution/routing-engine.ts"
click node_conversations "https://github.com/viniciosragazzidev/ancorahub/blob/main/src/app/(dashboard)/conversas/page.tsx"
click node_sales "https://github.com/viniciosragazzidev/ancorahub/blob/main/src/app/(dashboard)/vendas/page.tsx"
click node_automation "https://github.com/viniciosragazzidev/ancorahub/blob/main/src/features/automations/engine.ts"
click node_qualification "https://github.com/viniciosragazzidev/ancorahub/blob/main/src/app/(dashboard)/qualificacao/page.tsx"
click node_agent "https://github.com/viniciosragazzidev/ancorahub/blob/main/src/features/ai-agent/capability-execution-engine.ts"
click node_triggers "https://github.com/viniciosragazzidev/ancorahub/blob/main/src/features/ai-agent/trigger-execution-engine.ts"
click node_ai "https://github.com/viniciosragazzidev/ancorahub/blob/main/src/features/ai/engine.ts"
click node_knowledge "https://github.com/viniciosragazzidev/ancorahub/blob/main/src/features/tenant-intelligence/ingestion/pipeline.ts"
click node_whatsapp "https://github.com/viniciosragazzidev/ancorahub/blob/main/services/whatsapp-api/src/app.ts"
click node_meta "https://github.com/viniciosragazzidev/ancorahub/blob/main/src/app/api/webhooks/meta/lead-ads/route.ts"
click node_documents "https://github.com/viniciosragazzidev/ancorahub/blob/main/src/shared/storage/r2-storage.ts"
click node_reports "https://github.com/viniciosragazzidev/ancorahub/blob/main/src/app/(dashboard)/relatorios/page.tsx"
click node_dashboard "https://github.com/viniciosragazzidev/ancorahub/blob/main/src/app/(dashboard)/dashboard/page.tsx"

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_portal,node_auth,node_tenant_admin,node_broker toneBlue
class node_leads,node_intake,node_distribution,node_conversations,node_sales,node_automation,node_object_store,node_db toneAmber
class node_qualification,node_agent,node_triggers,node_ai,node_knowledge toneMint
class node_whatsapp,node_meta,node_documents toneRose
class node_reports,node_dashboard,node_prospect,node_messaging_provider toneIndigo
```

## Components

### Access and tenancy

- [CRM portal](https://github.com/viniciosragazzidev/ancorahub/blob/main/src/app/(dashboard)/layout.tsx): `src/app/(dashboard)/layout.tsx`
- [Authentication](https://github.com/viniciosragazzidev/ancorahub/blob/main/src/app/(auth)/login/page.tsx): `src/app/(auth)/login/page.tsx`
- [Platform administration](https://github.com/viniciosragazzidev/ancorahub/blob/main/src/app/(platform-admin)/super-admin/page.tsx): `src/app/(platform-admin)/super-admin/page.tsx`

### CRM operations

- [Lead workspace](https://github.com/viniciosragazzidev/ancorahub/blob/main/src/app/(dashboard)/leads/page.tsx): `src/app/(dashboard)/leads/page.tsx`
- [Lead intake APIs](https://github.com/viniciosragazzidev/ancorahub/blob/main/src/app/api/webhooks/leads/route.ts): `src/app/api/webhooks/leads/route.ts`
- [Lead routing](https://github.com/viniciosragazzidev/ancorahub/blob/main/src/features/lead-distribution/routing-engine.ts): `src/features/lead-distribution/routing-engine.ts`
- [Conversations](https://github.com/viniciosragazzidev/ancorahub/blob/main/src/app/(dashboard)/conversas/page.tsx): `src/app/(dashboard)/conversas/page.tsx`
- [Sales and commissions](https://github.com/viniciosragazzidev/ancorahub/blob/main/src/app/(dashboard)/vendas/page.tsx): `src/app/(dashboard)/vendas/page.tsx`
- [Automation engine](https://github.com/viniciosragazzidev/ancorahub/blob/main/src/features/automations/engine.ts): `src/features/automations/engine.ts`

### AI and qualification

- [Qualification workspace](https://github.com/viniciosragazzidev/ancorahub/blob/main/src/app/(dashboard)/qualificacao/page.tsx): `src/app/(dashboard)/qualificacao/page.tsx`
- [Agent execution](https://github.com/viniciosragazzidev/ancorahub/blob/main/src/features/ai-agent/capability-execution-engine.ts): `src/features/ai-agent/capability-execution-engine.ts`
- [Agent triggers](https://github.com/viniciosragazzidev/ancorahub/blob/main/src/features/ai-agent/trigger-execution-engine.ts): `src/features/ai-agent/trigger-execution-engine.ts`
- [AI engine](https://github.com/viniciosragazzidev/ancorahub/blob/main/src/features/ai/engine.ts): `src/features/ai/engine.ts`
- [Tenant knowledge ingestion](https://github.com/viniciosragazzidev/ancorahub/blob/main/src/features/tenant-intelligence/ingestion/pipeline.ts): `src/features/tenant-intelligence/ingestion/pipeline.ts`

### Messaging and integrations

- [WhatsApp service](https://github.com/viniciosragazzidev/ancorahub/blob/main/services/whatsapp-api/src/app.ts): `services/whatsapp-api/src/app.ts`
- [Meta integrations](https://github.com/viniciosragazzidev/ancorahub/blob/main/src/app/api/webhooks/meta/lead-ads/route.ts): `src/app/api/webhooks/meta/lead-ads/route.ts`
- [Document storage](https://github.com/viniciosragazzidev/ancorahub/blob/main/src/shared/storage/r2-storage.ts): `src/shared/storage/r2-storage.ts`

### Sales and oversight

- [Reports and exports](https://github.com/viniciosragazzidev/ancorahub/blob/main/src/app/(dashboard)/relatorios/page.tsx): `src/app/(dashboard)/relatorios/page.tsx`
- [Operational dashboards](https://github.com/viniciosragazzidev/ancorahub/blob/main/src/app/(dashboard)/dashboard/page.tsx): `src/app/(dashboard)/dashboard/page.tsx`

### Other components

- **Brokerage users**
- **Prospects**
- **WhatsApp provider**
- **Cloudflare R2**
- **CRM database**

## Connections

- Brokerage users → Authentication: signs in
- Authentication → CRM portal: opens workspace
- Brokerage users → Lead workspace: manages leads
- Prospects → Lead intake APIs: submits lead
- Lead intake APIs → CRM database: writes lead data
- Lead workspace → Lead routing: requests routing
- Lead routing → CRM database: reads routing rules
- Brokerage users → Conversations: handles conversations
- Brokerage users → Qualification workspace: reviews qualification
- Qualification workspace → Agent execution: requests capability
- Agent execution → CRM database: reads and records
- Agent execution → Agent triggers: executes trigger
- Agent execution → AI engine: requests AI
- Agent execution → CRM database: updates conversation
- Tenant knowledge ingestion → AI engine: classifies and extracts
- Tenant knowledge ingestion → CRM database: stores knowledge
- Tenant knowledge ingestion → Document storage: stores documents
- Document storage → Cloudflare R2: uploads and downloads
- Automation engine → CRM database: reads and updates
- Automation engine → WhatsApp provider: sends relay message
- WhatsApp service → WhatsApp provider: integrates messaging
- Meta integrations → CRM database: records integration data
- Brokerage users → Sales and commissions: tracks sales
- Sales and commissions → CRM database: reads sales data
- Brokerage users → Reports and exports: views reports
- Brokerage users → Operational dashboards: views operations
- Platform administration → CRM database: administers tenants
