# atum246/keelead architecture

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

- Interactive diagram: https://gitdiagram.com/atum246/keelead
- Repository: https://github.com/atum246/keelead

## Overview

KeeLead is a self-hosted, AI-enabled lead-generation platform. The principal documented workflow is to describe a prospect search in chat, parse the request, gather leads, and present results; company research and email verification are separate supported chat actions. The dashboard also exposes lead management, campaigns, analytics, exports, and compliance. Edges follow shown calls or README statements; unsampled dashboard and API internals are represented without guessed wiring.

Main entry points: [`app/api/chat/route.ts`](https://github.com/atum246/keelead/blob/main/app/api/chat/route.ts) (Chat Handler), [`app/chat/page.tsx`](https://github.com/atum246/keelead/blob/main/app/chat/page.tsx) (AI Chat), [`lib/sources/index.ts`](https://github.com/atum246/keelead/blob/main/lib/sources/index.ts) (Data Sources), [`lib/email/index.ts`](https://github.com/atum246/keelead/blob/main/lib/email/index.ts) (Email Verification)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["User Experience"]
  node_chat["AI Chat<br/>[page.tsx]"]
  node_dashboard["Dashboard"]
  node_chat_api["Chat Handler<br/>[route.ts]"]
end

subgraph group_discovery["Lead Discovery"]
  node_intent["Intent Parsing<br/>[index.ts]"]
  node_lead_engine["Lead Search<br/>[index.ts]"]
  node_source_registry["Data Sources<br/>[index.ts]"]
  node_source_adapters["Source Adapters"]
  node_ai_providers["AI Providers<br/>[index.ts]"]
end

subgraph group_research["Research &amp; Verification"]
  node_company_research["Company Research<br/>[index.ts]"]
  node_email_verification["Email Verification<br/>[index.ts]"]
end

subgraph group_management["Lead Management"]
  node_lead_api["Lead Management API<br/>[route.ts]"]
  node_campaigns["Campaigns<br/>[route.ts]"]
  node_analytics["Analytics<br/>[route.ts]"]
  node_exports["Exports<br/>[route.ts]"]
  node_compliance["Compliance<br/>[index.ts]"]
end

node_user(("User"))

node_user -->|"asks"| node_chat
node_user -->|"manages leads"| node_dashboard
node_chat -.->|"submits message"| node_chat_api
node_chat_api -->|"parses intent"| node_intent
node_chat_api -->|"searches leads"| node_lead_engine
node_chat_api -->|"requests research"| node_company_research
node_chat_api -->|"verifies email"| node_email_verification
node_user -->|"verifies email"| node_email_verification
node_user -->|"searches sources"| node_source_registry
node_source_registry -->|"dispatches searches"| node_source_adapters
node_user -->|"manages campaigns"| node_campaigns
node_user -->|"views reports"| node_analytics
node_user -->|"exports leads"| node_exports
node_user -->|"manages compliance"| node_compliance
node_chat_api -.->|"uses AI"| node_ai_providers

click node_chat "https://github.com/atum246/keelead/blob/main/app/chat/page.tsx"
click node_dashboard "https://github.com/atum246/keelead/tree/main/app/dashboard"
click node_chat_api "https://github.com/atum246/keelead/blob/main/app/api/chat/route.ts"
click node_intent "https://github.com/atum246/keelead/blob/main/lib/ai/index.ts"
click node_lead_engine "https://github.com/atum246/keelead/blob/main/lib/lead-engine/index.ts"
click node_source_registry "https://github.com/atum246/keelead/blob/main/lib/sources/index.ts"
click node_source_adapters "https://github.com/atum246/keelead/tree/main/lib/sources"
click node_company_research "https://github.com/atum246/keelead/blob/main/lib/research/index.ts"
click node_email_verification "https://github.com/atum246/keelead/blob/main/lib/email/index.ts"
click node_lead_api "https://github.com/atum246/keelead/blob/main/app/api/leads/route.ts"
click node_campaigns "https://github.com/atum246/keelead/blob/main/app/api/campaigns/route.ts"
click node_analytics "https://github.com/atum246/keelead/blob/main/app/api/analytics/route.ts"
click node_exports "https://github.com/atum246/keelead/blob/main/app/api/export/route.ts"
click node_compliance "https://github.com/atum246/keelead/blob/main/lib/compliance/index.ts"
click node_ai_providers "https://github.com/atum246/keelead/blob/main/lib/ai/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_chat,node_dashboard,node_chat_api,node_user toneBlue
class node_intent,node_lead_engine,node_source_registry,node_source_adapters,node_ai_providers toneAmber
class node_company_research,node_email_verification toneMint
class node_lead_api,node_campaigns,node_analytics,node_exports,node_compliance toneRose
```

## Components

### User Experience

- [AI Chat](https://github.com/atum246/keelead/blob/main/app/chat/page.tsx): `app/chat/page.tsx`
- [Dashboard](https://github.com/atum246/keelead/tree/main/app/dashboard): `app/dashboard`
- [Chat Handler](https://github.com/atum246/keelead/blob/main/app/api/chat/route.ts): `app/api/chat/route.ts`

### Lead Discovery

- [Intent Parsing](https://github.com/atum246/keelead/blob/main/lib/ai/index.ts): `lib/ai/index.ts`
- [Lead Search](https://github.com/atum246/keelead/blob/main/lib/lead-engine/index.ts): `lib/lead-engine/index.ts`
- [Data Sources](https://github.com/atum246/keelead/blob/main/lib/sources/index.ts): `lib/sources/index.ts`
- [Source Adapters](https://github.com/atum246/keelead/tree/main/lib/sources): `lib/sources`
- [AI Providers](https://github.com/atum246/keelead/blob/main/lib/ai/index.ts): `lib/ai/index.ts`

### Research & Verification

- [Company Research](https://github.com/atum246/keelead/blob/main/lib/research/index.ts): `lib/research/index.ts`
- [Email Verification](https://github.com/atum246/keelead/blob/main/lib/email/index.ts): `lib/email/index.ts`

### Lead Management

- [Lead Management API](https://github.com/atum246/keelead/blob/main/app/api/leads/route.ts): `app/api/leads/route.ts`
- [Campaigns](https://github.com/atum246/keelead/blob/main/app/api/campaigns/route.ts): `app/api/campaigns/route.ts`
- [Analytics](https://github.com/atum246/keelead/blob/main/app/api/analytics/route.ts): `app/api/analytics/route.ts`
- [Exports](https://github.com/atum246/keelead/blob/main/app/api/export/route.ts): `app/api/export/route.ts`
- [Compliance](https://github.com/atum246/keelead/blob/main/lib/compliance/index.ts): `lib/compliance/index.ts`

### Other components

- **User**

## Connections

- User → AI Chat: asks (evidence: `README.md`)
- User → Dashboard: manages leads (evidence: `README.md`)
- AI Chat → Chat Handler: submits message
- Chat Handler → Intent Parsing: parses intent (evidence: `app/api/chat/route.ts`)
- Chat Handler → Lead Search: searches leads (evidence: `app/api/chat/route.ts`)
- Chat Handler → Company Research: requests research (evidence: `app/api/chat/route.ts`)
- Chat Handler → Email Verification: verifies email (evidence: `app/api/chat/route.ts`)
- User → Email Verification: verifies email (evidence: `README.md`)
- User → Data Sources: searches sources (evidence: `README.md`)
- Data Sources → Source Adapters: dispatches searches (evidence: `lib/sources/index.ts`)
- User → Campaigns: manages campaigns (evidence: `README.md`)
- User → Analytics: views reports (evidence: `README.md`)
- User → Exports: exports leads (evidence: `README.md`)
- User → Compliance: manages compliance (evidence: `README.md`)
- Chat Handler → AI Providers: uses AI (evidence: `app/api/chat/route.ts`)
