When building domain-specific web utilities—such as construction material estimators—most developers default to a database-backed SPA. However, contractors and DIY builders on a job site often have spotty mobile reception and want instant, shareable calculations without creating an account.
While engineering CalculMatériaux, a free French construction material estimator aligned with 2026 NF and DTU standards, we chose a 100% client-side, zero-backend architecture built on Astro. Here is a breakdown of the key technical patterns we used.
1. Encoding Construction Norms as Deterministic Formulas
French construction relies on strict regulatory baselines (Normes Françaises and Documents Techniques Unifiés):
- Concrete dosage (NF EN 206/CN & DTU 13.3): Standard structural concrete typically targets 350 kg/m³ of cement. Instead of returning abstract cubic meters alone, the concrete volume and dosage calculator converts volume ($V = L \times W \times H \times (1 + \text{waste})$) directly into commercial bag counts (25 kg or 35 kg cement bags), sand, and gravel weights.
- Masonry blocks (NF DTU 20.1): Standard French parpaings measure 20 × 20 × 50 cm, yielding a baseline of 10 blocks per m² plus mortar joint allowances.
- Roof pitch conversion (NF DTU 40.35): Translating between percentage slope ($p = 100 \cdot \tan\theta$) and degrees dynamically for roofing sheets and tiles.
Keeping all coefficients in pure TypeScript modules makes unit testing straightforward and eliminates API latency.
2. Dynamic Dimensioned SVG Blueprints
A common UX pitfall in calculators is showing a wall of numbers without spatial feedback. Instead of loading heavy WebGL libraries, we generate parametric SVG blueprints directly from the reactive input state:
// Example: computing scaled SVG coordinates for a concrete slab const pad = 24; const scale = Math.min((viewW - pad * 2) / lengthM, (viewH - pad * 2) / widthM); const rectW = Math.round(lengthM * scale); const rectH = Math.round(widthM * scale); Whenever a user adjusts slab thickness or length, the SVG dimension lines (<line>, <marker>, and <text>) update in under 1 ms with crisp vector rendering on both desktop and mobile screens.
3. URL-Driven State & Local Canvas PNG Export
To let users save or share a bill of materials (bordereau) before heading to a supplier without storing anything on a server:
- URL State Synchronization: Every dimension and material choice is serialized into query parameters via
history.replaceState. Copying the URL preserves the exact job-site configuration. - Client-Side PNG Quote Export: Using the HTML5
<canvas>2D context, we render a structured 1080×1350 px vertical summary sheet directly in the browser and trigger a local download—zero server-side Puppeteer or PDF microservice required.
Conclusion
Combining static HTML delivery via Astro with deterministic TypeScript calculation modules, parametric SVGs, and URL-persisted state results in a sub-second tool that works reliably even on weak mobile connections. You can explore the live implementation at CalculMatériaux.