# bhavya-dhanwani/easysales architecture

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

- Interactive diagram: https://gitdiagram.com/bhavya-dhanwani/easysales
- Repository: https://github.com/bhavya-dhanwani/easysales

## Overview

easySales is a multi-tenant AI business-development platform. Teams configure a sales profile, discover and select prospects, research and qualify leads, then authorize outreach under tenant-defined policy; replies, requirements, proposals, and optional demos continue the sales workflow. The React client exposes these capabilities through an API, while a durable worker runs agent workflows and integrations. The README documents several subsystems whose implementation excerpts were not provided; those capabilities are represented at their documented directory level, and evidence limits are reflected in the edges.

Main entry points: [`server/src/agents`](https://github.com/bhavya-dhanwani/easysales/tree/main/server/src/agents) (AI agents and graphs), [`server/src/shared/outbound/outbound.service.ts`](https://github.com/bhavya-dhanwani/easysales/blob/main/server/src/shared/outbound/outbound.service.ts) (Outbound and outbox), [`server/src/jobs/worker.ts`](https://github.com/bhavya-dhanwani/easysales/blob/main/server/src/jobs/worker.ts) (Workflow worker), [`server/src/shared/policy/policy.engine.ts`](https://github.com/bhavya-dhanwani/easysales/blob/main/server/src/shared/policy/policy.engine.ts) (Policy engine)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Client experience"]
  node_clientapp["Web application<br/>[App.tsx]"]
  node_authui["Authentication UI<br/>[Auth.tsx]"]
  node_authstate["Session and organization state<br/>[auth.tsx]"]
  node_api["API client<br/>[api.ts]"]
  node_salesui["Sales workspace views"]
end

subgraph group_sales["Prospect and sales workflows"]
  node_discovery["Lead discovery"]
  node_leadroutes["Lead and opportunity APIs"]
  node_research["Research and qualification"]
  node_agents["AI agents and graphs"]
  node_conversation["Replies and requirements"]
  node_outbound["Outbound and outbox"]
  node_proposal["Proposal workflow"]
  node_prototype["Demo prototypes"]
end

subgraph group_governance["Policy and controls"]
  node_policy["Policy engine<br/>[policy.engine.ts]"]
  node_approvals["Human approvals"]
  node_billing["Plans and budgets"]
end

subgraph group_platform["Platform services"]
  node_httpapi["HTTP API<br/>[app.ts]"]
  node_authroutes["Authentication routes<br/>[auth.router.ts]"]
  node_authcontroller["Authentication controller<br/>[auth.controller.ts]"]
  node_worker["Workflow worker<br/>[worker.ts]"]
  node_tenancy["Tenant context and access"]
  node_database[("MongoDB")]
end

subgraph group_operations["Operations and integrations"]
  node_integrations["CRM and calendar sync"]
  node_analytics["Funnel analytics"]
  node_emailprovider["Email delivery and inbox<br/>[email.provider.ts]"]
end

node_user(("Workspace user"))
node_external["Search and web sources"]

node_user -->|"uses"| node_clientapp
node_clientapp -->|"routes to"| node_authui
node_clientapp -->|"routes to"| node_salesui
node_authui -->|"authenticates through"| node_authstate
node_authstate -->|"calls"| node_api
node_salesui -->|"requests data"| node_api
node_api -.->|"sends requests"| node_httpapi
node_httpapi -->|"mounts routes"| node_authroutes
node_authroutes -->|"dispatches"| node_authcontroller
node_authcontroller -->|"creates workspace"| node_tenancy
node_user -.->|"sets niche and selects leads"| node_discovery
node_external -.->|"provides search results"| node_discovery
node_leadroutes -.->|"offers lead discovery"| node_discovery
node_leadroutes -.->|"queues research"| node_worker
node_worker -->|"runs graphs"| node_agents
node_agents -->|"researches prospects"| node_research
node_research -->|"loads policy"| node_policy
node_research -->|"invokes research agent"| node_agents
node_agents -.->|"handles replies"| node_conversation
node_conversation -.->|"proposes replies"| node_outbound
node_outbound -.->|"checks actions"| node_policy
node_outbound -.->|"requests review"| node_approvals
node_approvals -.->|"authorizes sending"| node_outbound
node_outbound -.->|"delivers messages"| node_emailprovider
node_emailprovider -.->|"returns replies"| node_conversation
node_conversation -.->|"starts conversation workflow"| node_agents
node_agents -.->|"drafts proposal"| node_proposal
node_proposal -->|"checks proposal action"| node_policy
node_proposal -.->|"requires approval"| node_approvals
node_proposal -.->|"sends approved proposal"| node_outbound
node_worker -->|"runs sync"| node_integrations
node_user -.->|"requests demo"| node_prototype
node_prototype -.->|"checks build eligibility"| node_policy
node_prototype -.->|"routes for review"| node_approvals
node_worker -.->|"records workflow outcomes"| node_analytics
node_policy -.->|"applies budget limits"| node_billing
node_httpapi -.->|"resolves tenant access"| node_tenancy
node_worker -.->|"persists workflow state"| node_database
node_tenancy -.->|"scopes tenant data"| node_database

click node_clientapp "https://github.com/bhavya-dhanwani/easysales/blob/main/client/src/App.tsx"
click node_authui "https://github.com/bhavya-dhanwani/easysales/blob/main/client/src/pages/Auth.tsx"
click node_authstate "https://github.com/bhavya-dhanwani/easysales/blob/main/client/src/lib/auth.tsx"
click node_api "https://github.com/bhavya-dhanwani/easysales/blob/main/client/src/lib/api.ts"
click node_salesui "https://github.com/bhavya-dhanwani/easysales/tree/main/client/src/app"
click node_httpapi "https://github.com/bhavya-dhanwani/easysales/blob/main/server/src/app.ts"
click node_authroutes "https://github.com/bhavya-dhanwani/easysales/blob/main/server/src/modules/public/auth/auth.router.ts"
click node_authcontroller "https://github.com/bhavya-dhanwani/easysales/blob/main/server/src/modules/public/auth/auth.controller.ts"
click node_discovery "https://github.com/bhavya-dhanwani/easysales/tree/main/server/src/shared/discovery"
click node_leadroutes "https://github.com/bhavya-dhanwani/easysales/tree/main/server/src/modules/private/leads"
click node_research "https://github.com/bhavya-dhanwani/easysales/blob/main/server/src/shared/research/research.service.ts"
click node_agents "https://github.com/bhavya-dhanwani/easysales/tree/main/server/src/agents"
click node_worker "https://github.com/bhavya-dhanwani/easysales/blob/main/server/src/jobs/worker.ts"
click node_conversation "https://github.com/bhavya-dhanwani/easysales/tree/main/server/src/shared/conversations"
click node_outbound "https://github.com/bhavya-dhanwani/easysales/blob/main/server/src/shared/outbound/outbound.service.ts"
click node_proposal "https://github.com/bhavya-dhanwani/easysales/blob/main/server/src/shared/proposals/proposal.service.ts"
click node_prototype "https://github.com/bhavya-dhanwani/easysales/tree/main/server/src/shared/prototypes"
click node_policy "https://github.com/bhavya-dhanwani/easysales/blob/main/server/src/shared/policy/policy.engine.ts"
click node_approvals "https://github.com/bhavya-dhanwani/easysales/tree/main/server/src/shared/approvals"
click node_billing "https://github.com/bhavya-dhanwani/easysales/tree/main/server/src/shared/billing"
click node_integrations "https://github.com/bhavya-dhanwani/easysales/tree/main/server/src/shared/integrations"
click node_analytics "https://github.com/bhavya-dhanwani/easysales/blob/main/server/src/shared/analytics/analytics.service.ts"
click node_tenancy "https://github.com/bhavya-dhanwani/easysales/tree/main/server/src/shared/tenancy"
click node_database "https://github.com/bhavya-dhanwani/easysales/tree/main/server/src/shared/models"
click node_emailprovider "https://github.com/bhavya-dhanwani/easysales/blob/main/server/src/providers/email.provider.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_clientapp,node_authui,node_authstate,node_api,node_salesui,node_user toneBlue
class node_discovery,node_leadroutes,node_research,node_agents,node_conversation,node_outbound,node_proposal,node_prototype toneAmber
class node_policy,node_approvals,node_billing toneMint
class node_httpapi,node_authroutes,node_authcontroller,node_worker,node_tenancy,node_database toneRose
class node_integrations,node_analytics,node_emailprovider,node_external toneIndigo
```

## Components

### Client experience

- [Web application](https://github.com/bhavya-dhanwani/easysales/blob/main/client/src/App.tsx): `client/src/App.tsx`
- [Authentication UI](https://github.com/bhavya-dhanwani/easysales/blob/main/client/src/pages/Auth.tsx): `client/src/pages/Auth.tsx`
- [Session and organization state](https://github.com/bhavya-dhanwani/easysales/blob/main/client/src/lib/auth.tsx): `client/src/lib/auth.tsx`
- [API client](https://github.com/bhavya-dhanwani/easysales/blob/main/client/src/lib/api.ts): `client/src/lib/api.ts`
- [Sales workspace views](https://github.com/bhavya-dhanwani/easysales/tree/main/client/src/app): `client/src/app`

### Prospect and sales workflows

- [Lead discovery](https://github.com/bhavya-dhanwani/easysales/tree/main/server/src/shared/discovery): `server/src/shared/discovery`
- [Lead and opportunity APIs](https://github.com/bhavya-dhanwani/easysales/tree/main/server/src/modules/private/leads): `server/src/modules/private/leads`
- [Research and qualification](https://github.com/bhavya-dhanwani/easysales/blob/main/server/src/shared/research/research.service.ts): `server/src/shared/research/research.service.ts`
- [AI agents and graphs](https://github.com/bhavya-dhanwani/easysales/tree/main/server/src/agents): `server/src/agents`
- [Replies and requirements](https://github.com/bhavya-dhanwani/easysales/tree/main/server/src/shared/conversations): `server/src/shared/conversations`
- [Outbound and outbox](https://github.com/bhavya-dhanwani/easysales/blob/main/server/src/shared/outbound/outbound.service.ts): `server/src/shared/outbound/outbound.service.ts`
- [Proposal workflow](https://github.com/bhavya-dhanwani/easysales/blob/main/server/src/shared/proposals/proposal.service.ts): `server/src/shared/proposals/proposal.service.ts`
- [Demo prototypes](https://github.com/bhavya-dhanwani/easysales/tree/main/server/src/shared/prototypes): `server/src/shared/prototypes`

### Policy and controls

- [Policy engine](https://github.com/bhavya-dhanwani/easysales/blob/main/server/src/shared/policy/policy.engine.ts): `server/src/shared/policy/policy.engine.ts`
- [Human approvals](https://github.com/bhavya-dhanwani/easysales/tree/main/server/src/shared/approvals): `server/src/shared/approvals`
- [Plans and budgets](https://github.com/bhavya-dhanwani/easysales/tree/main/server/src/shared/billing): `server/src/shared/billing`

### Platform services

- [HTTP API](https://github.com/bhavya-dhanwani/easysales/blob/main/server/src/app.ts): `server/src/app.ts`
- [Authentication routes](https://github.com/bhavya-dhanwani/easysales/blob/main/server/src/modules/public/auth/auth.router.ts): `server/src/modules/public/auth/auth.router.ts`
- [Authentication controller](https://github.com/bhavya-dhanwani/easysales/blob/main/server/src/modules/public/auth/auth.controller.ts): `server/src/modules/public/auth/auth.controller.ts`
- [Workflow worker](https://github.com/bhavya-dhanwani/easysales/blob/main/server/src/jobs/worker.ts): `server/src/jobs/worker.ts`
- [Tenant context and access](https://github.com/bhavya-dhanwani/easysales/tree/main/server/src/shared/tenancy): `server/src/shared/tenancy`
- [MongoDB](https://github.com/bhavya-dhanwani/easysales/tree/main/server/src/shared/models): `server/src/shared/models`

### Operations and integrations

- [CRM and calendar sync](https://github.com/bhavya-dhanwani/easysales/tree/main/server/src/shared/integrations): `server/src/shared/integrations`
- [Funnel analytics](https://github.com/bhavya-dhanwani/easysales/blob/main/server/src/shared/analytics/analytics.service.ts): `server/src/shared/analytics/analytics.service.ts`
- [Email delivery and inbox](https://github.com/bhavya-dhanwani/easysales/blob/main/server/src/providers/email.provider.ts): `server/src/providers/email.provider.ts`

### Other components

- **Workspace user**
- **Search and web sources**

## Connections

- Workspace user → Web application: uses (evidence: `client/src/App.tsx`)
- Web application → Authentication UI: routes to (evidence: `client/src/App.tsx`)
- Web application → Sales workspace views: routes to (evidence: `client/src/App.tsx`)
- Authentication UI → Session and organization state: authenticates through (evidence: `client/src/pages/Auth.tsx`)
- Session and organization state → API client: calls (evidence: `client/src/lib/auth.tsx`)
- Sales workspace views → API client: requests data (evidence: `client/src/app/Research.tsx`)
- API client → HTTP API: sends requests
- HTTP API → Authentication routes: mounts routes (evidence: `server/src/app.ts`)
- Authentication routes → Authentication controller: dispatches (evidence: `server/src/modules/public/auth/auth.router.ts`)
- Authentication controller → Tenant context and access: creates workspace (evidence: `server/src/modules/public/auth/auth.controller.ts`)
- Workspace user → Lead discovery: sets niche and selects leads (evidence: `README.md`)
- Search and web sources → Lead discovery: provides search results (evidence: `README.md`)
- Lead and opportunity APIs → Lead discovery: offers lead discovery (evidence: `README.md`)
- Lead and opportunity APIs → Workflow worker: queues research (evidence: `README.md`)
- Workflow worker → AI agents and graphs: runs graphs (evidence: `server/src/jobs/worker.ts`)
- AI agents and graphs → Research and qualification: researches prospects (evidence: `server/src/shared/research/research.service.ts`)
- Research and qualification → Policy engine: loads policy (evidence: `server/src/shared/research/research.service.ts`)
- Research and qualification → AI agents and graphs: invokes research agent (evidence: `server/src/shared/research/research.service.ts`)
- AI agents and graphs → Replies and requirements: handles replies (evidence: `README.md`)
- Replies and requirements → Outbound and outbox: proposes replies (evidence: `README.md`)
- Outbound and outbox → Policy engine: checks actions (evidence: `README.md`)
- Outbound and outbox → Human approvals: requests review (evidence: `README.md`)
- Human approvals → Outbound and outbox: authorizes sending (evidence: `README.md`)
- Outbound and outbox → Email delivery and inbox: delivers messages (evidence: `README.md`)
- Email delivery and inbox → Replies and requirements: returns replies (evidence: `README.md`)
- Replies and requirements → AI agents and graphs: starts conversation workflow (evidence: `README.md`)
- AI agents and graphs → Proposal workflow: drafts proposal (evidence: `README.md`)
- Proposal workflow → Policy engine: checks proposal action (evidence: `server/src/shared/proposals/proposal.service.ts`)
- Proposal workflow → Human approvals: requires approval (evidence: `README.md`)
- Proposal workflow → Outbound and outbox: sends approved proposal (evidence: `README.md`)
- Workflow worker → CRM and calendar sync: runs sync (evidence: `server/src/jobs/worker.ts`)
- Workspace user → Demo prototypes: requests demo (evidence: `README.md`)
- Demo prototypes → Policy engine: checks build eligibility (evidence: `README.md`)
- Demo prototypes → Human approvals: routes for review (evidence: `README.md`)
- Workflow worker → Funnel analytics: records workflow outcomes (evidence: `README.md`)
- Policy engine → Plans and budgets: applies budget limits (evidence: `README.md`)
- HTTP API → Tenant context and access: resolves tenant access (evidence: `README.md`)
- Workflow worker → MongoDB: persists workflow state (evidence: `README.md`)
- Tenant context and access → MongoDB: scopes tenant data (evidence: `README.md`)
