Companies

Organizations in the system — partner firms, client companies, contractors, subcontractors. Synced with HubSpot Integration and linked to Contacts via a many-to-many relationship.

Source Files

LayerPath
Schemabackend/src/db/schema.ts (line ~7083)
Routesbackend/src/routes/companies.ts
Servicebackend/src/services/company-service.ts
Pagesfrontend/src/pages/CompaniesPage.tsx, frontend/src/pages/CompanyDetailPage.tsx
Queriesfrontend/src/lib/queries/companyQueries.ts

Database Tables

TablePurpose
companiesMain entity — name, domain, address, business info, HubSpot sync, hierarchy
contact_companiesM2M join with Contacts (role, isPrimary, start/end dates)

Key Fields

FieldTypeNotes
namevarchar(255)Company name (required)
domain, websitevarcharWeb presence
email, phonevarcharPrimary contact info
industryvarcharBusiness sector
legalFormvarchar(50)Legal form (Rechtsform)
annualRevenuedecimalRevenue figure
numberOfEmployeesintegerCompany size
taxIdvarcharTax identification (USt-IdNr)
isVatDeductiblebooleanVAT deduction eligibility
companyTypevarcharRENEWA classification (Kategorie)
classificationvarcharInternal classification
priority, potentialvarcharBusiness priority and potential
parentCompanyIduuidSelf-referencing hierarchy
hierarchyLevel, hierarchyPathint/varcharHierarchy navigation
trades, tradeLabelstextSemicolon-separated trade specializations
hubspotIdvarcharHubSpot company ID
hubspotPropertiesjsonbRaw HubSpot property bag
lastSyncedAttimestampLast sync timestamp

Relationships

Company *──* Contacts (via contact_companies)
Company *──0..1 Company (parent -- self-referencing hierarchy)
Company *──* Projects (via contacts and roles)

Company Hierarchy

Companies support a self-referencing tree structure:

  • parentCompanyId points to the parent company
  • hierarchyLevel (0 = root) and hierarchyPath enable efficient tree queries
  • Used to model corporate structures (holding subsidiary branch)

HubSpot Sync

  • Synced from HubSpot CRM companies via HubSpot Integration
  • hubspotCompanyType maps to HubSpot’s type field (PROSPECT, PARTNER, VENDOR, etc.)
  • lifecycleStage and leadStatus track the HubSpot sales pipeline
  • Association config in backend/src/routes/admin/hubspot-association-config.ts

Features

  • Company hierarchy with parent/child relationships and tree navigation
  • HubSpot sync for CRM data including lifecycle and classification
  • Trade tracking for contractor/craftsman specializations
  • Contact associations with role metadata (employee, consultant, board member)
  • RENEWA classification system (type, classification, priority, potential)

Contacts | Projects | Buildings | HubSpot Integration | Leads | Database Architecture