# pipelinesync/ai architecture

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

- Interactive diagram: https://gitdiagram.com/pipelinesync/ai
- Repository: https://github.com/pipelinesync/ai

## Overview

Nova PipelineSync AI is a browser-based prototype that turns a lead’s discovery-call answers into a tailored revenue-operations blueprint, then unlocks a downloadable and optionally emailed PDF. The principal journey runs from an entry gate through AI or fallback voice intake, extraction, asynchronous generation and status polling, and delivery. Separate capabilities include CRM capture and enrichment, lead persistence, consent and anti-abuse checks, and optional live AI integrations. The graph follows documented and indexed runtime wiring; several browser-to-endpoint links are documented only at a high level, so those links are dashed.

Main entry points: [`public/app.js`](https://github.com/pipelinesync/ai/blob/main/public/app.js) (Browser app), [`lib/deliver-core.js`](https://github.com/pipelinesync/ai/blob/main/lib/deliver-core.js) (Delivery coordinator), [`lib/job-store.js`](https://github.com/pipelinesync/ai/blob/main/lib/job-store.js) (Blueprint job store), [`netlify/functions/start.js`](https://github.com/pipelinesync/ai/blob/main/netlify/functions/start.js) (Entry gate)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["Browser and entry"]
  node_browser["Browser app<br/>[app.js]"]
  node_start["Entry gate<br/>[start.js]"]
end

subgraph group_intake["Intake and lead capture"]
  node_turnstile["Turnstile check<br/>[turnstile.js]"]
  node_voice_route["Voice API route<br/>[voice.js]"]
  node_voice_api["Voice routing<br/>[voice-api.js]"]
  node_voice["Discovery interviewer<br/>[voice.js]"]
end

subgraph group_blueprint["Blueprint generation"]
  node_extract_route["Answer extraction route<br/>[extract.js]"]
  node_ai_pipeline["Extract and generate<br/>[ai-pipeline.js]"]
  node_core["Knowledge and PDF core<br/>[core.js]"]
  node_generate_route["Generation request<br/>[generate.js]"]
  node_generate_job["Generation worker<br/>[generate-job.js]"]
  node_background["Background function"]
  node_status["Job status route<br/>[generate-status.js]"]
  node_job_store[("Blueprint job store<br/>[job-store.js]")]
end

subgraph group_delivery["Delivery and integrations"]
  node_deliver_route["Delivery route<br/>[deliver.js]"]
  node_deliver_core["Delivery coordinator<br/>[deliver-core.js]"]
  node_code_route["Email code route<br/>[deliver-code.js]"]
  node_email_verify["Email verification<br/>[email-verify.js]"]
  node_pdf_email["PDF email<br/>[pdf-email.js]"]
  node_hubspot["HubSpot CRM<br/>[hubspot.js]"]
  node_supabase[("Lead persistence<br/>[supabase-leads.js]")]
end

node_visitor(("Lead"))
node_anthropic_service["Anthropic Claude"]
node_openai_service["OpenAI voice"]
node_resend["Resend email"]

node_visitor -->|"uses"| node_browser
node_browser -.->|"starts session"| node_start
node_start -->|"verifies token"| node_turnstile
node_start -->|"creates lead"| node_supabase
node_start -->|"captures contact"| node_hubspot
node_browser -.->|"conducts discovery"| node_voice_route
node_voice_route -->|"routes requests"| node_voice_api
node_voice_api -->|"runs voice flow"| node_voice
node_voice -.->|"uses when enabled"| node_openai_service
node_browser -.->|"submits answers"| node_extract_route
node_extract_route -->|"extracts fields"| node_ai_pipeline
node_ai_pipeline -->|"falls back to"| node_core
node_ai_pipeline -.->|"uses when enabled"| node_anthropic_service
node_browser -.->|"requests blueprint"| node_generate_route
node_generate_route -->|"starts job"| node_generate_job
node_generate_route -->|"records job"| node_job_store
node_background -->|"runs job"| node_generate_job
node_generate_job -->|"generates blueprint"| node_ai_pipeline
node_generate_job -->|"updates job"| node_job_store
node_browser -.->|"polls progress"| node_status
node_status -->|"reads status"| node_job_store
node_browser -.->|"unlocks PDF"| node_deliver_route
node_deliver_route -->|"handles delivery"| node_deliver_core
node_deliver_core -->|"loads blueprint"| node_job_store
node_deliver_core -->|"builds PDF"| node_core
node_deliver_core -->|"enriches CRM"| node_hubspot
node_deliver_core -->|"persists lead"| node_supabase
node_deliver_core -->|"sends PDF"| node_pdf_email
node_pdf_email -.->|"sends email"| node_resend
node_browser -.->|"requests code"| node_code_route
node_code_route -->|"checks job"| node_job_store
node_code_route -->|"creates code"| node_email_verify
node_code_route -->|"sends code"| node_resend

click node_browser "https://github.com/pipelinesync/ai/blob/main/public/app.js"
click node_start "https://github.com/pipelinesync/ai/blob/main/netlify/functions/start.js"
click node_turnstile "https://github.com/pipelinesync/ai/blob/main/lib/turnstile.js"
click node_voice_route "https://github.com/pipelinesync/ai/blob/main/netlify/functions/voice.js"
click node_voice_api "https://github.com/pipelinesync/ai/blob/main/lib/voice-api.js"
click node_voice "https://github.com/pipelinesync/ai/blob/main/lib/voice.js"
click node_extract_route "https://github.com/pipelinesync/ai/blob/main/netlify/functions/extract.js"
click node_ai_pipeline "https://github.com/pipelinesync/ai/blob/main/lib/ai-pipeline.js"
click node_core "https://github.com/pipelinesync/ai/blob/main/lib/core.js"
click node_generate_route "https://github.com/pipelinesync/ai/blob/main/netlify/functions/generate.js"
click node_generate_job "https://github.com/pipelinesync/ai/blob/main/lib/generate-job.js"
click node_background "https://github.com/pipelinesync/ai/blob/main/netlify/functions/generate-background.js"
click node_status "https://github.com/pipelinesync/ai/blob/main/netlify/functions/generate-status.js"
click node_job_store "https://github.com/pipelinesync/ai/blob/main/lib/job-store.js"
click node_deliver_route "https://github.com/pipelinesync/ai/blob/main/netlify/functions/deliver.js"
click node_deliver_core "https://github.com/pipelinesync/ai/blob/main/lib/deliver-core.js"
click node_code_route "https://github.com/pipelinesync/ai/blob/main/netlify/functions/deliver-code.js"
click node_email_verify "https://github.com/pipelinesync/ai/blob/main/lib/email-verify.js"
click node_pdf_email "https://github.com/pipelinesync/ai/blob/main/lib/pdf-email.js"
click node_hubspot "https://github.com/pipelinesync/ai/blob/main/lib/hubspot.js"
click node_supabase "https://github.com/pipelinesync/ai/blob/main/lib/supabase-leads.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_browser,node_start toneBlue
class node_turnstile,node_voice_route,node_voice_api,node_voice toneAmber
class node_extract_route,node_ai_pipeline,node_core,node_generate_route,node_generate_job,node_background,node_status,node_job_store toneMint
class node_deliver_route,node_deliver_core,node_code_route,node_email_verify,node_pdf_email,node_hubspot,node_supabase toneRose
class node_visitor,node_anthropic_service,node_openai_service,node_resend toneIndigo
```

## Components

### Browser and entry

- [Browser app](https://github.com/pipelinesync/ai/blob/main/public/app.js): `public/app.js`
- [Entry gate](https://github.com/pipelinesync/ai/blob/main/netlify/functions/start.js): `netlify/functions/start.js`

### Intake and lead capture

- [Turnstile check](https://github.com/pipelinesync/ai/blob/main/lib/turnstile.js): `lib/turnstile.js`
- [Voice API route](https://github.com/pipelinesync/ai/blob/main/netlify/functions/voice.js): `netlify/functions/voice.js`
- [Voice routing](https://github.com/pipelinesync/ai/blob/main/lib/voice-api.js): `lib/voice-api.js`
- [Discovery interviewer](https://github.com/pipelinesync/ai/blob/main/lib/voice.js): `lib/voice.js`

### Blueprint generation

- [Answer extraction route](https://github.com/pipelinesync/ai/blob/main/netlify/functions/extract.js): `netlify/functions/extract.js`
- [Extract and generate](https://github.com/pipelinesync/ai/blob/main/lib/ai-pipeline.js): `lib/ai-pipeline.js`
- [Knowledge and PDF core](https://github.com/pipelinesync/ai/blob/main/lib/core.js): `lib/core.js`
- [Generation request](https://github.com/pipelinesync/ai/blob/main/netlify/functions/generate.js): `netlify/functions/generate.js`
- [Generation worker](https://github.com/pipelinesync/ai/blob/main/lib/generate-job.js): `lib/generate-job.js`
- [Background function](https://github.com/pipelinesync/ai/blob/main/netlify/functions/generate-background.js): `netlify/functions/generate-background.js`
- [Job status route](https://github.com/pipelinesync/ai/blob/main/netlify/functions/generate-status.js): `netlify/functions/generate-status.js`
- [Blueprint job store](https://github.com/pipelinesync/ai/blob/main/lib/job-store.js): `lib/job-store.js`

### Delivery and integrations

- [Delivery route](https://github.com/pipelinesync/ai/blob/main/netlify/functions/deliver.js): `netlify/functions/deliver.js`
- [Delivery coordinator](https://github.com/pipelinesync/ai/blob/main/lib/deliver-core.js): `lib/deliver-core.js`
- [Email code route](https://github.com/pipelinesync/ai/blob/main/netlify/functions/deliver-code.js): `netlify/functions/deliver-code.js`
- [Email verification](https://github.com/pipelinesync/ai/blob/main/lib/email-verify.js): `lib/email-verify.js`
- [PDF email](https://github.com/pipelinesync/ai/blob/main/lib/pdf-email.js): `lib/pdf-email.js`
- [HubSpot CRM](https://github.com/pipelinesync/ai/blob/main/lib/hubspot.js): `lib/hubspot.js`
- [Lead persistence](https://github.com/pipelinesync/ai/blob/main/lib/supabase-leads.js): `lib/supabase-leads.js`

### Other components

- **Lead**
- **Anthropic Claude**
- **OpenAI voice**
- **Resend email**

## Connections

- Lead → Browser app: uses (evidence: `README.md`)
- Browser app → Entry gate: starts session
- Entry gate → Turnstile check: verifies token (evidence: `netlify/functions/start.js`)
- Entry gate → Lead persistence: creates lead (evidence: `netlify/functions/start.js`)
- Entry gate → HubSpot CRM: captures contact (evidence: `netlify/functions/start.js`)
- Browser app → Voice API route: conducts discovery
- Voice API route → Voice routing: routes requests (evidence: `netlify/functions/voice.js`)
- Voice routing → Discovery interviewer: runs voice flow (evidence: `lib/voice-api.js`)
- Discovery interviewer → OpenAI voice: uses when enabled (evidence: `README.md`)
- Browser app → Answer extraction route: submits answers
- Answer extraction route → Extract and generate: extracts fields (evidence: `netlify/functions/extract.js`)
- Extract and generate → Knowledge and PDF core: falls back to (evidence: `lib/ai-pipeline.js`)
- Extract and generate → Anthropic Claude: uses when enabled (evidence: `README.md`)
- Browser app → Generation request: requests blueprint
- Generation request → Generation worker: starts job (evidence: `netlify/functions/generate.js`)
- Generation request → Blueprint job store: records job (evidence: `netlify/functions/generate.js`)
- Background function → Generation worker: runs job (evidence: `netlify/functions/generate-background.js`)
- Generation worker → Extract and generate: generates blueprint (evidence: `lib/generate-job.js`)
- Generation worker → Blueprint job store: updates job (evidence: `lib/generate-job.js`)
- Browser app → Job status route: polls progress
- Job status route → Blueprint job store: reads status (evidence: `netlify/functions/generate-status.js`)
- Browser app → Delivery route: unlocks PDF
- Delivery route → Delivery coordinator: handles delivery (evidence: `netlify/functions/deliver.js`)
- Delivery coordinator → Blueprint job store: loads blueprint (evidence: `lib/deliver-core.js`)
- Delivery coordinator → Knowledge and PDF core: builds PDF (evidence: `lib/deliver-core.js`)
- Delivery coordinator → HubSpot CRM: enriches CRM (evidence: `lib/deliver-core.js`)
- Delivery coordinator → Lead persistence: persists lead (evidence: `lib/deliver-core.js`)
- Delivery coordinator → PDF email: sends PDF (evidence: `lib/deliver-core.js`)
- PDF email → Resend email: sends email (evidence: `README.md`)
- Browser app → Email code route: requests code
- Email code route → Blueprint job store: checks job (evidence: `netlify/functions/deliver-code.js`)
- Email code route → Email verification: creates code (evidence: `netlify/functions/deliver-code.js`)
- Email code route → Resend email: sends code (evidence: `netlify/functions/deliver-code.js`)
