# karanverma-lgtm/xmonksb2b architecture

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

- Interactive diagram: https://gitdiagram.com/karanverma-lgtm/xmonksb2b
- Repository: https://github.com/karanverma-lgtm/xmonksb2b

## Overview

This is a browser-based sales CRM covering prospect outreach, lead-pipeline management, billing and delivery, email, document handling, analytics, and integrations. The principal workflow spans prospecting and outreach into tracked pipeline deals, then billing and delivery follow-through. Sampled evidence supports several service and component calls, but the README is only the generic Next.js starter README and page-level routing was not sampled; the graph therefore preserves major tree-visible product areas without guessing their wiring.

Main entry points: [`src/lib/emailService.ts`](https://github.com/karanverma-lgtm/xmonksb2b/blob/main/src/lib/emailService.ts) (Email campaigns), [`src/lib/firebase.ts`](https://github.com/karanverma-lgtm/xmonksb2b/blob/main/src/lib/firebase.ts) (Firebase services), [`src/lib/leadsService.ts`](https://github.com/karanverma-lgtm/xmonksb2b/blob/main/src/lib/leadsService.ts) (Lead records), [`src/lib/r2.ts`](https://github.com/karanverma-lgtm/xmonksb2b/blob/main/src/lib/r2.ts) (Object storage)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_sales["Sales workflow"]
  node_prospect["Prospect management"]
  node_outreach_store[("Outreach records<br/>[outreachService.ts]")]
  node_pipeline["Lead pipeline"]
  node_lead_store[("Lead records<br/>[leadsService.ts]")]
  node_stage_catalog["Pipeline stages<br/>[stages.ts]"]
end

subgraph group_engagement["Outreach and email"]
  node_email_ui["Email composition"]
  node_email_service["Email campaigns<br/>[emailService.ts]"]
  node_attachment_ui["Attachment manager"]
  node_email_send["Email dispatch<br/>[route.ts]"]
  node_templates[("Email templates")]
end

subgraph group_operations["Billing and delivery"]
  node_billing[("Billing records<br/>[billingService.ts]")]
  node_delivery["Delivery management<br/>[deliveryService.ts]"]
  node_proposal_parse["Proposal import<br/>[route.ts]"]
end

subgraph group_platform["Shared services"]
  node_library[("Document library<br/>[libraryService.ts]")]
  node_file_storage[("Object storage<br/>[r2.ts]")]
  node_approach_notes["Approach notes"]
  node_financial_docs["Financial documents"]
  node_firebase[("Firebase services<br/>[firebase.ts]")]
end

subgraph group_insights["Insights and integrations"]
  node_analytics["Sales analytics"]
  node_prospector["Sales prospecting<br/>[ProspectorTab.tsx]"]
  node_salesql_api["SalesQL enrichment<br/>[route.ts]"]
  node_salesql_helper["SalesQL server helper"]
  node_sheets_sync["Google Sheets sync<br/>[route.ts]"]
end

node_user(("Sales user"))

node_prospect -->|"updates records"| node_outreach_store
node_prospect -->|"sends campaigns"| node_email_service
node_email_ui -->|"uses service"| node_email_service
node_email_ui -->|"renders manager"| node_attachment_ui
node_attachment_ui -->|"uploads attachments"| node_email_service
node_email_service -->|"stores campaign data"| node_firebase
node_email_send -->|"dispatches email"| node_email_service
node_email_service -->|"uses templates"| node_templates
node_pipeline -.->|"migrates won deals"| node_billing
node_lead_store -->|"reads and writes"| node_firebase
node_lead_store -->|"deletes note files"| node_approach_notes
node_billing -->|"reads and writes"| node_firebase
node_proposal_parse -.->|"parses proposal data"| node_delivery
node_sheets_sync -->|"uses lead service"| node_lead_store
node_sheets_sync -->|"accesses database"| node_firebase
node_salesql_api -->|"enriches person"| node_salesql_helper
node_salesql_helper -->|"uses database"| node_firebase
node_library -.->|"stores metadata"| node_firebase
node_file_storage -.->|"stores files"| node_library
node_financial_docs -.->|"stores documents"| node_file_storage
node_approach_notes -.->|"stores notes"| node_file_storage

click node_prospect "https://github.com/karanverma-lgtm/xmonksb2b/blob/main/src/components/AddColdClientModal.tsx"
click node_outreach_store "https://github.com/karanverma-lgtm/xmonksb2b/blob/main/src/lib/outreachService.ts"
click node_pipeline "https://github.com/karanverma-lgtm/xmonksb2b/blob/main/src/components/MigratePipelineLeadModal.tsx"
click node_lead_store "https://github.com/karanverma-lgtm/xmonksb2b/blob/main/src/lib/leadsService.ts"
click node_stage_catalog "https://github.com/karanverma-lgtm/xmonksb2b/blob/main/src/constants/stages.ts"
click node_billing "https://github.com/karanverma-lgtm/xmonksb2b/blob/main/src/lib/billingService.ts"
click node_delivery "https://github.com/karanverma-lgtm/xmonksb2b/blob/main/src/lib/deliveryService.ts"
click node_proposal_parse "https://github.com/karanverma-lgtm/xmonksb2b/blob/main/src/app/api/delivery/parse-proposal/route.ts"
click node_email_ui "https://github.com/karanverma-lgtm/xmonksb2b/blob/main/src/components/AIEmailComposerModal.tsx"
click node_email_service "https://github.com/karanverma-lgtm/xmonksb2b/blob/main/src/lib/emailService.ts"
click node_attachment_ui "https://github.com/karanverma-lgtm/xmonksb2b/blob/main/src/components/EmailAttachmentManager.tsx"
click node_email_send "https://github.com/karanverma-lgtm/xmonksb2b/blob/main/src/app/api/email/send/route.ts"
click node_library "https://github.com/karanverma-lgtm/xmonksb2b/blob/main/src/lib/libraryService.ts"
click node_file_storage "https://github.com/karanverma-lgtm/xmonksb2b/blob/main/src/lib/r2.ts"
click node_approach_notes "https://github.com/karanverma-lgtm/xmonksb2b/blob/main/src/lib/approachNoteService.ts"
click node_financial_docs "https://github.com/karanverma-lgtm/xmonksb2b/blob/main/src/lib/financialDocumentService.ts"
click node_firebase "https://github.com/karanverma-lgtm/xmonksb2b/blob/main/src/lib/firebase.ts"
click node_analytics "https://github.com/karanverma-lgtm/xmonksb2b/blob/main/src/components/AnalyticsCharts.tsx"
click node_prospector "https://github.com/karanverma-lgtm/xmonksb2b/blob/main/src/components/ProspectorTab.tsx"
click node_salesql_api "https://github.com/karanverma-lgtm/xmonksb2b/blob/main/src/app/api/salesql/enrich-person/route.ts"
click node_salesql_helper "https://github.com/karanverma-lgtm/xmonksb2b/blob/main/src/lib/salesqlServerHelper.ts"
click node_sheets_sync "https://github.com/karanverma-lgtm/xmonksb2b/blob/main/src/app/api/integrations/google-sheets/route.ts"
click node_templates "https://github.com/karanverma-lgtm/xmonksb2b/blob/main/src/lib/templatesService.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_prospect,node_outreach_store,node_pipeline,node_lead_store,node_stage_catalog,node_user toneBlue
class node_email_ui,node_email_service,node_attachment_ui,node_email_send,node_templates toneAmber
class node_billing,node_delivery,node_proposal_parse toneMint
class node_library,node_file_storage,node_approach_notes,node_financial_docs,node_firebase toneRose
class node_analytics,node_prospector,node_salesql_api,node_salesql_helper,node_sheets_sync toneIndigo
```

## Components

### Sales workflow

- [Prospect management](https://github.com/karanverma-lgtm/xmonksb2b/blob/main/src/components/AddColdClientModal.tsx): `src/components/AddColdClientModal.tsx`
- [Outreach records](https://github.com/karanverma-lgtm/xmonksb2b/blob/main/src/lib/outreachService.ts): `src/lib/outreachService.ts`
- [Lead pipeline](https://github.com/karanverma-lgtm/xmonksb2b/blob/main/src/components/MigratePipelineLeadModal.tsx): `src/components/MigratePipelineLeadModal.tsx`
- [Lead records](https://github.com/karanverma-lgtm/xmonksb2b/blob/main/src/lib/leadsService.ts): `src/lib/leadsService.ts`
- [Pipeline stages](https://github.com/karanverma-lgtm/xmonksb2b/blob/main/src/constants/stages.ts): `src/constants/stages.ts`

### Outreach and email

- [Email composition](https://github.com/karanverma-lgtm/xmonksb2b/blob/main/src/components/AIEmailComposerModal.tsx): `src/components/AIEmailComposerModal.tsx`
- [Email campaigns](https://github.com/karanverma-lgtm/xmonksb2b/blob/main/src/lib/emailService.ts): `src/lib/emailService.ts`
- [Attachment manager](https://github.com/karanverma-lgtm/xmonksb2b/blob/main/src/components/EmailAttachmentManager.tsx): `src/components/EmailAttachmentManager.tsx`
- [Email dispatch](https://github.com/karanverma-lgtm/xmonksb2b/blob/main/src/app/api/email/send/route.ts): `src/app/api/email/send/route.ts`
- [Email templates](https://github.com/karanverma-lgtm/xmonksb2b/blob/main/src/lib/templatesService.ts): `src/lib/templatesService.ts`

### Billing and delivery

- [Billing records](https://github.com/karanverma-lgtm/xmonksb2b/blob/main/src/lib/billingService.ts): `src/lib/billingService.ts`
- [Delivery management](https://github.com/karanverma-lgtm/xmonksb2b/blob/main/src/lib/deliveryService.ts): `src/lib/deliveryService.ts`
- [Proposal import](https://github.com/karanverma-lgtm/xmonksb2b/blob/main/src/app/api/delivery/parse-proposal/route.ts): `src/app/api/delivery/parse-proposal/route.ts`

### Shared services

- [Document library](https://github.com/karanverma-lgtm/xmonksb2b/blob/main/src/lib/libraryService.ts): `src/lib/libraryService.ts`
- [Object storage](https://github.com/karanverma-lgtm/xmonksb2b/blob/main/src/lib/r2.ts): `src/lib/r2.ts`
- [Approach notes](https://github.com/karanverma-lgtm/xmonksb2b/blob/main/src/lib/approachNoteService.ts): `src/lib/approachNoteService.ts`
- [Financial documents](https://github.com/karanverma-lgtm/xmonksb2b/blob/main/src/lib/financialDocumentService.ts): `src/lib/financialDocumentService.ts`
- [Firebase services](https://github.com/karanverma-lgtm/xmonksb2b/blob/main/src/lib/firebase.ts): `src/lib/firebase.ts`

### Insights and integrations

- [Sales analytics](https://github.com/karanverma-lgtm/xmonksb2b/blob/main/src/components/AnalyticsCharts.tsx): `src/components/AnalyticsCharts.tsx`
- [Sales prospecting](https://github.com/karanverma-lgtm/xmonksb2b/blob/main/src/components/ProspectorTab.tsx): `src/components/ProspectorTab.tsx`
- [SalesQL enrichment](https://github.com/karanverma-lgtm/xmonksb2b/blob/main/src/app/api/salesql/enrich-person/route.ts): `src/app/api/salesql/enrich-person/route.ts`
- [SalesQL server helper](https://github.com/karanverma-lgtm/xmonksb2b/blob/main/src/lib/salesqlServerHelper.ts): `src/lib/salesqlServerHelper.ts`
- [Google Sheets sync](https://github.com/karanverma-lgtm/xmonksb2b/blob/main/src/app/api/integrations/google-sheets/route.ts): `src/app/api/integrations/google-sheets/route.ts`

### Other components

- **Sales user**

## Connections

- Prospect management → Outreach records: updates records (evidence: `src/components/AddColdClientModal.tsx`)
- Prospect management → Email campaigns: sends campaigns
- Email composition → Email campaigns: uses service (evidence: `src/components/AIEmailComposerModal.tsx`)
- Email composition → Attachment manager: renders manager (evidence: `src/components/AIEmailComposerModal.tsx`)
- Attachment manager → Email campaigns: uploads attachments (evidence: `src/components/EmailAttachmentManager.tsx`)
- Email campaigns → Firebase services: stores campaign data (evidence: `src/lib/emailService.ts`)
- Email dispatch → Email campaigns: dispatches email (evidence: `src/app/api/email/send/route.ts`)
- Email campaigns → Email templates: uses templates (evidence: `src/lib/emailService.ts`)
- Lead pipeline → Billing records: migrates won deals
- Lead records → Firebase services: reads and writes (evidence: `src/lib/leadsService.ts`)
- Lead records → Approach notes: deletes note files (evidence: `src/lib/leadsService.ts`)
- Billing records → Firebase services: reads and writes (evidence: `src/lib/billingService.ts`)
- Proposal import → Delivery management: parses proposal data
- Google Sheets sync → Lead records: uses lead service (evidence: `src/app/api/integrations/google-sheets/route.ts`)
- Google Sheets sync → Firebase services: accesses database (evidence: `src/app/api/integrations/google-sheets/route.ts`)
- SalesQL enrichment → SalesQL server helper: enriches person (evidence: `src/app/api/salesql/enrich-person/route.ts`)
- SalesQL server helper → Firebase services: uses database (evidence: `src/lib/salesqlServerHelper.ts`)
- Document library → Firebase services: stores metadata
- Object storage → Document library: stores files
- Financial documents → Object storage: stores documents
- Approach notes → Object storage: stores notes
