tpt-construction

Rust

Modular Rust workspace of reusable, dual-licensed (MIT OR Apache-2.0) construction-industry libraries — BIM/IFC, estimating, scheduling, civil/earthwork, field execution, and digital twins.

1 stars1 forks1 watchersApache License 2.0

Languages

Rust99.8%Shell0.2%
README

tpt-construction

CI License headers License: MIT OR Apache-2.0

Dual-licensed MIT OR Apache-2.0 · TPT Solutions

A modular Rust workspace providing reusable libraries for the construction industry: BIM/IFC, quantity takeoff, estimating, scheduling, project controls, field management, civil/earthwork, equipment telemetry, safety, documents, contracts, facility management, digital twins, and WebAssembly tooling.

tpt-construction is the construction domain layer of the TPT ecosystem:

tpt-math            numeric computation
        ↑
tpt-engineering     applied engineering primitives
        ↑
tpt-construction    tpt-c-* construction crates

The two upstream substrates are not required to build this repository today: the crates here are self-contained, and the local [patch.crates-io] overrides for ../tpt-math / ../tpt-engineering stay commented out in the root manifest until those checkouts are available locally.

Status

ItemState
Library crates40 tpt-c-* crates — all workspace members, all with their own README.md and CHANGELOG.md
Examples / binaries9 — ifc-import, quantity-takeoff, estimate-export, cpm-schedule, earthwork-cut-fill, field-execution-e2e, field-offline-sync, wasm-browser-demo, and the tpt CLI
Version0.1.0 (pre-1.0; APIs may change between releases)
Toolchainstable Rust, edition 2021
Testscargo test --workspace --all-features green (222 tests)
License policycargo deny check licenses green — no Apache-only crates remain
WASM targettpt-c-wasm is buildable for wasm32-unknown-unknown

Every crate under crates/ is listed in the root manifest's members, so cargo test --workspace and all CI gates cover the entire set; a CI job fails if a crates/* directory is ever left out again.

Quick start

Requires a stable Rust toolchain and cargo (rustup recommended):

git clone https://github.com/tpt-solutions/tpt-construction.git
cd tpt-construction

cargo build --workspace        # build every workspace member
cargo test --workspace         # run the unit and integration tests

CLI: price a model and export an estimate

The tpt binary reads a neutral model (tpt-c-model JSON) plus a CSV cost database and writes a multi-sheet .xlsx estimate:

cargo run -p tpt -- estimate test-data/golden/sample-model.json \
    --cost-db test-data/golden/rates.csv \
    --output estimate.xlsx
Estimate written to estimate.xlsx: 5 line items, subtotal 6141.10 USD, total 7295.63 USD

Running tpt with no arguments — or with help / --help / -h — prints the usage summary.

CLI: serve the engines over HTTP

With the serve feature the CLI also exposes takeoff, estimate, and CPM scheduling as JSON endpoints (bearer-token auth optional):

cargo run -p tpt --features serve -- serve --addr 127.0.0.1:8090
curl -s http://127.0.0.1:8090/health        # {"status":"ok"}

See cookbook/11-serve-over-http.md for the full endpoint list.

Learning path

  • docs/getting-started.md — the smallest end-to-end flow (model → takeoff → estimate → export), CLI and library.
  • cookbook/ — minimal, copy-paste recipes for the common workflows, with verified outputs.
  • CONTRIBUTING.md — dev commands and crate conventions; CHANGELOG.md — what changed and when.

Runnable examples

Each example is a workspace member; run it with cargo run -p <name>:

# Parse IFC (STEP) text into the neutral tpt-c-model (defaults to test-data/ifc/sample.ifc)
cargo run -p ifc-import
cargo run -p ifc-import -- path/to/model.ifc

# Quantity takeoff over a neutral model JSON
cargo run -p quantity-takeoff -- test-data/golden/sample-model.json

# Model + cost database -> estimate.xlsx
cargo run -p estimate-export -- test-data/golden/sample-model.json \
    test-data/golden/rates.csv estimate.xlsx

