# ranjith-fullstack/leadpilot-ai architecture

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

- Interactive diagram: https://gitdiagram.com/ranjith-fullstack/leadpilot-ai
- Repository: https://github.com/ranjith-fullstack/leadpilot-ai

## Overview

LeadPilot AI is a multi-tenant CRM workspace. Users enter through the React app, authenticate and select an organization, then work with leads and related discovery, enrichment, verification, and scoring capabilities; the broader product also supports campaigns, sales operations, customer portals, and SaaS administration. The backend exposes domain services and persists application state in PostgreSQL. Edges are limited to relationships shown in excerpts, the SOURCE INDEX, or the README; unsampled subsystem wiring is not asserted.

Main entry points: [`backend/src/lib/prisma.js`](https://github.com/ranjith-fullstack/leadpilot-ai/blob/main/backend/src/lib/prisma.js) (PostgreSQL), [`frontend/src/app/App.jsx`](https://github.com/ranjith-fullstack/leadpilot-ai/blob/main/frontend/src/app/App.jsx) (React application), [`backend/src/modules/billing/billing.service.js`](https://github.com/ranjith-fullstack/leadpilot-ai/blob/main/backend/src/modules/billing/billing.service.js) (SaaS billing), [`frontend/src/context/OrganizationContext.jsx`](https://github.com/ranjith-fullstack/leadpilot-ai/blob/main/frontend/src/context/OrganizationContext.jsx) (Organization context)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Workspace client"]
  node_app["React application<br/>[App.jsx]"]
  node_routes["Workspace routes<br/>[AppRoutes.jsx]"]
  node_authctx["Authentication context<br/>[AuthContext.jsx]"]
  node_orgctx["Organization context"]
  node_api["API client<br/>[api.js]"]
end

subgraph group_leadops["Lead operations"]
  node_leads["Lead management"]
  node_discovery["Lead discovery"]
  node_enrichment["Lead enrichment"]
  node_verification["Email verification"]
  node_scoring["Lead scoring"]
end

subgraph group_revenue["Revenue operations"]
  node_campaigns["Campaign management"]
  node_delivery["Email delivery"]
  node_pipeline["Sales pipeline<br/>[PipelinePage.jsx]"]
  node_proposals["Proposals"]
  node_invoices["Invoices and payments"]
  node_portal["Customer portal"]
  node_automation["Workflow automation"]
end

subgraph group_platform["Platform services"]
  node_billing["SaaS billing<br/>[billing.service.js]"]
  node_admin["Tenant administration"]
  node_permissions["Permission policy"]
  node_database[("PostgreSQL<br/>[prisma.js]")]
end

node_user(("Workspace user"))

node_user -->|"uses"| node_app
node_app -->|"renders"| node_routes
node_app -->|"provides auth"| node_authctx
node_app -->|"provides org"| node_orgctx
node_routes -->|"routes to"| node_pipeline
node_orgctx -->|"reads identity"| node_authctx
node_orgctx -->|"loads organizations"| node_api
node_pipeline -->|"requests data"| node_api
node_leads -->|"queries membership"| node_database
node_leads -->|"checks usage"| node_billing
node_campaigns -->|"checks usage"| node_billing
node_campaigns -.->|"persists records"| node_database
node_delivery -->|"reads and writes"| node_database
node_billing -->|"stores subscriptions"| node_database
node_billing -->|"authorizes access"| node_permissions
node_automation -.->|"persists workflows"| node_database

click node_app "https://github.com/ranjith-fullstack/leadpilot-ai/blob/main/frontend/src/app/App.jsx"
click node_routes "https://github.com/ranjith-fullstack/leadpilot-ai/blob/main/frontend/src/app/AppRoutes.jsx"
click node_authctx "https://github.com/ranjith-fullstack/leadpilot-ai/blob/main/frontend/src/context/AuthContext.jsx"
click node_orgctx "https://github.com/ranjith-fullstack/leadpilot-ai/blob/main/frontend/src/context/OrganizationContext.jsx"
click node_api "https://github.com/ranjith-fullstack/leadpilot-ai/blob/main/frontend/src/services/api.js"
click node_leads "https://github.com/ranjith-fullstack/leadpilot-ai/blob/main/backend/src/modules/leads/leads.controller.js"
click node_discovery "https://github.com/ranjith-fullstack/leadpilot-ai/tree/main/backend/src/modules/discovery"
click node_enrichment "https://github.com/ranjith-fullstack/leadpilot-ai/tree/main/backend/src/modules/enrichment"
click node_verification "https://github.com/ranjith-fullstack/leadpilot-ai/tree/main/backend/src/modules/verification"
click node_scoring "https://github.com/ranjith-fullstack/leadpilot-ai/tree/main/backend/src/modules/scoring"
click node_campaigns "https://github.com/ranjith-fullstack/leadpilot-ai/blob/main/backend/src/modules/campaigns/campaigns.controller.js"
click node_delivery "https://github.com/ranjith-fullstack/leadpilot-ai/blob/main/backend/src/modules/emailDelivery/emailDelivery.controller.js"
click node_pipeline "https://github.com/ranjith-fullstack/leadpilot-ai/blob/main/frontend/src/features/pipeline/PipelinePage.jsx"
click node_proposals "https://github.com/ranjith-fullstack/leadpilot-ai/blob/main/backend/src/modules/proposals/proposals.controller.js"
click node_invoices "https://github.com/ranjith-fullstack/leadpilot-ai/tree/main/backend/src/modules/invoices"
click node_portal "https://github.com/ranjith-fullstack/leadpilot-ai/tree/main/backend/src/modules/customerPortal"
click node_automation "https://github.com/ranjith-fullstack/leadpilot-ai/blob/main/backend/src/modules/workflows/workflows.service.js"
click node_billing "https://github.com/ranjith-fullstack/leadpilot-ai/blob/main/backend/src/modules/billing/billing.service.js"
click node_admin "https://github.com/ranjith-fullstack/leadpilot-ai/tree/main/backend/src/modules/admin"
click node_permissions "https://github.com/ranjith-fullstack/leadpilot-ai/blob/main/backend/src/services/permission.service.js"
click node_database "https://github.com/ranjith-fullstack/leadpilot-ai/blob/main/backend/src/lib/prisma.js"

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_app,node_routes,node_authctx,node_orgctx,node_api,node_user toneBlue
class node_leads,node_discovery,node_enrichment,node_verification,node_scoring toneAmber
class node_campaigns,node_delivery,node_pipeline,node_proposals,node_invoices,node_portal,node_automation toneMint
class node_billing,node_admin,node_permissions,node_database toneRose
```

## Components

### Workspace client

- [React application](https://github.com/ranjith-fullstack/leadpilot-ai/blob/main/frontend/src/app/App.jsx): `frontend/src/app/App.jsx`
- [Workspace routes](https://github.com/ranjith-fullstack/leadpilot-ai/blob/main/frontend/src/app/AppRoutes.jsx): `frontend/src/app/AppRoutes.jsx`
- [Authentication context](https://github.com/ranjith-fullstack/leadpilot-ai/blob/main/frontend/src/context/AuthContext.jsx): `frontend/src/context/AuthContext.jsx`
- [Organization context](https://github.com/ranjith-fullstack/leadpilot-ai/blob/main/frontend/src/context/OrganizationContext.jsx): `frontend/src/context/OrganizationContext.jsx`
- [API client](https://github.com/ranjith-fullstack/leadpilot-ai/blob/main/frontend/src/services/api.js): `frontend/src/services/api.js`

### Lead operations

- [Lead management](https://github.com/ranjith-fullstack/leadpilot-ai/blob/main/backend/src/modules/leads/leads.controller.js): `backend/src/modules/leads/leads.controller.js`
- [Lead discovery](https://github.com/ranjith-fullstack/leadpilot-ai/tree/main/backend/src/modules/discovery): `backend/src/modules/discovery`
- [Lead enrichment](https://github.com/ranjith-fullstack/leadpilot-ai/tree/main/backend/src/modules/enrichment): `backend/src/modules/enrichment`
- [Email verification](https://github.com/ranjith-fullstack/leadpilot-ai/tree/main/backend/src/modules/verification): `backend/src/modules/verification`
- [Lead scoring](https://github.com/ranjith-fullstack/leadpilot-ai/tree/main/backend/src/modules/scoring): `backend/src/modules/scoring`

### Revenue operations

- [Campaign management](https://github.com/ranjith-fullstack/leadpilot-ai/blob/main/backend/src/modules/campaigns/campaigns.controller.js): `backend/src/modules/campaigns/campaigns.controller.js`
- [Email delivery](https://github.com/ranjith-fullstack/leadpilot-ai/blob/main/backend/src/modules/emailDelivery/emailDelivery.controller.js): `backend/src/modules/emailDelivery/emailDelivery.controller.js`
- [Sales pipeline](https://github.com/ranjith-fullstack/leadpilot-ai/blob/main/frontend/src/features/pipeline/PipelinePage.jsx): `frontend/src/features/pipeline/PipelinePage.jsx`
- [Proposals](https://github.com/ranjith-fullstack/leadpilot-ai/blob/main/backend/src/modules/proposals/proposals.controller.js): `backend/src/modules/proposals/proposals.controller.js`
- [Invoices and payments](https://github.com/ranjith-fullstack/leadpilot-ai/tree/main/backend/src/modules/invoices): `backend/src/modules/invoices`
- [Customer portal](https://github.com/ranjith-fullstack/leadpilot-ai/tree/main/backend/src/modules/customerPortal): `backend/src/modules/customerPortal`
- [Workflow automation](https://github.com/ranjith-fullstack/leadpilot-ai/blob/main/backend/src/modules/workflows/workflows.service.js): `backend/src/modules/workflows/workflows.service.js`

### Platform services

- [SaaS billing](https://github.com/ranjith-fullstack/leadpilot-ai/blob/main/backend/src/modules/billing/billing.service.js): `backend/src/modules/billing/billing.service.js`
- [Tenant administration](https://github.com/ranjith-fullstack/leadpilot-ai/tree/main/backend/src/modules/admin): `backend/src/modules/admin`
- [Permission policy](https://github.com/ranjith-fullstack/leadpilot-ai/blob/main/backend/src/services/permission.service.js): `backend/src/services/permission.service.js`
- [PostgreSQL](https://github.com/ranjith-fullstack/leadpilot-ai/blob/main/backend/src/lib/prisma.js): `backend/src/lib/prisma.js`

### Other components

- **Workspace user**

## Connections

- Workspace user → React application: uses (evidence: `frontend/src/app/App.jsx`)
- React application → Workspace routes: renders (evidence: `frontend/src/app/App.jsx`)
- React application → Authentication context: provides auth (evidence: `frontend/src/app/App.jsx`)
- React application → Organization context: provides org (evidence: `frontend/src/app/App.jsx`)
- Workspace routes → Sales pipeline: routes to (evidence: `frontend/src/app/AppRoutes.jsx`)
- Organization context → Authentication context: reads identity (evidence: `frontend/src/context/OrganizationContext.jsx`)
- Organization context → API client: loads organizations
- Sales pipeline → API client: requests data
- Lead management → PostgreSQL: queries membership (evidence: `backend/src/modules/leads/leads.controller.js`)
- Lead management → SaaS billing: checks usage (evidence: `backend/src/modules/leads/leads.controller.js`)
- Campaign management → SaaS billing: checks usage (evidence: `backend/src/modules/campaigns/campaigns.controller.js`)
- Campaign management → PostgreSQL: persists records (evidence: `backend/src/modules/campaigns/campaigns.controller.js`)
- Email delivery → PostgreSQL: reads and writes (evidence: `backend/src/modules/emailDelivery/emailDelivery.controller.js`)
- SaaS billing → PostgreSQL: stores subscriptions (evidence: `backend/src/modules/billing/billing.service.js`)
- SaaS billing → Permission policy: authorizes access (evidence: `backend/src/modules/billing/billing.controller.js`)
- Workflow automation → PostgreSQL: persists workflows
