Internal Engineering Specification

AI Takeoff Engine: Core Architecture & Mathematical Assemblies

High-performance Blueprint Vector Extraction, Interactive Canvas Measurement & Trade Assembly Math

1 Core Architecture Pipeline (For Takeoffs)

Vector PDF Pipeline
[Vector PDF / Scanned Plan]
            │
            ▼
┌──────────────────────────────────────┐
│  1. Document & Vector Extraction     │ ➔ Extracts lines, text strings, bounding boxes
└──────────────────────────────────────┘
            │
            ▼
┌──────────────────────────────────────┐
│  2. Interactive Measurement Canvas   │ ➔ User calibrates scale & draws geometries
└──────────────────────────────────────┘
            │
            ▼
┌──────────────────────────────────────┐
│  3. Trade Assembly Engine (Math)     │ ➔ Converts raw LF/SF/Counts to trade BOM
└──────────────────────────────────────┘
            │
            ▼
┌──────────────────────────────────────┐
│  4. Work Breakdown / Bid Output      │ ➔ Trade divisions (Concrete, Framing, Drywall)
└──────────────────────────────────────┘
      

2. The Four Build Components

Comprehensive layer-by-layer architectural breakdown

Layer 1: Plan Rendering & Coordinate Alignment

Do not treat blueprints as flat images. Modern architectural PDFs are vector documents containing raw geometry and coordinate-mapped text.

Frontend Engine

Use pdfjs-dist to render pages into an HTML5 <canvas> or WebGL viewport.

Vector Text Snapping

Call page.getTextContent() in PDF.js. It returns an array of text tokens with exact [x, y] coordinates. Automatically locate room names, door/window callouts, and dimension strings without burning OCR cycles.

Tiling & Virtualized Zoom

Blueprints are typically 24"x36" (Arch D) or 36"x48" (Arch E) at 300+ DPI. Implement viewport canvas virtualization so zooming into a foundation detail doesn't crash browser memory.

Layer 2: Interactive Measurement Canvas (React + Konva / Fabric.js)

Overlay a transparent canvas layer over the PDF canvas to capture user inputs with pixel-perfect coordinate tracking:

A Two-Point Scale Calibration

User clicks Point A (x1, y1) and Point B (x2, y2) across a known dimension line (e.g., a 20' 0" dimension callout).

Distance in screen pixels:
d_px = √((x2 - x1)² + (y2 - y1)²)
Scale ratio calculation:
pixelsPerFoot = d_px / realFeet
B Area Calculation (Shoelace Formula on Polygons)

Collect polygon vertices [(x0, y0), (x1, y1), ..., (xn, yn)]. Calculate area using the Gauss Shoelace algorithm in screen pixels, then normalize:

Area_sqft = ( 0.5 * | ∑(i=0 to n-1) (x_i * y_{i+1} - x_{i+1} * y_i) | ) / (pixelsPerFoot)²
Linear Runs (Polyline Tool)

Sum Euclidean segment distances and divide by pixelsPerFoot for footings, wall framing, and baseboard trim.

Item Counts (Point Marker Tool)

Click-to-drop coordinate markers for fixtures, recessed lighting cans, and plumbing drain drops.

Layer 3: Trade Assembly Math Engine

Converts raw linear feet, square feet, and coordinate counts into contractor purchasing units:

Concrete (Slabs & Footings) Cubic Yards (CY)
Cubic Yards = ( (Area_sqft * (Thickness_in / 12)) / 27 ) * (1 + Waste_Factor)
Rebar Grid Formula (3ft on center):
Total LF = ((Length / 3) * Width) + ((Width / 3) * Length)
Framing (Wood & Steel Walls) Lumber BOM
Top/Bottom Plates = Linear_Feet_of_Wall * 3
Stud count (16" O.C.):
Studs = ( (Linear_Feet * 12) / 16 ) * 1.15 (corners, tees, trimmers)
Drywall Assemblies 4x12 Boards
Wall Area = Linear_Feet_of_Wall * Ceiling_Height * 2 (both sides)
Panel count (4x12 boards = 48 sq ft):
Panels = ⌈Total_SF / 48⌉ * 1.10 (10% waste)
Roofing Squares 100 SQ FT
Pitch Factor = √(1 + (Rise / 12)²)
Roof Squares:
Roof Squares = ( (Footprint_Area * Pitch_Factor) / 100 ) * 1.10

Layer 4: Data Schema & Subcontractor Packaging

Store measurements in normalized JSON so a single drawn polygon or linear run generates multiple trade line items simultaneously:

{
  "takeoff_id": "proj_101",
  "scale_factor_px_per_ft": 48.0,
  "layers": [
    {
      "name": "Exterior Slab",
      "geometry_type": "polygon",
      "coordinates": [[120, 240], [600, 240], [600, 480], [120, 480]],
      "raw_area_sqft": 450.0,
      "assemblies": [
        {
          "trade": "Concrete",
          "item": "3500 PSI Slab 4-inch",
          "calculated_qty": 5.83,
          "unit": "CY"
        },
        {
          "trade": "Concrete",
          "item": "#3 Rebar (3ft O.C. Grid)",
          "calculated_qty": 345.0,
          "unit": "LF"
        },
        {
          "trade": "Excavation",
          "item": "10 mil Vapor Barrier",
          "calculated_qty": 495.0,
          "unit": "SF"
        }
      ]
    }
  ]
}

Immediate Implementation Roadmap

1
Build the Interactive Canvas Sandbox

Create a single component using react-konva (or Fabric.js) and pdfjs-dist that loads a sample 1-page PDF plan, allows drawing a 2-point line, and prompts for real footage to store px_per_ft.

2
Build the Polygon Shoelace Utility

Implement the Shoelace formula on closed canvas paths to output square footage dynamically as vertices are placed.

3
Write the Assembly Formula Store

Create a modular mapping function that takes { type: 'slab', area_sqft, thickness_in, rebar_oc_ft } and outputs the bill of materials in standard job-site units.

ConstructionCostEstimator.app — Internal Blueprint & Vector Takeoff Engine Specifications