# CPM schedule + Monte Carlo risk + earned-value snapshot
cargo run -p cpm-schedule

# Alignment stake-out + mass haul + cut/fill balance
cargo run -p earthwork-cut-fill

# Offline CRDT sync between two field devices + event-sourced audit replay
cargo run -p field-offline-sync

# Daily log -> RFI -> transmittal -> contract notice/claim -> pay app -> safety incident
cargo run -p field-execution-e2e

# WASM-facing API demo (IFC import, takeoff, glTF export surface)
cargo run -p wasm-browser-demo

Crate naming

All crates in this workspace use the tpt-c- prefix. Rust import names use underscores:

use tpt_c_core::ProjectId;
use tpt_c_ifc::IfcProject;
use tpt_c_quantities::TakeoffEngine;
use tpt_c_estimating::EstimateBuilder;

Workspace layout

tpt-construction/
├── Cargo.toml            # virtual workspace manifest (members + workspace deps)
├── crates/               # tpt-c-* libraries (each with README.md + CHANGELOG.md)
├── examples/             # runnable end-to-end examples and the `tpt` CLI
├── cookbook/             # minimal, heavily-commented copy-paste recipes
├── docs/                 # source-file-header.txt, getting-started.md
├── scripts/              # CI helper scripts (workspace membership check)
└── test-data/            # fixtures: ifc/, bcf/, golden/
    ├── ifc/sample.ifc
    ├── bcf/markup.bcf
    └── golden/           # sample-model.json, rates.csv, estimate.xlsx

Crates

Every crate has its own README (linked in the reference below), CHANGELOG, and crates.io metadata (categories/keywords).

LayerCrates
Foundationtpt-c-core, tpt-c-ids, tpt-c-units, tpt-c-classification, tpt-c-model
Geometry & formatstpt-c-geometry, tpt-c-geo, tpt-c-ifc, tpt-c-bcf, tpt-c-gltf, tpt-c-las, tpt-c-dxf
Estimatingtpt-c-quantities, tpt-c-cost, tpt-c-estimating, tpt-c-change, tpt-c-csv, tpt-c-xlsx
Scheduling & controlstpt-c-schedule, tpt-c-risk, tpt-c-earned-value
Civiltpt-c-earthwork, tpt-c-alignment
Field executiontpt-c-field, tpt-c-workflow, tpt-c-documents, tpt-c-contracts, tpt-c-payapps, tpt-c-safety
Equipment & synctpt-c-equipment, tpt-c-sync, tpt-c-events, tpt-c-db
FM & twinstpt-c-fm, tpt-c-assets, tpt-c-maintenance, tpt-c-twin, tpt-c-space
Web platformtpt-c-wasm, tpt-c-api

Crate reference

