Leads

Potential customers and incoming inquiries tracked via HubSpot Integration. Leads represent the earliest stage of the sales funnel before conversion to Contacts and Companies.

Source Files

LayerPath
Schemabackend/src/db/schema.ts (line ~7223)
Backendbackend/src/routes/admin/hubspot-sync.ts (leads endpoints at /leads, /leads/:id)
Pagesfrontend/src/pages/LeadsPage.tsx, frontend/src/pages/LeadDetailPage.tsx

Database Table

TablePurpose
hubspot_leadsHubSpot-synced leads with pipeline, status, and association references

Key Fields

FieldTypeNotes
hubspotIdvarchar(100)HubSpot deal/lead ID (unique, required)
hubspotContactIdvarcharAssociated HubSpot contact ID
contactIduuid FKLocal contact reference (nullable)
hubspotCompanyIdvarcharAssociated HubSpot company ID
companyIduuid FKLocal company reference (nullable)
leadNamevarchar(255)Display name of the lead
leadStatusvarchar(100)Current status in the pipeline
leadLabelvarchar(100)Classification label
hubspotPipelinevarcharHubSpot pipeline identifier
hubspotPipelineStagevarcharCurrent stage within the pipeline
hubspotOwnerIdvarcharAssigned HubSpot owner
hubspotPropertiesjsonbFull HubSpot property bag
hubspotSchemaVersionvarchar(20)Schema version for sync compatibility
lastSyncedAttimestampLast sync timestamp
archived, archivedAtbool/timestampSoft archive
archiveReasontextWhy the lead was archived
mergedIntoHubspotIdvarcharIf lead was merged into another

Relationships

Lead *──0..1 Contact (local contact reference)
Lead *──0..1 Company (local company reference)

Leads may reference both a HubSpot contact/company ID and a local contact/company record once the association is established.

API Endpoints

Leads are served through the HubSpot admin sync routes:

MethodPathPurpose
GET/api/admin/hubspot/sync/leadsPaginated lead list
GET/api/admin/hubspot/sync/leads/:idSingle lead detail

Leads are synced as part of the full HubSpot sync process (with syncLeads flag).

Conversion Flow

HubSpot Lead -> Sync -> hubspot_leads table
                     -> Associate with local Contact/Company
                     -> Convert to Building/Project (manual)

When a lead converts, the associated contact and company records serve as the basis for creating Buildings and Projects.

Features

  • HubSpot-native — leads originate and are primarily managed in HubSpot CRM
  • Pipeline tracking with stage progression synced from HubSpot
  • Soft archive with reason tracking and merge detection
  • Association linking to local Contacts and Companies records

Contacts | Companies | Buildings | Projects | HubSpot Integration | Admin Dashboard