Documentation
Packages and applications
Workspace names, public entry points, consumers, and implementation responsibilities.
Domain libraries
@cadcamfun/core
packages/core/src/index.ts exports CAD symbols both flat and under cad, CAM under cam, and drawing functions under drawing. It contains sketches, solid modelling, tessellation, drawing exchange, machining operations, post-processors, G-code analysis, and verification. The desktop consumes this package directly for interactive operations; the sidecar uses it behind HTTP and assistant adapters.
@cadcamfun/vcs
packages/vcs/src/index.ts exposes project snapshot, object, reference, diff, merge, and GitHub transport functions. It has no runtime package dependencies. Storage and acting-user resolution belong to the sidecar's VCS repository and services.
@cadcamfun/workflow
packages/workflow/src/index.ts exports workflow schemas, parsing, trigger matching, and execution. It depends on Effect. The sidecar registers steps requiring notifications, project history, or AI access; a workflow step name is usable only when its implementation is registered in the runner.
Contracts, storage, and AI
@cadcamfun/api
The root entry packages/api/src/index.ts composes HttpApi groups and shared schemas. The @cadcamfun/api/sdk export points to the generated Promise SDK. The source tree also contains Effect clients and the full contract-based ApiClient. API consumers should select the client surface that represents the endpoint they need.
@cadcamfun/db
The root export provides the Effect Database service and a schema namespace. @cadcamfun/db/schema exposes the Drizzle tables. SQLite access, migrations, backup planning, and schema ownership live here. Most application queries run from sidecar repositories through the service; the local web Studio imports table schemas for its independent Bun process.
@cadcamfun/ai
packages/ai/src/index.ts exposes provider services, the embedded nikcli integration, action catalogue, application tools, prompts, and skills. The sidecar supplies live project, geometry, machining, file, history, and workflow adapters. The package depends on API and core, with pinned nikcli and AI SDK versions.
Extension packages
@cadcamfun/plugin-sdk
The SDK's src/index.ts is the public application plugin entry point. It defines manifest and capability contracts and plugin authoring helpers. The runtime host lives in apps/sidecar/src/plugins; the SDK itself is not the host process.
@cadcamfunv2/cadcamfun-nikcli-plugin
packages/nikcli-plugin/src/index.ts exports the standalone nikcli bridge. Unlike most workspaces, it is configured for public npm publication, currently at version 0.1.0. It discovers actions from a running CADCAMFUN application and invokes them over authenticated HTTP. It does not embed the CAD kernel or an independent action catalogue.
@cadcamfun/plugin-sdk implements plugin API major version 1. Plugin identifiers are reverse-DNS names of 3–128 characters, such as com.example.gear-generator, and versions follow major.minor.patch with an optional pre-release suffix (packages/plugin-sdk/src/manifest.ts).
HTTP client generator
@cadcamfun/httpapi-codegen exports its compiler and emitters from packages/httpapi-codegen/src/index.ts. compile reflects an Effect HttpApi into a contract model. emitPromise creates the Promise SDK; emitEffect and emitEffectImported support Effect output. The imported variant references existing contract schemas.
Other exports include compatibility emitters, transport error mapping, write, and generate. Unsupported contract shapes raise GenerationError. The application generation script records endpoint exclusions explicitly for shared and Promise-only limitations.
packages/api/scripts/generate-clients.ts writes src/sdk/generated and src/client/generated. Its drift check generates into a temporary directory and compares file names and contents with committed output.
bun run generate
bun run generate:check The generated output lives in packages/api/src/client/generated and packages/api/src/sdk/generated. Run bun run generate after changing a contract, and bun run generate:check to confirm the committed output is current.
Application workspaces
@cadcamfun/sidecar—apps/sidecarsrc/main.tsis the executable server entry;src/layers.tswires services and served groups. The package start script runs Bun directly. Compilation into a native sidecar is managed by root build scripts.@cadcamfun/desktop—apps/desktop- SolidJS/Vite frontend plus the Tauri Rust application in
src-tauri. The package'sbuildscript builds the frontend; native packaging requires Tauri and the sidecar resources. @cadcamfun/mobile—apps/mobile- Expo Router entry point, companion HTTP/native transport, secure pairing state, and mobile UI. Its build script exports the iOS JavaScript bundle; producing a native application requires the native build commands.
Documentation, assistant, and Studio
@cadcamfun/web contains Astro pages, shared documentation components, and the site content index. The sidebar is declared in src/data/docsSidebar.ts; src/data/docsIndex.ts holds retrieval summaries and keywords for the same routes. Each documentation page prerenders its article.
GET /llm lists documentation pages as Markdown links. GET /llm?path=/docs/cam returns the corresponding rendered article as GitHub-flavored Markdown. Add format=prompt for a documentation prompt. Unknown paths return 404; conversion failures return an error status. The Markdown pipeline strips navigation, scripts, styles, and controls.
POST /api/docs-assistant retrieves up to three indexed pages and streams an answer through Workers AI or a configured nikcli backend. Local Astro development disables remote bindings, so a model backend must be available for generation. The optional SESSIONS KV binding enables best-effort per-IP rate limiting; optional ARTIFACTS storage enables shareable generated guides.
bun run --filter @cadcamfun/web dev starts both Astro and the Studio API. start runs Astro alone; studio starts only the Bun Studio API. Studio selects CADCAMFUN_DB, then DATABASE_URL with an optional file: prefix removed, then the repository's data/cadcamfun.db. The file must already exist and contain the application schema.
Studio accepts an existing user's email and password, verifies the stored password with Bun.password, and writes a seven-day database session with an HTTP-only cookie. Its overview returns installation-wide counts and recent projects to authenticated users. The production /studio/api/* route returns 503; deployed documentation does not open a local SQLite database.
bun run --filter @cadcamfun/web start
bun test packages/web/test
bun run --filter @cadcamfun/web typecheck
bun run --filter @cadcamfun/web build Select an integration surface
| Need | Surface | What the caller provides |
|---|---|---|
| Compute geometry without persistence | @cadcamfun/core | Validated geometry and operation inputs; ownership and document saving remain outside the kernel. |
| Call the complete typed HTTP contract | ApiClient from @cadcamfun/api | Sidecar base URL, application token, and Effect runtime/layers. |
| Use Promise-based generated methods | @cadcamfun/api/sdk | SDK client options and endpoint inputs; check generation omissions first. |
| Offer an application capability | @cadcamfun/plugin-sdk | A supported manifest, compatible module exports, and granted capabilities. |
| Drive project actions from standalone nikcli | @cadcamfunv2/cadcamfun-nikcli-plugin | The running app URL, scoped bridge token, and selected project. |
| Read documentation in a tool | /llm?path=/docs/… | A known documentation route; this does not invoke CAD/CAM project actions. |
Most library packages are private workspaces exporting TypeScript source; their presence in the monorepo does not imply a separately published npm distribution. The nikcli bridge has explicit publication metadata. Use the HTTP reference for integrations that should remain independent of internal package layout.
Workspace at a glance
| Workspace | Package | Internal deps | Source files | Lines | Test files | Contents |
|---|---|---|---|---|---|---|
packages/core | @cadcamfun/core | — | 307 | 70,774 | 106 | Geometry kernel: cad/ (80 files), cam/ (110), drawing/ (7) |
packages/ai | @cadcamfun/ai | api, core | 196 | 22,579 | 83 | Assistant: actions, embedded host, prompts, skills, tools |
packages/api | @cadcamfun/api | core, httpapi-codegen | 64 | 18,388 | 9 | HttpApi contract, errors, Effect and Promise clients |
packages/db | @cadcamfun/db | — | 7 | 1,730 | 2 | SQLite + Drizzle, migrations, backups |
packages/vcs | @cadcamfun/vcs | — | 10 | 1,133 | 1 | Content-addressed project history and merge |
packages/workflow | @cadcamfun/workflow | — | 5 | 320 | 1 | Workflow file schema and run semantics |
packages/plugin-sdk | @cadcamfun/plugin-sdk | core | 9 | 952 | 2 | Plugin manifest, capabilities, test host |
packages/httpapi-codegen | @cadcamfun/httpapi-codegen | — | 13 | 4,330 | 2 | Client generator for HttpApi contracts |
packages/nikcli-plugin | @cadcamfunv2/cadcamfun-nikcli-plugin | — | 5 | 359 | 2 | Plugin that exposes CADCAMFUN to the nikcli agent |
packages/web | @cadcamfun/web | db | 84 | 12,991 | 3 | This documentation site, Studio, docs assistant |
apps/sidecar | @cadcamfun/sidecar | ai, api, core, db, plugin-sdk, vcs, workflow | 172 | 20,797 | 73 | Local HTTP server: http/ (34), repos/ (24), services/ (29) |
apps/desktop | @cadcamfun/desktop | api, core | 557 | 85,579 | 104 | SolidJS webview (features/ 280 files) + Rust shell in src-tauri/ |
apps/mobile | @cadcamfun/mobile | api | 79 | 7,637 | 7 | Expo iOS companion |
Counts are TypeScript, TSX, Rust and Astro files tracked in git, measured on this branch; test files are *.test.ts(x). Internal dependencies omit the @cadcamfun/ prefix.
Dependency graph
Arrows point from a workspace to what it imports. core has no internal dependencies, so geometry and CAM can be tested and reused without a server. Only the sidecar touches the database; the desktop and mobile apps reach data through api. plugin-sdk also depends on core (not drawn).
Scripts per workspace
| Workspace | Scripts |
|---|---|
| root | typecheck, test, build, build:sidecar, build:desktop, desktop:dev, generate, generate:check, db:generate, db:migrate |
packages/api | typecheck, coverage, generate, generate:check |
packages/db | typecheck, generate, migrate |
packages/web | dev, start, studio, build, preview, deploy, astro, check:freshness, check:docs-index, typecheck, generate:api-reference, check:api-reference |
apps/desktop | typecheck, dev, build, stub-sidecar, tauri, tauri:dev, tauri:build |
apps/mobile | start, ios, dev, ios:build, ios:release, ios:dev, web, native:generate, typecheck, build, test |
apps/sidecar | typecheck, start |
| other packages | typecheck |
The root typecheck runs every workspace's typecheck through turbo and then checks the root project. The root test runs bun test packages apps scripts.