CratePurpose
tpt-c-coreCore domain primitives: ids, errors, audit metadata, project context
tpt-c-idsDeterministic/UUIDv7 id generation and external-id mapping (IFC GUID, Revit, cost codes, asset tags)
tpt-c-unitsConstruction measurement units, conversions, rounding, waste factors, domain measures
tpt-c-classificationMasterFormat, UniFormat, OmniClass, Uniclass support and project classification mapping
tpt-c-modelNeutral construction domain model: project, site, building, storey, zone, element, assembly, property/quantity sets
tpt-c-geometryPoints, vectors, meshes, bounding boxes, spatial indexing, area/volume, clash-detection primitives
tpt-c-geoCRS, lat/long, local site coordinates, elevations, grids, datums, transformations
tpt-c-ifcISO-10303-21 (STEP) IFC parser mapping building elements to the neutral tpt-c-model
tpt-c-bcfBIM Collaboration Format topics, viewpoints, comments, statuses, assignments (XML round-trip)
tpt-c-gltfExport neutral models to glTF 2.0 JSON for web/mesh viewers
tpt-c-lasLAS/LAZ point-cloud parsing, classification and volume estimation
tpt-c-dxfASCII DXF reader for LINE, LWPOLYLINE, CIRCLE, POINT and TEXT entities
tpt-c-csvTabular CSV import/export for estimates, cost databases, schedules and field logs
tpt-c-xlsxExcel (.xlsx) export for estimates, owner reports and bid summaries
tpt-c-quantitiesTakeoff engine: count/length/area/volume/weight, net vs gross, waste factors, manual overrides, derived rules
tpt-c-costResource rates, cost items, assemblies, line items, markups, budgets and estimates
tpt-c-estimatingEstimate builder, bid preparation, pricing workflows, revisions, comparison, cost planning
tpt-c-changeChange orders, revision diffs, quantity/cost deltas and change registers (spec §12)
tpt-c-scheduleActivities, relationships (FS/SS/FF/SF), calendars, constraints, CPM engine, float, baselines, actuals
tpt-c-riskSchedule and cost risk: Monte Carlo simulation, weather and productivity uncertainty
tpt-c-earned-valueEarned Value Management: PV/EV/AC, SPI, CPI, TCPI, EAC, ETC, VAC
tpt-c-earthworkEarthwork volumes, shrink/swell, mass haul and volume balancing
tpt-c-alignmentHorizontal/vertical road alignments, curves, superelevation, stationing, corridor modelling
tpt-c-fieldField execution records: daily logs, field reports, work records, manpower, weather, site observations
tpt-c-workflowApproval workflows and state machines for RFI, submittal, punch list, issue, change order, notice, transmittal
tpt-c-documentsDocument control: documents, drawings, specifications, revisions, transmittals
tpt-c-contractsContracts, contract items, responsibilities, notices, claims, compliance events
tpt-c-payappsProgress claims and payment applications: schedule of values, retention, approvals, certified amounts
tpt-c-safetyIncidents, near misses, safety observations, toolbox talks, inspections, compliance checklists
tpt-c-equipmentEquipment registry, utilization, fuel/maintenance tracking, telematics events
tpt-c-eventsDomain events, audit trail, event sourcing, projections, replay
tpt-c-syncOffline-first synchronization with CRDTs and deterministic conflict resolution
tpt-c-dbPersistence patterns: repositories, storage backends and a migration framework
tpt-c-fmFacility management: COBie handover data, asset registers, spaces and systems
tpt-c-assetsAsset lifecycle, warranties, serial numbers, replacements, maintenance schedules
tpt-c-maintenancePreventive/corrective maintenance, work orders, service history
tpt-c-twinDigital twin state, sensor mapping, live telemetry, spatial asset context
tpt-c-spaceSpaces, occupancy, leases, areas, space planning, utilization
tpt-c-wasmWASM bindings for IFC parsing and glTF export (pure engines re-exported for wasm32 builds)
tpt-c-apiREST/GraphQL API models, auth patterns, authorization, project access control, webhooks, audit logging

Industry coverage

The crate set targets at least 80% of common construction software needs (spec §19).

Industry DomainCovered By
BIM / model coordinationtpt-c-ifc, tpt-c-bcf, tpt-c-gltf, tpt-c-model
Quantity takeofftpt-c-quantities, tpt-c-geometry, tpt-c-model
Estimatingtpt-c-cost, tpt-c-estimating, tpt-c-classification
Cost controltpt-c-cost, tpt-c-earned-value, tpt-c-change
Schedulingtpt-c-schedule, tpt-c-risk, tpt-c-earned-value
Field managementtpt-c-field, tpt-c-workflow, tpt-c-documents
RFIs / submittalstpt-c-workflow, tpt-c-documents
Contractstpt-c-contracts, tpt-c-payapps
Payment applicationstpt-c-payapps
Safetytpt-c-safety, tpt-c-field
Civil / earthworktpt-c-geo, tpt-c-earthwork, tpt-c-alignment
Survey / point cloudstpt-c-las, tpt-c-geo
Equipment / IoTtpt-c-equipment, tpt-c-twin
Facility managementtpt-c-fm, tpt-c-assets, tpt-c-maintenance
Digital twinstpt-c-twin, tpt-c-equipment, tpt-c-assets
Offline field appstpt-c-sync, tpt-c-db
Web toolingtpt-c-wasm, tpt-c-gltf, tpt-c-api
Reporting / exportstpt-c-csv, tpt-c-xlsx

