Contacts
People associated with buildings and projects — building owners, tenants, craftsmen, consultants. Contacts are synced bidirectionally with HubSpot Integration.
Source Files
| Layer | Path |
|---|---|
| Schema | backend/src/db/schema.ts (line ~291) |
| Routes | backend/src/routes/contacts.ts |
| Service | backend/src/services/contact-service.ts |
| Pages | frontend/src/pages/ContactsPage.tsx, frontend/src/pages/ContactDetailPage.tsx |
| Queries | frontend/src/lib/queries/contactQueries.ts |
Database Tables
| Table | Purpose |
|---|---|
contacts | Main entity — personal/legal person data, address, HubSpot sync fields |
contact_companies | M2M join table linking contacts to Companies with role metadata |
building_roles | Links contacts to Buildings with a role (via RBAC Authorization) |
project_roles | Links contacts to Projects with a role |
Key Fields
| Field | Type | Notes |
|---|---|---|
type | enum | natural_person or legal_person |
firstName, lastName | varchar | For natural persons |
title | varchar(50) | Dr., Prof., etc. |
email, phone | varchar | Contact info |
street, houseNumber, postalCode, city, country | varchar | Unified address (Issue #1329) |
lat, lng, placeId | double/varchar | Geocoded location |
dateOfBirth | timestamp | For natural persons |
hubspotId | varchar | HubSpot CRM contact ID |
hubspotProperties | jsonb | Raw HubSpot property bag |
lastSyncedAt | timestamp | Last HubSpot sync timestamp |
HubSpot Sync
Contacts sync bidirectionally with HubSpot CRM contacts:
hubspotIdmaps to the HubSpot recordhubspotPropertiesstores the full HubSpot property setlastSyncedAttracks 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
Related Pages
Companies | Buildings | Projects | Users | HubSpot Integration | RBAC Authorization | Leads | Database Architecture