DEV Community

A browser CAD or floor-plan tool still ships its geometry kernel and snapping rules

Browser-based CAD and floor-plan editors have become seriously good. You can draw walls, drop in doors, get automatic room areas, and export a dimensioned plan without installing anything.

Behind that smooth experience is usually years of work on a geometry kernel: polygon offsetting, wall-join resolution, snapping heuristics, area rules, and the little tolerances that make a drawing "feel right". If that kernel runs in the browser, every visitor downloads it.

This post looks at what exactly ships, how competitors actually lift it, and what you can realistically do about it.

What a floor-plan editor really sends to the client

Open the network tab on almost any web floor-plan tool and you will find one or two large bundles. Inside them, beyond the React or canvas UI, there is typically:

  • Wall-join logic - how two or three walls meet at a corner, mitre vs. butt joins, and the special cases for T-junctions.
  • Snapping rules - grid snap, angle snap (15°, 45°, 90°), snap-to-midpoint, snap priorities and the pixel tolerances that decide which one wins.
  • Area and perimeter calculation - including regional rules like whether wall thickness counts, how balconies or stairwells are treated, and rounding.
  • Opening placement constraints - minimum distance of a door from a corner, window sill heights, clearance checks.
  • Export pipelines - DXF/SVG/PDF generation, layer naming conventions, and the scale handling that customers pay for.

None of that is "secret" in the cryptographic sense, but it is the difference between a weekend demo and a product people pay for.

How it gets copied

Nobody reverse-engineers a geometry kernel from scratch. They do something much simpler:

  • Pretty-print the bundle in DevTools.
  • Search for telltale constants (0.001, Math.PI / 12, EPSILON) or strings like "mitre" and "snapAngle".
  • Set a breakpoint inside the wall-drawing handler and step out until they find the pure functions.
  • Copy those functions into their own project, rename a few things, and ship.

Here is the kind of function that gets lifted almost verbatim:

// Resolve which snap target wins for the cursor position
export function resolveSnap(cursor, targets, opts = { px: 8, angleStep: Math.PI / 12 }) {
  let best = null;
  for (const t of targets) {
    const d = Math.hypot(cursor.x - t.x, cursor.y - t.y);
    const weight = t.kind === 'endpoint' ? 0.6 : t.kind === 'midpoint' ? 0.8 : 1;
    const score = d * weight;
    if (d <= opts.px && (!best || score < best.score)) best = { ...t, score };
  }
  return best ?? snapToAngle(cursor, opts.angleStep);
}

The weights and tolerances in that snippet are the result of user testing. Reading them takes thirty seconds.

What actually protects you

Be honest with yourself about the threat. You are not stopping a determined reverse engineer who has a week. You are trying to make "copy the kernel" more expensive than "build your own", and to keep the parts that really matter off the client entirely.

Move what you can to the server

  • Export is the most commonly monetized feature and the easiest to move. Generate DXF/PDF on the server from the plan JSON, and check the user's plan there.
  • Batch area reports, cost estimates and compliance checks rarely need to be interactive at 60 fps. Run them server-side.
  • Licence and seat checks must be enforced on the API, never only in the UI.

Keep the interactive kernel, but make it expensive to lift

Snapping and wall joins must run locally or the editor feels laggy. For that code:

  • Bundle the kernel separately so you can treat it differently from UI code.
  • Apply real obfuscation to that chunk only. Name-mangling from Terser is not enough; control-flow flattening helps, and VM-based protection (which compiles your functions into custom bytecode run by an embedded interpreter) helps more, because the copied code no longer looks like readable geometry.
  • Measure performance. Geometry runs in tight loops; protect the decision logic and leave the hottest numeric inner loops lighter if needed.
  • Keep source maps off the public CDN.

Make copying detectable

Add a few harmless, distinctive constants or behaviors to the kernel so that if a competitor ships a suspiciously identical snapping engine, you can show it.

Practical checklist

  • [ ] Export, compliance reports and seat checks run on the server, not only in the UI.
  • [ ] The interactive geometry kernel is bundled separately from the rest of the app.
  • [ ] That kernel chunk is protected with stronger-than-mangling obfuscation (control-flow / VM).
  • [ ] Hot numeric loops are measured after protection; dial back if FPS drops.
  • [ ] Source maps for the kernel are not on the public CDN.
  • [ ] A few distinctive, harmless markers exist so you can recognize a lifted copy.
  • [ ] Paid plan and feature gates are enforced by the API, not by hiding a menu item.

Honest limits

Obfuscation raises the cost of copying; it does not make a secret safe. Treat the client as a convenience layer and the server as the control plane.

Summary

A browser CAD tool ships its most expensive R&D to every visitor. Move exports and compliance off the client, protect the interactive kernel that must stay local, and never pretend that hiding a function is the same as enforcing a business rule.

Disclosure: I work on VEILVM, a JavaScript VM-protection service. Free browser tier (3 runs/day, up to 5 KB) and a Pro plan at $9/month or $79/year with API access. Try the playground at vm.ldvmp.com.

Read on DEV Community ↗ ← Back to News

Comments

No comments yet. Start the discussion.