Design principles

  • Neutral model first — file formats parse into tpt-c-model; domain engines consume tpt-c-model and never depend directly on file formats.
  • Pure core crates — deterministic, testable, serializable, platform-independent; IO stays at the edges.
  • Event-first auditability — important changes are representable as domain events (QuantityAdjusted, RFIAnswered, ...).
  • Offline-first field support — assume poor connectivity; local storage, CRDT merge, retry queues.
  • WASM as a first-class target — engines compile to wasm32-unknown-unknown.

Development

Toolchain: stable Rust; the minimum supported Rust version is 1.82, declared as msrv in clippy.toml.

cargo fmt --all --check
cargo clippy --all-targets --all-features -- -D warnings
cargo test --workspace --all-features
cargo deny check                                     # licenses, bans, sources

Windows checkouts: there is no .gitattributes, and rustfmt.toml sets newline_style = "Unix", so a working tree created with core.autocrlf=true makes cargo fmt --all --check report Incorrect newline style for every file. Either re-checkout with git config core.autocrlf input, or run cargo fmt --all to normalize the tree first. CI runs on Linux, where the files are LF.

Continuous integration

JobCommand
Workspace membershipbash scripts/check-workspace-members.sh — fails if a crates/* directory is missing from [workspace] members (or a listed member is missing on disk)
Rustfmtcargo fmt --all --check
Clippycargo clippy --all-targets --all-features -- -D warnings
Testcargo test --workspace --all-features
Rustdoccargo doc --workspace --no-deps (warnings denied)
Cargo Denycargo deny check --all-features (licenses, bans, sources)
SPDX header checkevery .rs file under crates/ and examples/ must carry the SPDX header on line 1 or 2

See .github/workflows/ci.yml and .github/workflows/license.yml.

Source file headers

Every .rs file starts with (see docs/source-file-header.txt):

// Copyright (c) TPT Solutions
// SPDX-License-Identifier: MIT OR Apache-2.0

Dependency policy

Prefer an MIT-selectable dependency chain (spec §4). deny.toml allows MIT, Apache-2.0, BSD-2-Clause, BSD-3-Clause, ISC, Zlib, Unicode-DFS-2016, Unicode-3.0, and CC0-1.0; copyleft licenses are banned, unknown registries and unknown git sources are denied, and wildcard version requirements are denied.

Current direct dependencies (all MIT OR Apache-2.0):

DependencyUsed by
serde, serde_jsonmodel and format (de)serialization across the workspace
thiserrorlibrary error types
uuid (v5/v7)id generation in tpt-c-core, tpt-c-ids
zip + flate2 (rust_backend, no zopfli).xlsx writing in tpt-c-xlsx
quick-xmldev-dependency of tpt-c-xlsx (asserts the generated OOXML)
wasm-bindgen, serde-wasm-bindgen, web-sysoptional, behind tpt-c-wasm's js / web features

cargo deny check licenses passes with no Apache-only crates left: the earlier transitive Apache-only crates (zopfli via rust_xlsxwriter, ryu via csv) were removed by replacing those dependencies with lightweight in-house implementations in tpt-c-csv and tpt-c-xlsx.

WebAssembly builds

tpt-c-wasm re-exports the pure engines and gates the wasm-bindgen glue behind the js / web features (js is enabled by default):

cargo build -p tpt-c-wasm --target wasm32-unknown-unknown                        # with js glue
cargo build -p tpt-c-wasm --target wasm32-unknown-unknown --no-default-features  # pure Rust only

API documentation

cargo doc --workspace --no-deps --open

License

Licensed under either of

  • MIT license
  • Apache License, Version 2.0

at your option.

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this repository shall be dual licensed as MIT OR Apache-2.0, without any additional terms or conditions.

Contribution License Agreement

By submitting a contribution to this repository, you agree that your
contribution is licensed under either the MIT license or the Apache
License, Version 2.0, at the option of the project maintainers and
downstream users.