{"id":43387756,"url":"https://github.com/andymai/brepjs","last_synced_at":"2026-07-05T01:02:15.112Z","repository":{"id":336011574,"uuid":"1147545446","full_name":"andymai/brepjs","owner":"andymai","description":"Web CAD library with exact B-Rep geometry","archived":false,"fork":false,"pushed_at":"2026-06-23T08:20:29.000Z","size":55021,"stargazers_count":51,"open_issues_count":2,"forks_count":4,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-06-23T08:26:38.813Z","etag":null,"topics":["3d-printing","bim","boundary-representation","brep","cad","csg","dxf","geometry-kernel","gltf","ifc","nurbs","opencascade","parametric-modeling","sheet-metal","solid-modeling","step","stl","typescript","wasm"],"latest_commit_sha":null,"homepage":"https://brepjs.dev","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/andymai.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"github":"andymai"}},"created_at":"2026-02-01T22:47:42.000Z","updated_at":"2026-06-23T08:19:21.000Z","dependencies_parsed_at":"2026-05-09T05:02:11.594Z","dependency_job_id":null,"html_url":"https://github.com/andymai/brepjs","commit_stats":null,"previous_names":["andymai/brepjs"],"tags_count":495,"template":false,"template_full_name":null,"purl":"pkg:github/andymai/brepjs","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andymai%2Fbrepjs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andymai%2Fbrepjs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andymai%2Fbrepjs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andymai%2Fbrepjs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/andymai","download_url":"https://codeload.github.com/andymai/brepjs/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andymai%2Fbrepjs/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34831250,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-26T02:00:06.560Z","response_time":106,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["3d-printing","bim","boundary-representation","brep","cad","csg","dxf","geometry-kernel","gltf","ifc","nurbs","opencascade","parametric-modeling","sheet-metal","solid-modeling","step","stl","typescript","wasm"],"created_at":"2026-02-02T11:57:06.319Z","updated_at":"2026-06-26T20:00:34.862Z","avatar_url":"https://github.com/andymai.png","language":"TypeScript","funding_links":["https://github.com/sponsors/andymai"],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n\n# brepjs\n\nCAD modeling for JavaScript.\n\n[![npm](https://img.shields.io/npm/v/brepjs)](https://www.npmjs.com/package/brepjs)\n[![CI](https://github.com/andymai/brepjs/actions/workflows/ci.yml/badge.svg)](https://github.com/andymai/brepjs/actions/workflows/ci.yml)\n[![Last release](https://img.shields.io/github/release-date/andymai/brepjs?label=last%20release)](https://github.com/andymai/brepjs/releases)\n[![Commit activity](https://img.shields.io/github/commit-activity/m/andymai/brepjs?label=commits%2Fmonth)](https://github.com/andymai/brepjs/commits/main)\n[![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](./LICENSE)\n\n**[▶ Try the live playground](https://brepjs.dev/playground)**: write code, watch the solid render, and export STEP, all in your browser.\n\n**[Getting Started](./docs/getting-started.md)** · **[Cheat Sheet](./docs/cheat-sheet.md)** · **[Docs](https://brepjs.dev/)**\n\n[![brepjs playground: write TypeScript on the left, see the exact solid render on the right](https://raw.githubusercontent.com/andymai/brepjs/main/media/demo.webp)](https://brepjs.dev/playground)\n\n\u003c/div\u003e\n\nShapes are exact mathematical boundaries (not triangle meshes), so booleans are precise, measurements are real, and you can export to STEP. TypeScript types prove the geometry is valid at compile time.\n\n```typescript\n// Drill a hole, fillet the vertical edges, export to STEP\nimport { box, cut, cylinder, fillet, edgeFinder, exportSTEP, unwrap } from 'brepjs/quick';\n\nconst b = box(30, 20, 10);\nconst hole = cylinder(5, 15, { at: [15, 10, -2] });\nconst drilled = unwrap(cut(b, hole));\n\nconst edges = edgeFinder().inDirection('Z').findAll(drilled);\nconst part = unwrap(fillet(drilled, edges, 1.5));\n\nconst step = unwrap(exportSTEP(part));\n```\n\n## Why?\n\nbrepjs grew out of the love and care I put into [gridfinitylayouttool.com](https://gridfinitylayouttool.com). I needed parametric CAD in the browser and I'm not a 3D modeler, but I know TypeScript. [OpenSCAD](https://openscad.org/) nailed code-first CAD but lives outside the JS ecosystem. [replicad](https://replicad.xyz/) proved OpenCascade works in JS but I kept hitting performance walls and fighting the API.\n\nNeither had the type safety I wanted, so brepjs leans hard on it: branded types, `Result\u003cT,E\u003e`, phantom types that prove invariants at compile time. If it compiles, the geometry is valid. It's strongest at exact, manufacturable geometry — precise booleans, fillets, chamfers and shells; real volumes, areas and clearances; watertight solids that round-trip through STEP — from a single part to a full assembly (enclosures, brackets, fixtures, gridfinity bins, machined and molded parts). It isn't built for organic sculpting or dense lattices; that's what field-based (implicit/voxel) modeling is for.\n\n## Scope\n\nTo set expectations, this project deliberately does not:\n\n- **Render or display geometry**: brepjs produces shape data; pass mesh output to Three.js, Babylon.js, or raw WebGL for rendering.\n- **Support organic or sculpting workflows**: brepjs models exact mechanical solids — parts and assemblies; freeform/organic sculpting and dense lattices are out of scope (that's field-based implicit/voxel territory).\n- **Output SVG or 2D files**: 2D drawing primitives exist solely as an intermediate step toward extruded 3D solids, not as a standalone 2D output format.\n- **Run server-side (SSR)**: WASM requires a browser or Node.js environment with WASM support; server-side rendering frameworks (Next.js, Nuxt, Remix) need a client-only import.\n- **Provide a GUI**: brepjs is a pure programmatic API; there is no visual editor, viewport, or file picker.\n\n## Status\n\n[occt-wasm](https://github.com/andymai/occt-wasm) (OpenCascade compiled to WebAssembly) is the default kernel. [brepkit](https://github.com/andymai/brepkit), a Rust-based kernel, is in active development as a faster replacement but not yet ready for production use. The kernel abstraction layer means switching is a one-line change. See [benchmarks](./benchmarks/results/latest.md) for performance comparisons.\n\n## Install\n\n```bash\nnpm install brepjs occt-wasm\n```\n\n`brepjs/quick` handles WASM init automatically via top-level await (ESM only). Other options:\n\n```typescript\n// Auto-detect kernel\nimport { init } from 'brepjs';\nawait init();\n\n// Or manual setup\nimport { OcctKernel } from 'occt-wasm';\nimport { registerKernel, OcctWasmAdapter } from 'brepjs';\nconst kernel = await OcctKernel.init();\nregisterKernel('occt-wasm', OcctWasmAdapter.fromKernel(kernel));\n```\n\n## Usage\n\nThe chapter-based guide is the recommended starting point:\n\n- **[Why brepjs](https://brepjs.dev/introduction/why-brepjs)**: what makes it different, who it's for\n- **[Install \u0026 Initialize](https://brepjs.dev/getting-started/install)**: three init styles, bundler notes\n- **[Your First Solid](https://brepjs.dev/getting-started/first-solid)**: the canonical drill-fillet-export workflow\n- **[Cheat Sheet](https://brepjs.dev/getting-started/cheat-sheet)**: single-page reference\n- **[Core Concepts](https://brepjs.dev/concepts/brep-vs-mesh)**: B-Rep, topology, types, kernels, tolerance\n- **[Common Tasks](https://brepjs.dev/tasks/booleans)**: booleans, fillets, sketching, lofts, sweeps, finders, measurement, IO\n- **[Three.js Integration](https://brepjs.dev/integration/threejs)**: meshing and rendering\n- **[Migration](https://brepjs.dev/migration/replicad)**: coming from Replicad, OpenSCAD, or Three.js\n- **[Extending brepjs](https://brepjs.dev/extending/architecture)**: custom kernels, custom operations, architecture\n- **[Reference](https://brepjs.dev/reference/glossary)**: glossary, function lookup, error codes, ADRs\n- **[API Reference (TypeDoc)](https://andymai.github.io/brepjs/)**: searchable type-level reference\n\nLegacy single-page docs in [./docs/](./docs/) remain available; the chapter site is the canonical location going forward.\n\n### Architecture\n\n```\nLayer 3  sketching/, text/, projection/   High-level API\nLayer 2  topology/, operations/, 2d/ ...  Domain logic\nLayer 1  core/                            Types, memory, errors\nLayer 0  kernel/, utils/                  WASM bindings\n```\n\nImports flow downward only. Boundaries are enforced in CI.\n\n## Authoring CAD with AI (brepjs-cad)\n\n[`brepjs-cad`](https://www.npmjs.com/package/brepjs-cad) helps an AI agent (or you) author CAD in brepjs and **prove it is correct** before handing it off. An LLM can't see geometry, so it writes a `.brep.ts` part, runs it on a real kernel, and reads a deterministic report instead of guessing from how the code reads. It ships as two cooperating pieces: a **Claude Code skill** (the authoring loop) and a **verification CLI** (validity + measured dimensions + multi-view snapshots + STEP export).\n\nInstall both; they ride on two rails:\n\n```bash\n# 1. The skill - Claude Code plugin (delivered via this repo's marketplace)\n#    In a Claude Code session:\n/plugin marketplace add andymai/brepjs\n/plugin install brepjs@brepjs\n#    …or from a terminal, non-interactively:\nclaude plugin marketplace add andymai/brepjs\nclaude plugin install brepjs@brepjs\n\n# 2. The runtime - the CLI the skill drives\nnpm i -D brepjs-cad\n```\n\nWith the skill installed, ask Claude for a part in plain English, or drive the pipeline explicitly with `/brepjs:cad \"a 40×20×10 mm bracket with two M4 holes\"`.\n\n`brepjs-cad` bundles its own `brepjs` + `occt-wasm`, so it runs in an empty directory; inside an existing brepjs project it prefers your installed versions so verified parts match what you ship. A model is a module that default-exports a zero-arg function returning a shape:\n\n```typescript\n// bracket.brep.ts\nimport { box } from 'brepjs';\nexport const expected = { volume: 8000, tolerancePct: 1 }; // optional: assert intent\nexport default () =\u003e box(40, 20, 10, { centered: true });\n```\n\n```bash\nnpx -y -p brepjs-cad brep bracket.brep.ts --check --step bracket.step --json report.json\n```\n\nThe command exits non-zero unless the report is `ok` (valid **and** every declared dimension within tolerance), so it drops straight into CI or an agent loop. For MCP-capable agents the package also ships a stdio MCP server (`brep-mcp`) exposing the same build-and-verify step as a `run_program` tool. See the [**Authoring with AI**](https://brepjs.dev/agent/overview) guide for the full loop, CLI reference, the MCP server, examples, and the measurement eval.\n\n## Projects Using brepjs\n\n- [Gridfinity Layout Tool](https://github.com/andymai/gridfinity-layout-tool): Web-based layout generator for Gridfinity storage systems\n\n## Get in touch\n\nI'm Andy Aragon — I build and maintain brepjs and the geometry kernels beneath it ([occt-wasm](https://github.com/andymai/occt-wasm), [brepkit](https://github.com/andymai/brepkit)). Building something on brepjs and want a hand, or just have a question? **[Get in touch →](https://brepjs.dev/support)**\n\n## Contributing\n\nSee [CONTRIBUTING.md](./CONTRIBUTING.md) for development setup and guidelines.\n\n## Acknowledgements\n\nbrepjs.dev and the playground are hosted on [Vercel](https://vercel.com) through its Open Source Program.\n\n\u003cdiv align=\"center\"\u003e\n  \u003ca href=\"https://vercel.com/open-source-program\"\u003e\n    \u003cimg alt=\"Vercel OSS Program\" src=\"https://vercel.com/oss/program-badge-2026.svg\" /\u003e\n  \u003c/a\u003e\n\u003c/div\u003e\n\n## License\n\n[Apache-2.0](./LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandymai%2Fbrepjs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fandymai%2Fbrepjs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandymai%2Fbrepjs/lists"}