# suyash2388/harvey-ai-sales-agent architecture

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

- Interactive diagram: https://gitdiagram.com/suyash2388/harvey-ai-sales-agent
- Repository: https://github.com/suyash2388/harvey-ai-sales-agent

## Overview

Harvey is a locally running autonomous sales agent. Its heartbeat prioritizes replies, sending, drafting, and prospecting; prospecting discovers and profiles businesses, while agents find contacts, write campaigns, send only through the approval workflow, and manage replies toward meetings. The dashboard, signal controls, training, and analytics support the same workflow. Edges follow the shown heartbeat, module references, and README; some integrations and unsampled implementation details are not fully evidenced.

Main entry points: [`harvey/main.py`](https://github.com/suyash2388/harvey-ai-sales-agent/blob/main/harvey/main.py) (Heartbeat loop), [`harvey/state.py`](https://github.com/suyash2388/harvey-ai-sales-agent/blob/main/harvey/state.py) (SQLite state), [`harvey/dashboard.py`](https://github.com/suyash2388/harvey-ai-sales-agent/blob/main/harvey/dashboard.py) (Local dashboard), [`harvey/brain.py`](https://github.com/suyash2388/harvey-ai-sales-agent/blob/main/harvey/brain.py) (Model interface)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Heartbeat and reasoning"]
  node_heartbeat["Heartbeat loop<br/>[main.py]"]
  node_brain["Model interface<br/>[brain.py]"]
  node_codex["Codex adapter<br/>[codex.py]"]
end

subgraph group_prospecting["Prospecting and signals"]
  node_pipeline["Prospecting stages<br/>[pipeline.py]"]
  node_discovery["Business discovery<br/>[discover.py]"]
  node_profiling["Website profiling<br/>[profile.py]"]
  node_signals["Signal catalog<br/>[signals.py]"]
end

subgraph group_sales["Sales agents"]
  node_scout["Contact scouting<br/>[scout.py]"]
  node_writer["Campaign writing<br/>[writer.py]"]
  node_sender["Campaign sending<br/>[sender.py]"]
  node_handler["Reply handling<br/>[handler.py]"]
  node_analyst["Sales analysis<br/>[analyst.py]"]
  node_approval["Send approval gate<br/>[gate.py]"]
end

subgraph group_mail["Mail integrations"]
  node_mail_api["Mail abstraction<br/>[mail_provider.py]"]
  node_gmail["Gmail provider<br/>[gmail.py]"]
  node_smtp["SMTP and IMAP<br/>[smtp_mail.py]"]
  node_instantly["Instantly integration<br/>[instantly.py]"]
end

subgraph group_operator["Operator tools and state"]
  node_state[("SQLite state<br/>[state.py]")]
  node_models["Sales data models"]
  node_dashboard["Local dashboard<br/>[dashboard.py]"]
  node_training["Product training<br/>[trainer.py]"]
  node_setup["Setup workflow<br/>[setup.py]"]
  node_config["Configuration<br/>[config.py]"]
  node_export["Data export<br/>[export.py]"]
end

node_operator(("Sales operator"))
node_subscription(("Claude or Codex plan"))
node_mailbox(("Email mailbox"))

node_operator -->|"starts"| node_heartbeat
node_heartbeat -->|"dispatches"| node_scout
node_heartbeat -->|"dispatches"| node_writer
node_heartbeat -->|"dispatches"| node_sender
node_heartbeat -->|"dispatches"| node_handler
node_heartbeat -->|"dispatches"| node_analyst
node_heartbeat -->|"runs profiling"| node_pipeline
node_brain -.->|"delegates optionally"| node_codex
node_brain -->|"uses plan"| node_subscription
node_pipeline -->|"runs discovery"| node_discovery
node_pipeline -->|"runs profiling"| node_profiling
node_discovery -->|"uses signals"| node_signals
node_scout -->|"requests reasoning"| node_brain
node_scout -->|"reads and writes"| node_state
node_writer -->|"requests drafts"| node_brain
node_writer -->|"stores campaigns"| node_state
node_sender -->|"checks approval"| node_approval
node_sender -->|"sends mail"| node_mail_api
node_handler -->|"classifies replies"| node_brain
node_handler -->|"records conversations"| node_state
node_handler -->|"reads replies"| node_mail_api
node_mail_api -->|"builds provider"| node_gmail
node_mail_api -->|"builds provider"| node_smtp
node_sender -.->|"supports legacy sending"| node_instantly
node_mail_api -->|"sends and reads"| node_mailbox
node_state -->|"persists records"| node_models
node_dashboard -->|"reads and updates"| node_state
node_dashboard -->|"controls discovery"| node_pipeline
node_dashboard -->|"confirms signals"| node_signals
node_dashboard -->|"reviews outbox"| node_approval
node_operator -->|"operates"| node_dashboard
node_training -->|"uses reasoning"| node_brain
node_setup -->|"supports training"| node_training
node_setup -->|"configures"| node_config
node_dashboard -->|"offers export"| node_export
node_analyst -->|"reads metrics"| node_state
node_heartbeat -->|"checks pipeline state"| node_state

click node_heartbeat "https://github.com/suyash2388/harvey-ai-sales-agent/blob/main/harvey/main.py"
click node_brain "https://github.com/suyash2388/harvey-ai-sales-agent/blob/main/harvey/brain.py"
click node_codex "https://github.com/suyash2388/harvey-ai-sales-agent/blob/main/harvey/codex.py"
click node_pipeline "https://github.com/suyash2388/harvey-ai-sales-agent/blob/main/harvey/pipeline.py"
click node_discovery "https://github.com/suyash2388/harvey-ai-sales-agent/blob/main/harvey/collectors/discover.py"
click node_profiling "https://github.com/suyash2388/harvey-ai-sales-agent/blob/main/harvey/collectors/profile.py"
click node_signals "https://github.com/suyash2388/harvey-ai-sales-agent/blob/main/harvey/signals.py"
click node_scout "https://github.com/suyash2388/harvey-ai-sales-agent/blob/main/harvey/agents/scout.py"
click node_writer "https://github.com/suyash2388/harvey-ai-sales-agent/blob/main/harvey/agents/writer.py"
click node_sender "https://github.com/suyash2388/harvey-ai-sales-agent/blob/main/harvey/agents/sender.py"
click node_handler "https://github.com/suyash2388/harvey-ai-sales-agent/blob/main/harvey/agents/handler.py"
click node_analyst "https://github.com/suyash2388/harvey-ai-sales-agent/blob/main/harvey/agents/analyst.py"
click node_approval "https://github.com/suyash2388/harvey-ai-sales-agent/blob/main/harvey/gate.py"
click node_mail_api "https://github.com/suyash2388/harvey-ai-sales-agent/blob/main/harvey/integrations/mail_provider.py"
click node_gmail "https://github.com/suyash2388/harvey-ai-sales-agent/blob/main/harvey/integrations/gmail.py"
click node_smtp "https://github.com/suyash2388/harvey-ai-sales-agent/blob/main/harvey/integrations/smtp_mail.py"
click node_instantly "https://github.com/suyash2388/harvey-ai-sales-agent/blob/main/harvey/integrations/instantly.py"
click node_state "https://github.com/suyash2388/harvey-ai-sales-agent/blob/main/harvey/state.py"
click node_models "https://github.com/suyash2388/harvey-ai-sales-agent/tree/main/harvey/models"
click node_dashboard "https://github.com/suyash2388/harvey-ai-sales-agent/blob/main/harvey/dashboard.py"
click node_training "https://github.com/suyash2388/harvey-ai-sales-agent/blob/main/harvey/trainer.py"
click node_setup "https://github.com/suyash2388/harvey-ai-sales-agent/blob/main/harvey/setup.py"
click node_config "https://github.com/suyash2388/harvey-ai-sales-agent/blob/main/harvey/config.py"
click node_export "https://github.com/suyash2388/harvey-ai-sales-agent/blob/main/harvey/export.py"

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_heartbeat,node_brain,node_codex toneBlue
class node_pipeline,node_discovery,node_profiling,node_signals toneAmber
class node_scout,node_writer,node_sender,node_handler,node_analyst,node_approval toneMint
class node_mail_api,node_gmail,node_smtp,node_instantly toneRose
class node_state,node_models,node_dashboard,node_training,node_setup,node_config,node_export,node_operator,node_subscription,node_mailbox toneIndigo
```

## Components

### Heartbeat and reasoning

- [Heartbeat loop](https://github.com/suyash2388/harvey-ai-sales-agent/blob/main/harvey/main.py): `harvey/main.py`
- [Model interface](https://github.com/suyash2388/harvey-ai-sales-agent/blob/main/harvey/brain.py): `harvey/brain.py`
- [Codex adapter](https://github.com/suyash2388/harvey-ai-sales-agent/blob/main/harvey/codex.py): `harvey/codex.py`

### Prospecting and signals

- [Prospecting stages](https://github.com/suyash2388/harvey-ai-sales-agent/blob/main/harvey/pipeline.py): `harvey/pipeline.py`
- [Business discovery](https://github.com/suyash2388/harvey-ai-sales-agent/blob/main/harvey/collectors/discover.py): `harvey/collectors/discover.py`
- [Website profiling](https://github.com/suyash2388/harvey-ai-sales-agent/blob/main/harvey/collectors/profile.py): `harvey/collectors/profile.py`
- [Signal catalog](https://github.com/suyash2388/harvey-ai-sales-agent/blob/main/harvey/signals.py): `harvey/signals.py`

### Sales agents

- [Contact scouting](https://github.com/suyash2388/harvey-ai-sales-agent/blob/main/harvey/agents/scout.py): `harvey/agents/scout.py`
- [Campaign writing](https://github.com/suyash2388/harvey-ai-sales-agent/blob/main/harvey/agents/writer.py): `harvey/agents/writer.py`
- [Campaign sending](https://github.com/suyash2388/harvey-ai-sales-agent/blob/main/harvey/agents/sender.py): `harvey/agents/sender.py`
- [Reply handling](https://github.com/suyash2388/harvey-ai-sales-agent/blob/main/harvey/agents/handler.py): `harvey/agents/handler.py`
- [Sales analysis](https://github.com/suyash2388/harvey-ai-sales-agent/blob/main/harvey/agents/analyst.py): `harvey/agents/analyst.py`
- [Send approval gate](https://github.com/suyash2388/harvey-ai-sales-agent/blob/main/harvey/gate.py): `harvey/gate.py`

### Mail integrations

- [Mail abstraction](https://github.com/suyash2388/harvey-ai-sales-agent/blob/main/harvey/integrations/mail_provider.py): `harvey/integrations/mail_provider.py`
- [Gmail provider](https://github.com/suyash2388/harvey-ai-sales-agent/blob/main/harvey/integrations/gmail.py): `harvey/integrations/gmail.py`
- [SMTP and IMAP](https://github.com/suyash2388/harvey-ai-sales-agent/blob/main/harvey/integrations/smtp_mail.py): `harvey/integrations/smtp_mail.py`
- [Instantly integration](https://github.com/suyash2388/harvey-ai-sales-agent/blob/main/harvey/integrations/instantly.py): `harvey/integrations/instantly.py`

### Operator tools and state

- [SQLite state](https://github.com/suyash2388/harvey-ai-sales-agent/blob/main/harvey/state.py): `harvey/state.py`
- [Sales data models](https://github.com/suyash2388/harvey-ai-sales-agent/tree/main/harvey/models): `harvey/models`
- [Local dashboard](https://github.com/suyash2388/harvey-ai-sales-agent/blob/main/harvey/dashboard.py): `harvey/dashboard.py`
- [Product training](https://github.com/suyash2388/harvey-ai-sales-agent/blob/main/harvey/trainer.py): `harvey/trainer.py`
- [Setup workflow](https://github.com/suyash2388/harvey-ai-sales-agent/blob/main/harvey/setup.py): `harvey/setup.py`
- [Configuration](https://github.com/suyash2388/harvey-ai-sales-agent/blob/main/harvey/config.py): `harvey/config.py`
- [Data export](https://github.com/suyash2388/harvey-ai-sales-agent/blob/main/harvey/export.py): `harvey/export.py`

### Other components

- **Sales operator**
- **Claude or Codex plan**
- **Email mailbox**

## Connections

- Sales operator → Heartbeat loop: starts
- Heartbeat loop → Contact scouting: dispatches (evidence: `harvey/main.py`)
- Heartbeat loop → Campaign writing: dispatches (evidence: `harvey/main.py`)
- Heartbeat loop → Campaign sending: dispatches (evidence: `harvey/main.py`)
- Heartbeat loop → Reply handling: dispatches (evidence: `harvey/main.py`)
- Heartbeat loop → Sales analysis: dispatches (evidence: `harvey/main.py`)
- Heartbeat loop → Prospecting stages: runs profiling (evidence: `harvey/main.py`)
- Model interface → Codex adapter: delegates optionally (evidence: `harvey/brain.py`)
- Model interface → Claude or Codex plan: uses plan
- Prospecting stages → Business discovery: runs discovery (evidence: `harvey/pipeline.py`)
- Prospecting stages → Website profiling: runs profiling (evidence: `harvey/pipeline.py`)
- Business discovery → Signal catalog: uses signals (evidence: `harvey/collectors/discover.py`)
- Contact scouting → Model interface: requests reasoning (evidence: `harvey/agents/scout.py`)
- Contact scouting → SQLite state: reads and writes (evidence: `harvey/agents/scout.py`)
- Campaign writing → Model interface: requests drafts (evidence: `harvey/agents/writer.py`)
- Campaign writing → SQLite state: stores campaigns (evidence: `harvey/agents/writer.py`)
- Campaign sending → Send approval gate: checks approval (evidence: `harvey/agents/sender.py`)
- Campaign sending → Mail abstraction: sends mail (evidence: `harvey/agents/sender.py`)
- Reply handling → Model interface: classifies replies (evidence: `harvey/agents/handler.py`)
- Reply handling → SQLite state: records conversations (evidence: `harvey/agents/handler.py`)
- Reply handling → Mail abstraction: reads replies (evidence: `harvey/agents/handler.py`)
- Mail abstraction → Gmail provider: builds provider (evidence: `harvey/integrations/mail_provider.py`)
- Mail abstraction → SMTP and IMAP: builds provider (evidence: `harvey/integrations/mail_provider.py`)
- Campaign sending → Instantly integration: supports legacy sending (evidence: `harvey/agents/sender.py`)
- Mail abstraction → Email mailbox: sends and reads (evidence: `harvey/integrations/mail_provider.py`)
- SQLite state → Sales data models: persists records (evidence: `harvey/state.py`)
- Local dashboard → SQLite state: reads and updates (evidence: `harvey/dashboard.py`)
- Local dashboard → Prospecting stages: controls discovery (evidence: `harvey/dashboard.py`)
- Local dashboard → Signal catalog: confirms signals (evidence: `harvey/dashboard.py`)
- Local dashboard → Send approval gate: reviews outbox
- Sales operator → Local dashboard: operates
- Product training → Model interface: uses reasoning (evidence: `harvey/trainer.py`)
- Setup workflow → Product training: supports training (evidence: `harvey/setup.py`)
- Setup workflow → Configuration: configures (evidence: `harvey/setup.py`)
- Local dashboard → Data export: offers export (evidence: `harvey/dashboard.py`)
- Sales analysis → SQLite state: reads metrics (evidence: `harvey/agents/analyst.py`)
- Heartbeat loop → SQLite state: checks pipeline state (evidence: `harvey/main.py`)
