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
| Layer | Path |
|---|---|
| Schema | backend/src/db/schema.ts (line ~7083) |
| Routes | backend/src/routes/companies.ts |
| Service | backend/src/services/company-service.ts |
| Pages | frontend/src/pages/CompaniesPage.tsx, frontend/src/pages/CompanyDetailPage.tsx |
| Queries | frontend/src/lib/queries/companyQueries.ts |
Database Tables
| Table | Purpose |
|---|---|
companies | Main entity — name, domain, address, business info, HubSpot sync, hierarchy |
contact_companies | M2M join with Contacts (role, isPrimary, start/end dates) |
Key Fields
| Field | Type | Notes |
|---|---|---|
name | varchar(255) | Company name (required) |
domain, website | varchar | Web presence |
email, phone | varchar | Primary contact info |
industry | varchar | Business sector |
legalForm | varchar(50) | Legal form (Rechtsform) |
annualRevenue | decimal | Revenue figure |
numberOfEmployees | integer | Company size |
taxId | varchar | Tax identification (USt-IdNr) |
isVatDeductible | boolean | VAT deduction eligibility |
companyType | varchar | RENEWA classification (Kategorie) |
classification | varchar | Internal classification |
priority, potential | varchar | Business priority and potential |
parentCompanyId | uuid | Self-referencing hierarchy |
hierarchyLevel, hierarchyPath | int/varchar | Hierarchy navigation |
trades, tradeLabels | text | Semicolon-separated trade specializations |
hubspotId | varchar | HubSpot company ID |
hubspotProperties | jsonb | Raw HubSpot property bag |
lastSyncedAt | timestamp | Last 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:
parentCompanyIdpoints to the parent companyhierarchyLevel(0 = root) andhierarchyPathenable efficient tree queries- Used to model corporate structures (holding → subsidiary → branch)
HubSpot Sync
- Synced from HubSpot CRM companies via HubSpot Integration
hubspotCompanyTypemaps to HubSpot’s type field (PROSPECT, PARTNER, VENDOR, etc.)lifecycleStageandleadStatustrack 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)
Related Pages
Contacts | Projects | Buildings | HubSpot Integration | Leads | Database Architecture