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: buildings mirrors the HubSpot Listing object (objectTypeId 0-420, listingConfig in services/hubspot/sync-engine/entity-configs.ts). The hubspotId column is the vendor identifier used only for sync round-tripping — internal cross-table references always join on buildings.id (UUID PK). See HubSpot Integration.

Source Files

LayerPath
Schemabackend/src/db/schema.ts (buildings)
Routesbackend/src/routes/buildings/ (crud.ts, aggregates.ts)
Servicebackend/src/services/buildings-service.ts
Pagesfrontend/src/pages/Buildings.tsx, frontend/src/pages/BuildingDetail.tsx
Queriesfrontend/src/lib/queries/buildingQueries.ts, buildingComponentQueries.ts, buildingRoleQueries.ts

Database Tables

TablePurpose
buildingsMain entity — address, type, year, geometry, HubSpot sync fields
building_componentsStructural elements (walls, roof, windows, etc.) — see Building Components
building_technologyTechnical systems (heating, ventilation, PV, solar thermal)
building_calculation_parametersParameters for Energy Calculations (residential units, areas)
building_rolesRBAC Authorization — maps Contacts to buildings with roles

Key Fields

FieldTypeNotes
buildingTypeenumsingle_family_detached, multi_family, commercial, mixed_use_*, etc.
yearBuiltintegerConstruction year
heritageStatusenumnone, listed_monument, ensemble_protection, unesco_world_heritage, etc.
ownershipStructureenumowner_occupied, rental, cooperative, condominium, mixed
street, houseNumber, postalCode, cityvarcharUnified address structure (I#1329)
lat, lngdoubleGPS coordinates for map view
residentialUnitsintegerHubSpot Listing mirror value (Anzahl Wohneinheiten) — sync overwrites on every run (PR#1983, I#1962)
livingArearealWohnfläche m², HubSpot mirror (PR#1983); not the same as heatedArea
heatedArearealBeheizte Fläche m² — EB-maintained, no HubSpot source
hubspotIdvarchar(100)HubSpot Listing ID (unique) — sync round-trip only, never used for internal joins
hubspotPipeline, hubspotPipelineStagevarcharListing pipeline mirror
recordOwnerContactIduuid FKRead-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, lastSyncedAtjsonb/varchar/timestampRaw HubSpot property bag + sync metadata
userIduuid FKCreator user — nullable, set null on delete (I#1724)
archived, archivedAt, deletedAt, archiveReason, mergedIntoHubspotIdvariousHubSpot 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

ComponentPurpose
BuildingFormCreate/edit building with address autocomplete
BuildingDetailHeaderTitle, status badges, actions
BuildingInfoCardsSummary cards (type, year, heritage, ownership)
BuildingMapLeaflet map view with building marker
BuildingTabsTab navigation on detail page
BuildingFinancialsTabQuotes and Invoices overview
BuildingFilesTabAttached 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_roles table (maps Contacts to buildings) and RBAC Authorization (verifyBuildingAccess())

Projects | Building Components | Scenarios | Files | Quotes | Invoices | Contacts | Energy Calculations | Financial Calculations | HubSpot Integration | Database Architecture