CADPilot
Turn a plain-language design brief into a validated, editable, exportable CAD model — no CAD software required.
Inspiration
Parametric CAD tools like SolidWorks, Fusion 360, and OpenSCAD are powerful but locked behind a steep learning curve: sketch planes, feature trees, constraint solvers, and boilerplate scripting stand between an idea and a usable 3D model. At the same time, most "AI CAD" demos stop at a pretty mesh — a shape you can look at but can't trust, edit, or manufacture from.
We wanted something different: an agent that treats CAD generation like real engineering work. Not "generate a mesh that looks like a bracket," but "produce a parametric, dimensioned, boundary-representation (BREP) solid that is validated the same way a CAD kernel validates it, with a full audit trail of how it got there." That gap — between AI that can talk about geometry and AI that can actually build it correctly — is what CADPilot set out to close.
What it does
CADPilot lets a user describe an object in natural language inside a private project workspace and get back a real, solid CAD model:
- Prompt to parametric part. A chat interface takes a design brief ("a 40mm hex standoff with an M3 through-hole") and drives a multi-stage agent pipeline that produces actual OpenCascade BREP geometry, not a disposable mesh.
- Full engineering record, every time. Each revision keeps its structured intent (object, units, dimensions, constraints, materials), its parametric plan, the generated Replicad source code, a deterministic validation report (volume, surface area, bounds, part count, mesh size), a preview mesh, and STEP/STL exports — plus the conversation that explains what changed and why.
- Live agent activity feed. The workspace streams server-sent events showing which agent is running, what tool it invoked, and the validation findings, using a shadcn/Magic UI "Marker" activity feed — without exposing hidden chain-of-thought.
- Safe rendered engineering chat. Agent responses render GitHub-flavored Markdown tables, KaTeX math, and Mermaid diagrams — raw HTML is never rendered, and Mermaid runs in strict security mode.
- A shared PBR Three.js viewer for inspecting validated geometry directly in the browser.
- Publishing and profiles. A validated revision can be published to a stable public project URL and shown on its creator's public profile, so parts can be shared, not just generated.
- A full CAD editor, not just a viewer. We integrated Chili3D (ChiliCAD) as a bidirectional STEP-based editor, so a generated model can be opened, edited by hand, and round-tripped back through the pipeline.
How we built it
CADPilot is a Next.js 15 / React 19 app backed by PostgreSQL via Prisma, with a strict separation between the web tier and the CAD execution tier:
- Agent pipeline. An intent agent (built on the Gemini API) converts a free-text request into constrained JSON — object, millimetre-unit dimensions, constraints, materials, and the requested edit. A parametric planner selects editable features and their dependency order. A Replicad generator writes JavaScript against a locally verified Replicad API reference (auto-generated by
scripts/gen-replicad-api.mjsso the model never hallucinates an API surface). A compiler executes that code inside a dedicated, sandboxed Node CAD worker (scripts/cad-agent-worker.mjs), builds the BREP withreplicad/replicad-opencascadejs, and produces preview, STEP, and STL artifacts. A BREP evaluator measures the resulting solid and writes a deterministic validation report. A repair agent gets only compiler diagnostics (never the original prompt again) and has at most two retries before failing loudly. - Second-pass fidelity refinement. After the first valid build, a second automated pass can refine the model for closer fidelity to the brief, without a human back-and-forth.
- Isolated execution. The CAD worker deploys separately from the web server, claims queued jobs, calls the model, and writes artifacts to a shared volume (local disk in dev via
CAD_ARTIFACT_DIR, S3-compatible storage in production). Generated source is length-limited and blocked from imports, process access, networking, timers, dynamic evaluation, and WebAssembly — the production worker is meant to run with no network egress, no app secrets, and hard CPU/memory/time quotas. - Data model. Prisma/PostgreSQL (Supabase in production) stores users, profiles, projects, revisions, build jobs and events, conversations, messages, and artifact metadata, so every generation is durably linked to the project that produced it.
- UI system. The workspace UI is built entirely from Magic UI and shadcn primitives kept in
components/magicui(no bespokecomponents/uilibrary), composed rather than restyled, with a consistent indigo/cyan/violet palette and reduced-motion support. - Bidirectional CAD editing. The Chili3D (ChiliCAD) integration lets a validated revision open in a full-featured editor and hands STEP files back through the same pipeline, closing the loop between "AI-generated" and "human-refined."
Challenges we ran into
- Getting an LLM to write correct, compilable CAD code. Replicad's API surface is large and easy to hallucinate against. We solved this by generating a verified, minimal API reference straight from the library itself and feeding that to the model instead of relying on its training data.
- Trusting the output. A mesh that merely looks right isn't good enough for anything downstream (manufacturing, further editing, export). We had to build a real validation stage — volume, surface area, bounds, part count, mesh size — and gate export/publish behind it succeeding.
- Running untrusted, model-generated code safely. Executing LLM-written JavaScript against a real geometry kernel meant building a genuinely sandboxed worker: no imports, no process/network access, no timers, no dynamic eval, no WebAssembly, plus a hard retry budget for self-repair.
- Keeping the agent's failure loop tight. Letting the repair agent see the full original prompt on every retry caused drift and repeated the same mistakes; scoping it to compiler diagnostics only, with a two-retry cap, made recovery both faster and more predictable.
- Bidirectional STEP round-tripping. Integrating Chili3D so that AI-generated and human-edited geometry could move back and forth through the same project without losing the parametric/validation record required careful handoff design between two very different CAD representations.
- Keeping the UI disciplined. With Magic UI/shadcn components as the only UI layer, resisting the urge to fork-and-restyle components (instead of composing them) took real discipline as the workspace grew more complex.
Accomplishments that we're proud of
- A working end-to-end pipeline that turns a sentence into a validated, parametric OpenCascade BREP — not a mesh — with STEP/STL export.
- A genuine engineering audit trail: intent, plan, source, validation report, mesh, and exports are all preserved per revision, not thrown away after rendering.
- A safe execution model for running AI-generated geometry code, with real sandboxing constraints instead of "trust the model."
- A self-repair loop that lets the agent recover from its own compiler errors without human intervention, within a bounded retry budget.
- Full bidirectional interoperability with a real CAD editor (Chili3D), so generated parts aren't a dead end — they're a starting point.
- A cohesive, accessible UI built entirely from composed, reusable primitives rather than one-off styled components.
What we learned
- Treating geometry generation as a validated engineering pipeline rather than a single prompt-to-mesh call produces dramatically more reliable, trustworthy results.
- Constraining an LLM to a verified, generated API surface (instead of hoping it remembers the real one) is one of the highest-leverage things you can do for code-generating agents.
- Sandboxing matters as much for AI-generated CAD code as it does for AI-generated shell commands — geometry kernels are still just code execution.
- Narrow, diagnostic-only context for repair loops beats re-sending the full prompt: less drift, faster convergence.
- Separating the web tier from the CAD execution tier early made it far easier to reason about security, scaling, and deployment independently.
What's next for CADPilot
- Richer parametric editing directly in the workspace (drag a dimension, regenerate downstream features) instead of only prompt-driven or Chili3D-based edits.
- Assembly support — multiple linked parts and mates, not just single solids.
- Manufacturability checks (wall thickness, draft angles, tolerancing) as an additional validation stage before export.
- Deeper Chili3D integration so manual edits can feed back into the parametric plan, not just the final geometry.
- Expanded material and constraint libraries for the intent agent, and support for imperial units alongside millimetres.
- Team workspaces and shared libraries of published, reusable parts.
Built With
- claude
- gemini
- javascript
- next.js
- supabase
- typescript
Log in or sign up for Devpost to join the conversation.