Buildings
The core entity in Renewa One representing physical buildings undergoing renovation. Every project, scenario, and financial record traces back to a building.
HubSpot mirror:
buildingsmirrors the HubSpot Listing object (objectTypeId0-420,listingConfiginservices/hubspot/sync-engine/entity-configs.ts). ThehubspotIdcolumn is the vendor identifier used only for sync round-tripping — internal cross-table references always join onbuildings.id(UUID PK). See HubSpot Integration.
Source Files
| Layer | Path |
|---|---|
| Schema | backend/src/db/schema.ts (buildings) |
| Routes | backend/src/routes/buildings/ (crud.ts, aggregates.ts) |
| Service | backend/src/services/buildings-service.ts |
| Pages | frontend/src/pages/Buildings.tsx, frontend/src/pages/BuildingDetail.tsx |
| Queries | frontend/src/lib/queries/buildingQueries.ts, buildingComponentQueries.ts, buildingRoleQueries.ts |
Database Tables
| Table | Purpose |
|---|---|
buildings | Main entity — address, type, year, geometry, HubSpot sync fields |
building_components | Structural elements (walls, roof, windows, etc.) — see Building Components |
building_technology | Technical systems (heating, ventilation, PV, solar thermal) |
building_calculation_parameters | Parameters for Energy Calculations (residential units, areas) |
building_roles | RBAC Authorization — maps Contacts to buildings with roles |
Key Fields
| Field | Type | Notes |
|---|---|---|
buildingType | enum | single_family_detached, multi_family, commercial, mixed_use_*, etc. |
yearBuilt | integer | Construction year |
heritageStatus | enum | none, listed_monument, ensemble_protection, unesco_world_heritage, etc. |
ownershipStructure | enum | owner_occupied, rental, cooperative, condominium, mixed |
street, houseNumber, postalCode, city | varchar | Unified address structure (I#1329) |
lat, lng | double | GPS coordinates for map view |
residentialUnits | integer | HubSpot Listing mirror value (Anzahl Wohneinheiten) — sync overwrites on every run (PR#1983, I#1962) |
livingArea | real | Wohnfläche m², HubSpot mirror (PR#1983); not the same as heatedArea |
heatedArea | real | Beheizte Fläche m² — EB-maintained, no HubSpot source |
hubspotId | varchar(100) | HubSpot Listing ID (unique) — sync round-trip only, never used for internal joins |
hubspotPipeline, hubspotPipelineStage | varchar | Listing pipeline mirror |
recordOwnerContactId | uuid FK | Read-only sync mirror of the HubSpot record owner, resolved to a contact via hubspot_owners (PR#1767). Sync layer is the sole writer. |
hubspotProperties, hubspotSchemaVersion, lastSyncedAt | jsonb/varchar/timestamp | Raw HubSpot property bag + sync metadata |
userId | uuid FK | Creator user — nullable, set null on delete (I#1724) |
archived, archivedAt, deletedAt, archiveReason, mergedIntoHubspotId | various | HubSpot archive/merge status + soft delete |
The EB-validated counterparts of the mirror values live in building_calculation_parameters (customer input → validated). heritageStatus is also sync-written from the HubSpot multiselect besonderheiten_immobilie.
Relationships
Building 1──* Projects
Building 1──* Building Components
Building 1──* Building Technology
Building 1──* Building Calculation Parameters
Building 1──* Building Roles ──* Contacts
Building 1──* Files
Building 1──* Quotes
Building 1──* Invoices
Building *──1 Users (creator)
Frontend Components
| Component | Purpose |
|---|---|
BuildingForm | Create/edit building with address autocomplete |
BuildingDetailHeader | Title, status badges, actions |
BuildingInfoCards | Summary cards (type, year, heritage, ownership) |
BuildingMap | Leaflet map view with building marker |
BuildingTabs | Tab navigation on detail page |
BuildingFinancialsTab | Quotes and Invoices overview |
BuildingFilesTab | Attached Files and Documents |
Features
- Map view on the buildings list page (Leaflet) with geocoded markers
- Energy calculations via Building Components and calculation parameters
- Financial overview aggregating Quotes and Invoices per building
- HubSpot sync — buildings mirror HubSpot Listings (not deals — HubSpot Deals map to Projects) with pipeline/stage tracking
- Access control via
building_rolestable (maps Contacts to buildings) and RBAC Authorization (verifyBuildingAccess())
Related Pages
Projects | Building Components | Scenarios | Files | Quotes | Invoices | Contacts | Energy Calculations | Financial Calculations | HubSpot Integration | Database Architecture