A modular CAD system for parametric, programmable, and AI-assisted design
opencad_kernel— geometry kernel and typed operation registryopencad_solver— 2D sketch constraint solving (SolveSpace + Python fallback)opencad_tree— parametric feature-tree DAG (CRUD + rebuild + stale propagation)opencad_agent— AI agent that plans and executes operationsopencad_viewport— React + Three.js viewport UI (mock mode by default)
opencad_kernel/ # 1 – Geometry Kernel
opencad_solver/ # 2 – Constraint Solver
opencad_tree/ # 3 – Feature Tree
opencad_viewport/ # 4 – 3D Viewport (frontend)
opencad_agent/ # 5 – AI Chat Agent
scripts/ # Backend smoke tests
Prereqs: Python 3.11+ and Node.js 18+
For a packaged install (for example from a wheel or a PyPI release), use:
uv pip install opencadFor local development from this repository:
uv sync --extra test --extra server
cp .env.example .envInstall optional integrations as needed, for example:
uv sync --extra occt
uv sync --extra llm
uv sync --extra fullEach service runs on its own port:
cd backend
uv run --no-sync python -m uvicorn api:app --reload --port 8000To start the backend and frontend together from the repository root:
cd opencad_viewport
pnpm install
cd ..
./scripts/run_dev.shThis starts:
- backend:
http://127.0.0.1:8000 - frontend:
http://127.0.0.1:5173
Press Ctrl+C to stop both services.
Optional environment overrides:
BACKEND_HOST=0.0.0.0 BACKEND_PORT=8000 FRONTEND_HOST=0.0.0.0 FRONTEND_PORT=5173 ./scripts/run_dev.shcurl -s http://127.0.0.1:8000/kernel/healthz # → {"status":"ok"}
curl -s http://127.0.0.1:8000/agent/healthz
curl -s http://127.0.0.1:8000/solver/healthz
curl -s http://127.0.0.1:8000/tree/healthzcd opencad_viewport
pnpm install
pnpm dev # → http://localhost:5173The viewport uses mock geometry/solver data by default (no backend required for those flows).
Chat targets the live agent service by default; set VITE_USE_CHAT_MOCK=true if you explicitly want mocked chat output.
Set VITE_USE_MOCK=false to connect the rest of the viewport to the live services above.
Build the backend image from the repository root so Docker can see the Python project metadata and backend package files:
docker build -f backend/Dockerfile -t opencad-backend .Build the frontend image from the viewport directory:
docker build -f opencad_viewport/Dockerfile -t opencad-frontend opencad_viewportRun the backend API on port 8000:
docker run --rm -p 8000:8000 opencad-backendRun the frontend on port 5173:
docker run --rm -p 5173:80 opencad-frontendBy default, the frontend image is built with VITE_BASE_URL=http://localhost:8000
and live API calls enabled. To point the frontend at another API URL or enable
mock mode, pass build args:
docker build \
-f opencad_viewport/Dockerfile \
-t opencad-frontend \
--build-arg VITE_BASE_URL=http://localhost:8000 \
--build-arg VITE_USE_MOCK=false \
--build-arg VITE_USE_CHAT_MOCK=false \
opencad_viewportRuntime defaults are documented in .env.example.
OPENCAD_ENABLE_DOCS=true|falsetoggles OpenAPI/docs route exposure.OPENCAD_CORS_ALLOW_ORIGINSsets a comma-separated browser origin allowlist.OPENCAD_KERNEL_BACKEND=analytic|occtselects the kernel backend.OPENCAD_SOLVER_BACKEND=auto|solvespace|pythonselects the solver backend.
For production, disable docs and set a strict CORS origin list.
Use TLS + authentication at your reverse proxy/API gateway.
Do not commit .env files, tokens, or private datasets.
See SECURITY.md for coordinated vulnerability reporting.
uv run --no-sync python -m pytestOpenCAD now includes a first-class in-process API for scripting workflows with automatic feature-tree logging.
from opencad import Part, Sketch
part = Part()
sketch = Sketch().rect(10, 20).circle(3, subtract=True)
part.extrude(sketch, depth=5).fillet(edges="top", radius=0.5)
part.export("output.step")Every fluent call appends a built FeatureNode to the in-memory DAG, so headless runs are recoverable.
Fluent sketches also persist entities + profile_order metadata in the sketch node, matching agent-path ordering semantics for deterministic profile reconstruction.
OpenCAD can export a versioned JSON artifact for SimCorrect. The artifact carries the feature tree, named parameters, and simulation tags; SimCorrect returns structured parameter patches against those names.
from opencad import Part, Sketch
part = Part(name="forearm").extrude(Sketch().rect(30, 4), depth=4)
part.export_design_artifact(
"caid-design.json",
artifact_id="forearm-demo",
parameters={"forearm_length": {"value": 0.30, "unit": "m", "role": "geometry"}},
simulation_tags=[
{"name": "right_forearm", "kind": "body", "target": "r_forearm"},
{"name": "forearm_length", "kind": "parameter", "target": "link2_length"},
],
)opencad build model.json --output model.built.json
opencad run model.py --export output.step --tree-output output-tree.jsonThe examples/ directory contains end-to-end scripts for common
device-development workflows:
hardware_mounting_bracket.py— bracket with fastener and cable pass-through holeshardware_pcb_carrier.py— PCB carrier plate with mounting holes and clearance slotsoftware_hmi_panel.py— front panel for an operator interface with button and encoder cutoutsfirmware_programmer_fixture.py— pogo-pin fixture plate for programming/debug accessfull_device_cable_grommet.py— concentric cable grommet built from primitive booleansexamples/agents/generate_mounting_bracket_code.py— agent code-generation usage example
Run an example from the repository root with:
python -m opencad.cli run examples/hardware_mounting_bracket.py \
--export bracket.step \
--tree-output bracket-tree.jsonThe agent service can also generate example-style Python scripts for different LLM providers
through LiteLLM by posting llm_provider, llm_model, and generate_code=true to /chat.
When generate_code is enabled, the response includes generated_code and leaves the feature
tree unchanged.
For a runnable script example, see examples/agents/README.md.
-
CHANGELOG.md - release notes
-
CONTRIBUTING.md - development and contract workflow
-
docs/CAID_ARTIFACT_CONTRACT.md - artifact and patch semantics
-
docs/RECONSTRUCTION_AND_UPGRADE_PLAN.md - local reconstruction status and CAID upgrade plan
-
PRODUCTION.md — deployment, routes, and verification
-
ARCHITECTURE.md — component design and API contracts
-
TOPOLOGY.md — topology reference stability (open research question)
-
SECURITY.md — vulnerability reporting and hardening baseline