# asiifdev/business-leads-ai-automation architecture

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

- Interactive diagram: https://gitdiagram.com/asiifdev/business-leads-ai-automation
- Repository: https://github.com/asiifdev/business-leads-ai-automation

## Overview

Prospex is a self-hosted GTM platform whose main workflow is creating a campaign, queuing Google Maps discovery, scoring leads, generating personalized outreach, and managing results in a CRM. The dashboard exposes campaign, lead, analytics, export, workspace, and integration features through a NestJS API backed by Prisma. The queue-to-worker and AI processing stages are documented in the README, but their internal calls are not shown in the sampled worker source, so those links are identified as documented rather than inferred from imports.

Main entry points: [`apps/web/src/app/(dashboard)`](https://github.com/asiifdev/business-leads-ai-automation/tree/main/apps/web/src/app/(dashboard)) (Web dashboard), [`apps/api/src/scraper/scraper.processor.ts`](https://github.com/asiifdev/business-leads-ai-automation/blob/main/apps/api/src/scraper/scraper.processor.ts) (Scrape and scoring worker), [`apps/api/src/prisma/prisma.service.ts`](https://github.com/asiifdev/business-leads-ai-automation/blob/main/apps/api/src/prisma/prisma.service.ts) (PostgreSQL data), [`apps/api/src/scraper/scraper.controller.ts`](https://github.com/asiifdev/business-leads-ai-automation/blob/main/apps/api/src/scraper/scraper.controller.ts) (Scrape job API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["User experience"]
  node_dashboard["Web dashboard"]
  node_authui["Sign-in screens"]
end

subgraph group_identity["Identity and workspace"]
  node_authapi["Authentication API<br/>[auth.service.ts]"]
  node_workspace["Workspace management"]
end

subgraph group_discovery["Lead discovery"]
  node_scrapeapi["Scrape job API"]
  node_queue["Scraper queue"]
  node_worker["Scrape and scoring worker"]
  node_maps["Google Maps"]
  node_leadai["Lead intelligence"]
  node_outreachai["Outreach generation"]
end

subgraph group_crm["CRM and campaigns"]
  node_campaigns["Campaign management"]
  node_leads["Lead CRM<br/>[leads.service.ts]"]
end

subgraph group_insights["Insights and platform"]
  node_database[("PostgreSQL data<br/>[prisma.service.ts]")]
  node_analytics["Analytics"]
  node_export["Lead export<br/>[export.service.ts]"]
  node_settings["API keys and integrations"]
end

node_user(("GTM user"))
node_ai_provider["OpenAI-compatible provider"]

node_user -->|"uses"| node_dashboard
node_user -->|"signs in"| node_authui
node_authui -.->|"authenticates"| node_authapi
node_dashboard -->|"manages campaigns"| node_campaigns
node_dashboard -->|"starts scraping"| node_scrapeapi
node_scrapeapi -->|"loads campaign"| node_campaigns
node_scrapeapi -->|"enqueues job"| node_queue
node_queue -->|"dispatches job"| node_worker
node_worker -->|"scrapes places"| node_maps
node_worker -->|"scores leads"| node_leadai
node_worker -->|"generates outreach"| node_outreachai
node_leadai -.->|"uses AI"| node_ai_provider
node_outreachai -.->|"generates content"| node_ai_provider
node_worker -.->|"stores results"| node_database
node_dashboard -->|"manages lead lifecycle"| node_leads
node_leads -.->|"reads and updates"| node_database
node_dashboard -->|"views analytics"| node_analytics
node_analytics -.->|"queries metrics"| node_database
node_dashboard -->|"exports leads"| node_export
node_export -.->|"reads leads"| node_database
node_dashboard -.->|"manages workspace"| node_workspace
node_dashboard -->|"configures integrations"| node_settings
node_authapi -->|"persists accounts"| node_database

click node_dashboard "https://github.com/asiifdev/business-leads-ai-automation/tree/main/apps/web/src/app/(dashboard)"
click node_authui "https://github.com/asiifdev/business-leads-ai-automation/tree/main/apps/web/src/app/(auth)"
click node_authapi "https://github.com/asiifdev/business-leads-ai-automation/blob/main/apps/api/src/auth/auth.service.ts"
click node_workspace "https://github.com/asiifdev/business-leads-ai-automation/blob/main/apps/api/src/workspace/workspace.controller.ts"
click node_campaigns "https://github.com/asiifdev/business-leads-ai-automation/blob/main/apps/api/src/campaigns/campaigns.service.ts"
click node_scrapeapi "https://github.com/asiifdev/business-leads-ai-automation/blob/main/apps/api/src/scraper/scraper.controller.ts"
click node_queue "https://github.com/asiifdev/business-leads-ai-automation/blob/main/apps/api/src/scraper/scraper.controller.ts"
click node_worker "https://github.com/asiifdev/business-leads-ai-automation/blob/main/apps/api/src/scraper/scraper.processor.ts"
click node_leadai "https://github.com/asiifdev/business-leads-ai-automation/blob/main/apps/api/src/ai/lead-intelligence.service.ts"
click node_outreachai "https://github.com/asiifdev/business-leads-ai-automation/blob/main/apps/api/src/ai/marketing-ai.service.ts"
click node_leads "https://github.com/asiifdev/business-leads-ai-automation/blob/main/apps/api/src/leads/leads.service.ts"
click node_database "https://github.com/asiifdev/business-leads-ai-automation/blob/main/apps/api/src/prisma/prisma.service.ts"
click node_analytics "https://github.com/asiifdev/business-leads-ai-automation/blob/main/apps/api/src/analytics/analytics.service.ts"
click node_export "https://github.com/asiifdev/business-leads-ai-automation/blob/main/apps/api/src/export/export.service.ts"
click node_settings "https://github.com/asiifdev/business-leads-ai-automation/blob/main/apps/api/src/settings/settings.service.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_dashboard,node_authui,node_user toneBlue
class node_authapi,node_workspace toneAmber
class node_scrapeapi,node_queue,node_worker,node_maps,node_leadai,node_outreachai toneMint
class node_campaigns,node_leads toneRose
class node_database,node_analytics,node_export,node_settings,node_ai_provider toneIndigo
```

## Components

### User experience

- [Web dashboard](https://github.com/asiifdev/business-leads-ai-automation/tree/main/apps/web/src/app/(dashboard)): `apps/web/src/app/(dashboard)`
- [Sign-in screens](https://github.com/asiifdev/business-leads-ai-automation/tree/main/apps/web/src/app/(auth)): `apps/web/src/app/(auth)`

### Identity and workspace

- [Authentication API](https://github.com/asiifdev/business-leads-ai-automation/blob/main/apps/api/src/auth/auth.service.ts): `apps/api/src/auth/auth.service.ts`
- [Workspace management](https://github.com/asiifdev/business-leads-ai-automation/blob/main/apps/api/src/workspace/workspace.controller.ts): `apps/api/src/workspace/workspace.controller.ts`

### Lead discovery

- [Scrape job API](https://github.com/asiifdev/business-leads-ai-automation/blob/main/apps/api/src/scraper/scraper.controller.ts): `apps/api/src/scraper/scraper.controller.ts`
- [Scraper queue](https://github.com/asiifdev/business-leads-ai-automation/blob/main/apps/api/src/scraper/scraper.controller.ts): `apps/api/src/scraper/scraper.controller.ts`
- [Scrape and scoring worker](https://github.com/asiifdev/business-leads-ai-automation/blob/main/apps/api/src/scraper/scraper.processor.ts): `apps/api/src/scraper/scraper.processor.ts`
- **Google Maps**
- [Lead intelligence](https://github.com/asiifdev/business-leads-ai-automation/blob/main/apps/api/src/ai/lead-intelligence.service.ts): `apps/api/src/ai/lead-intelligence.service.ts`
- [Outreach generation](https://github.com/asiifdev/business-leads-ai-automation/blob/main/apps/api/src/ai/marketing-ai.service.ts): `apps/api/src/ai/marketing-ai.service.ts`

### CRM and campaigns

- [Campaign management](https://github.com/asiifdev/business-leads-ai-automation/blob/main/apps/api/src/campaigns/campaigns.service.ts): `apps/api/src/campaigns/campaigns.service.ts`
- [Lead CRM](https://github.com/asiifdev/business-leads-ai-automation/blob/main/apps/api/src/leads/leads.service.ts): `apps/api/src/leads/leads.service.ts`

### Insights and platform

- [PostgreSQL data](https://github.com/asiifdev/business-leads-ai-automation/blob/main/apps/api/src/prisma/prisma.service.ts): `apps/api/src/prisma/prisma.service.ts`
- [Analytics](https://github.com/asiifdev/business-leads-ai-automation/blob/main/apps/api/src/analytics/analytics.service.ts): `apps/api/src/analytics/analytics.service.ts`
- [Lead export](https://github.com/asiifdev/business-leads-ai-automation/blob/main/apps/api/src/export/export.service.ts): `apps/api/src/export/export.service.ts`
- [API keys and integrations](https://github.com/asiifdev/business-leads-ai-automation/blob/main/apps/api/src/settings/settings.service.ts): `apps/api/src/settings/settings.service.ts`

### Other components

- **GTM user**
- **OpenAI-compatible provider**

## Connections

- GTM user → Web dashboard: uses
- GTM user → Sign-in screens: signs in
- Sign-in screens → Authentication API: authenticates
- Web dashboard → Campaign management: manages campaigns
- Web dashboard → Scrape job API: starts scraping
- Scrape job API → Campaign management: loads campaign (evidence: `apps/api/src/scraper/scraper.controller.ts`)
- Scrape job API → Scraper queue: enqueues job (evidence: `apps/api/src/scraper/scraper.controller.ts`)
- Scraper queue → Scrape and scoring worker: dispatches job (evidence: `apps/api/src/scraper/scraper.controller.ts`)
- Scrape and scoring worker → Google Maps: scrapes places
- Scrape and scoring worker → Lead intelligence: scores leads
- Scrape and scoring worker → Outreach generation: generates outreach
- Lead intelligence → OpenAI-compatible provider: uses AI
- Outreach generation → OpenAI-compatible provider: generates content
- Scrape and scoring worker → PostgreSQL data: stores results
- Web dashboard → Lead CRM: manages lead lifecycle
- Lead CRM → PostgreSQL data: reads and updates
- Web dashboard → Analytics: views analytics
- Analytics → PostgreSQL data: queries metrics
- Web dashboard → Lead export: exports leads
- Lead export → PostgreSQL data: reads leads
- Web dashboard → Workspace management: manages workspace
- Web dashboard → API keys and integrations: configures integrations
- Authentication API → PostgreSQL data: persists accounts (evidence: `apps/api/src/auth/auth.service.ts`)
