# hexninja555/opentakeoff architecture

> Architecture diagram of the GitHub repository hexninja555/opentakeoff, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-12). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/hexninja555/opentakeoff
- Repository: https://github.com/hexninja555/opentakeoff

## Overview

OpenTakeoff is a browser-based building-plan takeoff canvas, with an MCP server that exposes the same measurement engine to AI agents. The main workflow is to bring in a plan, work across its sheets, measure and classify shapes, then review quantities and export reports. The graph also preserves documented materials, marked-set, and optional Google Drive capabilities. Some UI and domain modules are unsampled; their inclusion reflects the README and source index, while uncertain connections are omitted.

Main entry points: [`web/src/pages/TakeoffCanvas.jsx`](https://github.com/hexninja555/opentakeoff/blob/main/web/src/pages/TakeoffCanvas.jsx) (Takeoff Canvas), [`web/src/components/TakeoffsPanel.jsx`](https://github.com/hexninja555/opentakeoff/blob/main/web/src/components/TakeoffsPanel.jsx) (Takeoff Controls), [`mcp/src/session.ts`](https://github.com/hexninja555/opentakeoff/blob/main/mcp/src/session.ts) (Plan Session), [`web/src/components/ReportPanel.jsx`](https://github.com/hexninja555/opentakeoff/blob/main/web/src/components/ReportPanel.jsx) (Report Panel)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_canvas["Plan Canvas"]
  node_canvas_ui["Takeoff Canvas<br/>[TakeoffCanvas.jsx]"]
  node_ingest["Plan Ingest<br/>[ingest.js]"]
  node_sheet_index["Sheets<br/>[sheets.ts]"]
  node_icons["Canvas Icons<br/>[icons.jsx]"]
end

subgraph group_measure["Takeoff Engine"]
  node_oneclick["One-Click Area<br/>[oneclick.ts]"]
  node_geometry["Geometry and Snapping<br/>[geometry.js]"]
  node_conditions["Condition Fields"]
  node_units["Units<br/>[units.ts]"]
  node_materials["Materials<br/>[materials.js]"]
  node_measurements["Takeoff Controls<br/>[TakeoffsPanel.jsx]"]
end

subgraph group_report["Reports and Outputs"]
  node_reports_ui["Report Panel<br/>[ReportPanel.jsx]"]
  node_totals["Quantity Totals<br/>[totals.js]"]
  node_report_fields["Report Fields<br/>[reportColumns.js]"]
  node_shape_labels["Shape Labels<br/>[shapeLabels.js]"]
  node_rfi["RFIs<br/>[rfi.js]"]
  node_marked_set["Marked Set Export<br/>[markedset.js]"]
end

subgraph group_agent["Agent Interface"]
  node_mcp_server["MCP Server<br/>[server.ts]"]
  node_mcp_tools["MCP Tools<br/>[tools.ts]"]
  node_mcp_session["Plan Session<br/>[session.ts]"]
  node_mcp_resources["MCP Resources<br/>[resources.ts]"]
end

subgraph group_state["Project State"]
  node_local_store[("Local Store<br/>[store.js]")]
  node_app_entry["App Entry<br/>[main.jsx]"]
  node_auth_context["Google Auth Context<br/>[AuthContext.jsx]"]
  node_google_auth["Google Auth<br/>[auth.js]"]
end

node_estimator(("Estimator"))
node_mcp_client(("MCP Client"))
node_drive[("Google Drive")]

node_estimator -->|"opens plan"| node_canvas_ui
node_canvas_ui -->|"ingests files"| node_ingest
node_canvas_ui -->|"uses sheet keys"| node_sheet_index
node_canvas_ui -->|"stores plan data"| node_local_store
node_canvas_ui -->|"renders controls"| node_measurements
node_measurements -->|"uses fields"| node_conditions
node_estimator -->|"measures plan"| node_measurements
node_mcp_client -->|"connects over stdio"| node_mcp_server
node_mcp_server -->|"registers tools"| node_mcp_tools
node_mcp_server -->|"registers resources"| node_mcp_resources
node_mcp_tools -->|"dispatches calls"| node_mcp_session
node_mcp_session -->|"extracts geometry"| node_oneclick
node_mcp_session -->|"builds snap grid"| node_geometry
node_mcp_session -->|"uses sheet keys"| node_sheet_index
node_mcp_session -->|"uses quantities"| node_totals
node_mcp_resources -->|"reads session"| node_mcp_session
node_estimator -->|"reviews quantities"| node_reports_ui
node_reports_ui -->|"builds report"| node_totals
node_reports_ui -->|"saves column prefs"| node_report_fields
node_reports_ui -->|"exports labels"| node_shape_labels
node_reports_ui -->|"exports RFIs"| node_rfi
node_canvas_ui -->|"exports marked set"| node_marked_set
node_totals -->|"labels shapes"| node_shape_labels
node_app_entry -->|"renders canvas"| node_canvas_ui
node_app_entry -->|"provides auth"| node_auth_context
node_auth_context -->|"calls auth"| node_google_auth
node_app_entry -->|"selects project store"| node_local_store
node_local_store -.->|"optional cloud sync"| node_drive
node_measurements -.->|"uses measurement engine"| node_oneclick
node_measurements -.->|"converts quantities"| node_units
node_measurements -.->|"configures materials"| node_materials

click node_canvas_ui "https://github.com/hexninja555/opentakeoff/blob/main/web/src/pages/TakeoffCanvas.jsx"
click node_ingest "https://github.com/hexninja555/opentakeoff/blob/main/web/src/lib/ingest.js"
click node_sheet_index "https://github.com/hexninja555/opentakeoff/blob/main/web/src/lib/sheets.ts"
click node_icons "https://github.com/hexninja555/opentakeoff/blob/main/web/src/brand/icons.jsx"
click node_oneclick "https://github.com/hexninja555/opentakeoff/blob/main/web/src/lib/oneclick.ts"
click node_geometry "https://github.com/hexninja555/opentakeoff/blob/main/web/src/lib/geometry.js"
click node_conditions "https://github.com/hexninja555/opentakeoff/blob/main/web/src/lib/conditionColumns.js"
click node_units "https://github.com/hexninja555/opentakeoff/blob/main/web/src/lib/units.ts"
click node_materials "https://github.com/hexninja555/opentakeoff/blob/main/web/src/lib/materials.js"
click node_measurements "https://github.com/hexninja555/opentakeoff/blob/main/web/src/components/TakeoffsPanel.jsx"
click node_reports_ui "https://github.com/hexninja555/opentakeoff/blob/main/web/src/components/ReportPanel.jsx"
click node_totals "https://github.com/hexninja555/opentakeoff/blob/main/web/src/lib/totals.js"
click node_report_fields "https://github.com/hexninja555/opentakeoff/blob/main/web/src/lib/reportColumns.js"
click node_shape_labels "https://github.com/hexninja555/opentakeoff/blob/main/web/src/lib/shapeLabels.js"
click node_rfi "https://github.com/hexninja555/opentakeoff/blob/main/web/src/lib/rfi.js"
click node_marked_set "https://github.com/hexninja555/opentakeoff/blob/main/web/src/lib/markedset.js"
click node_mcp_server "https://github.com/hexninja555/opentakeoff/blob/main/mcp/server.ts"
click node_mcp_tools "https://github.com/hexninja555/opentakeoff/blob/main/mcp/src/tools.ts"
click node_mcp_session "https://github.com/hexninja555/opentakeoff/blob/main/mcp/src/session.ts"
click node_mcp_resources "https://github.com/hexninja555/opentakeoff/blob/main/mcp/src/resources.ts"
click node_local_store "https://github.com/hexninja555/opentakeoff/blob/main/web/src/lib/store.js"
click node_app_entry "https://github.com/hexninja555/opentakeoff/blob/main/web/src/main.jsx"
click node_auth_context "https://github.com/hexninja555/opentakeoff/blob/main/web/src/lib/google/AuthContext.jsx"
click node_google_auth "https://github.com/hexninja555/opentakeoff/blob/main/web/src/lib/google/auth.js"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_canvas_ui,node_ingest,node_sheet_index,node_icons,node_mcp_client toneBlue
class node_oneclick,node_geometry,node_conditions,node_units,node_materials,node_measurements,node_drive toneAmber
class node_reports_ui,node_totals,node_report_fields,node_shape_labels,node_rfi,node_marked_set toneMint
class node_mcp_server,node_mcp_tools,node_mcp_session,node_mcp_resources toneRose
class node_local_store,node_app_entry,node_auth_context,node_google_auth,node_estimator toneIndigo
```

## Components

### Plan Canvas

- [Takeoff Canvas](https://github.com/hexninja555/opentakeoff/blob/main/web/src/pages/TakeoffCanvas.jsx): `web/src/pages/TakeoffCanvas.jsx`
- [Plan Ingest](https://github.com/hexninja555/opentakeoff/blob/main/web/src/lib/ingest.js): `web/src/lib/ingest.js`
- [Sheets](https://github.com/hexninja555/opentakeoff/blob/main/web/src/lib/sheets.ts): `web/src/lib/sheets.ts`
- [Canvas Icons](https://github.com/hexninja555/opentakeoff/blob/main/web/src/brand/icons.jsx): `web/src/brand/icons.jsx`

### Takeoff Engine

- [One-Click Area](https://github.com/hexninja555/opentakeoff/blob/main/web/src/lib/oneclick.ts): `web/src/lib/oneclick.ts`
- [Geometry and Snapping](https://github.com/hexninja555/opentakeoff/blob/main/web/src/lib/geometry.js): `web/src/lib/geometry.js`
- [Condition Fields](https://github.com/hexninja555/opentakeoff/blob/main/web/src/lib/conditionColumns.js): `web/src/lib/conditionColumns.js`
- [Units](https://github.com/hexninja555/opentakeoff/blob/main/web/src/lib/units.ts): `web/src/lib/units.ts`
- [Materials](https://github.com/hexninja555/opentakeoff/blob/main/web/src/lib/materials.js): `web/src/lib/materials.js`
- [Takeoff Controls](https://github.com/hexninja555/opentakeoff/blob/main/web/src/components/TakeoffsPanel.jsx): `web/src/components/TakeoffsPanel.jsx`

### Reports and Outputs

- [Report Panel](https://github.com/hexninja555/opentakeoff/blob/main/web/src/components/ReportPanel.jsx): `web/src/components/ReportPanel.jsx`
- [Quantity Totals](https://github.com/hexninja555/opentakeoff/blob/main/web/src/lib/totals.js): `web/src/lib/totals.js`
- [Report Fields](https://github.com/hexninja555/opentakeoff/blob/main/web/src/lib/reportColumns.js): `web/src/lib/reportColumns.js`
- [Shape Labels](https://github.com/hexninja555/opentakeoff/blob/main/web/src/lib/shapeLabels.js): `web/src/lib/shapeLabels.js`
- [RFIs](https://github.com/hexninja555/opentakeoff/blob/main/web/src/lib/rfi.js): `web/src/lib/rfi.js`
- [Marked Set Export](https://github.com/hexninja555/opentakeoff/blob/main/web/src/lib/markedset.js): `web/src/lib/markedset.js`

### Agent Interface

- [MCP Server](https://github.com/hexninja555/opentakeoff/blob/main/mcp/server.ts): `mcp/server.ts`
- [MCP Tools](https://github.com/hexninja555/opentakeoff/blob/main/mcp/src/tools.ts): `mcp/src/tools.ts`
- [Plan Session](https://github.com/hexninja555/opentakeoff/blob/main/mcp/src/session.ts): `mcp/src/session.ts`
- [MCP Resources](https://github.com/hexninja555/opentakeoff/blob/main/mcp/src/resources.ts): `mcp/src/resources.ts`

### Project State

- [Local Store](https://github.com/hexninja555/opentakeoff/blob/main/web/src/lib/store.js): `web/src/lib/store.js`
- [App Entry](https://github.com/hexninja555/opentakeoff/blob/main/web/src/main.jsx): `web/src/main.jsx`
- [Google Auth Context](https://github.com/hexninja555/opentakeoff/blob/main/web/src/lib/google/AuthContext.jsx): `web/src/lib/google/AuthContext.jsx`
- [Google Auth](https://github.com/hexninja555/opentakeoff/blob/main/web/src/lib/google/auth.js): `web/src/lib/google/auth.js`

### Other components

- **Estimator**
- **MCP Client**
- **Google Drive**

## Connections

- Estimator → Takeoff Canvas: opens plan
- Takeoff Canvas → Plan Ingest: ingests files (evidence: `web/src/pages/TakeoffCanvas.jsx`)
- Takeoff Canvas → Sheets: uses sheet keys (evidence: `web/src/pages/TakeoffCanvas.jsx`)
- Takeoff Canvas → Local Store: stores plan data (evidence: `web/src/pages/TakeoffCanvas.jsx`)
- Takeoff Canvas → Takeoff Controls: renders controls (evidence: `web/src/pages/TakeoffCanvas.jsx`)
- Takeoff Controls → Condition Fields: uses fields (evidence: `web/src/components/TakeoffsPanel.jsx`)
- Estimator → Takeoff Controls: measures plan
- MCP Client → MCP Server: connects over stdio (evidence: `mcp/server.ts`)
- MCP Server → MCP Tools: registers tools (evidence: `mcp/server.ts`)
- MCP Server → MCP Resources: registers resources (evidence: `mcp/server.ts`)
- MCP Tools → Plan Session: dispatches calls (evidence: `mcp/src/tools.ts`)
- Plan Session → One-Click Area: extracts geometry (evidence: `mcp/src/session.ts`)
- Plan Session → Geometry and Snapping: builds snap grid (evidence: `mcp/src/session.ts`)
- Plan Session → Sheets: uses sheet keys (evidence: `mcp/src/session.ts`)
- Plan Session → Quantity Totals: uses quantities (evidence: `mcp/src/session.ts`)
- MCP Resources → Plan Session: reads session (evidence: `mcp/src/resources.ts`)
- Estimator → Report Panel: reviews quantities
- Report Panel → Quantity Totals: builds report (evidence: `web/src/components/ReportPanel.jsx`)
- Report Panel → Report Fields: saves column prefs (evidence: `web/src/components/ReportPanel.jsx`)
- Report Panel → Shape Labels: exports labels (evidence: `web/src/components/ReportPanel.jsx`)
- Report Panel → RFIs: exports RFIs (evidence: `web/src/components/ReportPanel.jsx`)
- Takeoff Canvas → Marked Set Export: exports marked set (evidence: `web/src/pages/TakeoffCanvas.jsx`)
- Quantity Totals → Shape Labels: labels shapes (evidence: `web/src/lib/totals.js`)
- App Entry → Takeoff Canvas: renders canvas (evidence: `web/src/main.jsx`)
- App Entry → Google Auth Context: provides auth (evidence: `web/src/main.jsx`)
- Google Auth Context → Google Auth: calls auth (evidence: `web/src/lib/google/AuthContext.jsx`)
- App Entry → Local Store: selects project store (evidence: `web/src/main.jsx`)
- Local Store → Google Drive: optional cloud sync
- Takeoff Controls → One-Click Area: uses measurement engine
- Takeoff Controls → Units: converts quantities (evidence: `web/src/components/TakeoffsPanel.jsx`)
- Takeoff Controls → Materials: configures materials
