Contacts

People associated with buildings and projects — building owners, tenants, craftsmen, consultants. Contacts are synced bidirectionally with HubSpot Integration.

Source Files

LayerPath
Schemabackend/src/db/schema.ts (line ~291)
Routesbackend/src/routes/contacts.ts
Servicebackend/src/services/contact-service.ts
Pagesfrontend/src/pages/ContactsPage.tsx, frontend/src/pages/ContactDetailPage.tsx
Queriesfrontend/src/lib/queries/contactQueries.ts

Database Tables

TablePurpose
contactsMain entity — personal/legal person data, address, HubSpot sync fields
contact_companiesM2M join table linking contacts to Companies with role metadata
building_rolesLinks contacts to Buildings with a role (via RBAC Authorization)
project_rolesLinks contacts to Projects with a role

Key Fields

FieldTypeNotes
typeenumnatural_person or legal_person
firstName, lastNamevarcharFor natural persons
titlevarchar(50)Dr., Prof., etc.
email, phonevarcharContact info
street, houseNumber, postalCode, city, countryvarcharUnified address (Issue #1329)
lat, lng, placeIddouble/varcharGeocoded location
dateOfBirthtimestampFor natural persons
hubspotIdvarcharHubSpot CRM contact ID
hubspotPropertiesjsonbRaw HubSpot property bag
lastSyncedAttimestampLast HubSpot sync timestamp

HubSpot Sync

Contacts sync bidirectionally with HubSpot CRM contacts:

  • hubspotId maps to the HubSpot record
  • hubspotProperties stores the full HubSpot property set
  • lastSyncedAt tracks sync freshness
  • Sync managed via HubSpot Integration admin routes (backend/src/routes/admin/hubspot-sync.ts)

Relationships

Contact *──* Companies (via contact_companies)
Contact *──* Buildings (via building_roles)
Contact *──* Projects (via project_roles)
Contact 1──0..1 Users (user.contactId)

Every user has a mandatory contactId reference, making contacts the source of truth for personal information.

Frontend Components

The contacts list page supports search, filtering, and pagination. The detail page shows contact info, associated Companies, Buildings, and Projects.

Features

  • Two contact types — natural persons (people) and legal persons (organizations without a company record)
  • HubSpot bidirectional sync via HubSpot Integration
  • Role assignments on Buildings and Projects via RBAC Authorization
  • Company associations with role and date metadata (primary flag, start/end dates)
  • User linkage — every system user is backed by a contact record

Companies | Buildings | Projects | Users | HubSpot Integration | RBAC Authorization | Leads | Database Architecture