Projects

A renovation project associated with a building. Projects track the full lifecycle from initial contact through funding payout, with phase management, Gantt visualization, and role-based access.

Source Files

LayerPath
Schemabackend/src/db/schema.ts (line ~755)
Routesbackend/src/routes/projects.ts
Servicebackend/src/services/project-service.ts
Pagesfrontend/src/pages/ProjectDetail.tsx
Queriesfrontend/src/lib/queries/projectQueries.ts

Database Tables

TablePurpose
projectsMain entity — name, phase, timeline, budget, HubSpot sync
project_phase_historyAudit trail of phase transitions (from/to, changed_by, timestamp)
project_rolesRBAC Authorization — maps Contacts to projects with roles

Key Fields

FieldTypeNotes
namevarchar(200)Project name
buildingIduuid FKParent building (cascade delete)
currentPhaseenumSee phase lifecycle below
phaseChangedAttimestampWhen the current phase was entered
selectedScenarioIduuidThe chosen scenario for execution
totalBudgetrealOverall budget estimate
startDate, plannedEndDate, actualEndDatetimestampTimeline tracking
hubspotIdvarcharSync with HubSpot Integration

Phase Lifecycle

Managed by projectPhaseEnum, transitions tracked in project_phase_history:

initial_contact -> consultation -> offer_sales -> funding_application
    -> execution -> results_presentation -> funding_completion -> funding_payout

Each transition records fromPhase, toPhase, changedBy, and optionally selectedScenarioId.

Relationships

Project *──1 Building
Project 1──* Scenarios
Project 1──* Funding Applications
Project 1──* Quotes
Project 1──* Invoices
Project 1──* Project Roles ──* Contacts
Project *──1 Users (creator)

Frontend Components

ComponentPurpose
ProjectFormCreate/edit project details
ProjectGanttViewGantt chart timeline visualization
ProjectOverviewCardSummary card with phase, budget, dates
ProjectRoleManagerAssign Contacts to project roles
PhaseHistoryTimeline of phase transitions
PhaseProgressBarVisual progress through phases
PhaseTransitionControlsButtons/dialogs to advance phases

Features

  • Phase management with transition controls and audit history
  • Gantt chart visualization of project timeline
  • Scenario selection — pick the winning scenario for execution
  • Role management via project_roles and RBAC Authorization (verifyProjectAccess())
  • Financial tracking through linked Quotes, Invoices, Funding Applications

Buildings | Scenarios | Funding Applications | Quotes | Invoices | Contacts | RBAC Authorization | Scenario Planning | Financial Calculations | HubSpot Integration