Cloud Construction Cost-Estimating Platform with Lossless Desktop-File Interop
Overview
Deviz Cloud is a cloud-native, multi-tenant construction cost-estimating platform
(devize, recapitulații, antemăsurători) that reads and writes the .is* interchange files
of a widely used Romanian desktop estimating suite, browser-only, no dongle. This repo
holds both the ten-document build specification (docs/01 → docs/10) and the
monorepo implementation that followed it, including a live Vercel deployment.
The Challenge
Romanian construction estimators work in a desktop tool whose project files are a proprietary container (an encrypted zip wrapping a .NET typed-DataSet XML with dozens of tables). Moving that workflow to the cloud only works if files round-trip losslessly, the cost arithmetic reproduces the desktop totals exactly (unit prices from resource recipes, surcharges, recap indices that compound across levels, VAT, rounding rules), and the licensed norm catalogs (indicatoare) can be loaded without being redistributed. On top of that, the product had to be usable by AI agents as a first-class client.
What We Built
An npm-workspaces monorepo with three framework-free packages and one app:
@isdp/format, reader/writer for the.is*container (ZipCrypto zip + typed-DataSet XML viafflate), with a byte-identical round-trip guarantee; the realdsExportDevizschema (34 tables) is captured inreference/dsExportDeviz.schema.json.@deviz/calc, the cost engine ondecimal.js: article unit prices (PU = Σ consum × preț × (1+spor)), minor-materials %, hours and weight, line costs with optional rounding, tree roll-up, recap levels (additive within a level, compounding across levels, % or absolute), VAT, and a measurement-sheet formula evaluator.@deviz/db, Postgres schema and migrations in Drizzle, a lossless.is*↔ relational mapping (unmodelled tables/columns carried verbatim), repositories with server-side recompute, auth, and an idempotent truncate-and-COPY importer for the norm catalog (CSV exports of the desktop norm database, ~3M rows).apps/web, Next.js 16 App Router app: organizations with owner/admin/estimator/viewer roles, projects explorer (investiție → obiect → deviz), a virtualized deviz grid with inline edits, article drawer (recipe, prices, antemăsurătoare), recap editor with cost waterfall, resources view with bulk re-pricing, norms catalog, settlements (decont snapshots), import with validation report, export to.isam, and variants.
A client-feedback round (spec doc 10) added investment-level roll-up recap and editable
C6–C9 price lists, an editable Deviz General on the HG 907/2016 chapter template that
round-trips to the desktop DevizGeneralStructura tables, bid packages as a single PDF
(DG, F1–F4, C6–C9 via @react-pdf/renderer), equipment lists with fișe tehnice,
settlement cases with cumulative situații de plată, and a Gantt schedule.
Every capability is also exposed three ways from the same code: REST routes under
/api (every mutation returns recomputed totals), a stateless Streamable-HTTP MCP server
at /api/mcp authenticated with org-scoped API keys, and a public OpenAPI 3.1 document.
For connectors the server implements the standard OAuth flow, well-known metadata
endpoints, dynamic client registration, authorization code + PKCE with a consent screen,
refresh-token rotation, so ChatGPT and Claude.ai can connect without a key. An in-app
/developers page lists live MCP tool schemas and connection snippets.
Technologies & Approach
Spec first: ten ordered documents (product overview, domain model, cost calculation,
features, file-format compatibility contract, cloud architecture, data model, API design,
roadmap, client-feedback gap analysis) were written before code, and the implementation
tracks them. The format, calc and DB layers are framework-free so they can be tested in
isolation with Vitest; golden tests import the real sample files, recompute every article
and deviz from resources and indices, assert equality with the totals stored in the file,
then export and compare table by table. The web app sits on Next.js 16 / React 19 /
Tailwind 4 with TanStack Virtual for large grids, Zod for validation, and Drizzle over
pg against Neon Postgres (local Docker Postgres 16 for development). Files are stored in
Postgres so no object storage is needed. A cloud-bootstrap.sh script provisions Neon,
migrates, seeds the demo account and loads the catalog in one go; a Playwright screenshot
tool checks every screen in light/dark/mobile.
Outcome / Impact
Validated, within a short build window, that a desktop-locked estimating workflow can move
to the browser without breaking file compatibility: real .isam files import, recompute to
the stored totals, and export back losslessly. The build runs as a live multi-tenant demo
on Vercel with self-registration closed, incorporates a full round of client feedback
(investment-level reporting, bid and settlement packages, Gantt), and doubles as an MCP
server so AI assistants can read and edit estimates through the same domain model.
Capabilities Demonstrated
- Reverse-engineering a proprietary desktop interchange format with byte-identical round-trip
- Decimal-exact financial calculation engine validated by golden tests against real customer files
- Lossless mapping of a 34-table typed DataSet into a relational Postgres model
- Multi-tenant SaaS with organization roles, API keys and OAuth 2.1 + PKCE consent flow
- One domain exposed as web UI, REST, OpenAPI 3.1 and an MCP server for AI agents
- Spec-driven delivery: structured product/architecture docs feeding a monorepo build
- Server-rendered PDF reporting (bid packages, settlement statements) with React
- Bulk data ingestion of multi-million-row licensed catalogs via idempotent COPY importers