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:
pip install opencadFor local development from this repository:
python -m venv .venv
source .venv/bin/activate
pip install -U pip
pip install -e ".[test]"
cp .env.example .envInstall optional integrations as needed, for example:
pip install -e ".[full]"
pip install -e ".[llm]"Each service runs on its own port:
python -m uvicorn opencad_kernel.api:app --reload --port 8000 # 1 – Kernel
python -m uvicorn opencad_solver.api:app --reload --port 8001 # 2 – Solver
python -m uvicorn opencad_tree.api:app --reload --port 8002 # 3 – Tree
python -m uvicorn opencad_agent.api:app --reload --port 8003 # 5 – Agentcurl -s http://127.0.0.1:8000/healthz # → {"status":"ok"}
curl -s http://127.0.0.1:8001/healthz
curl -s http://127.0.0.1:8002/healthz
curl -s http://127.0.0.1:8003/healthzcd opencad_viewport
npm install
npm run 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.
Runtime 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.
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 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.
- 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