Skip to content
CADCAMFUN
Docs

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.

Repository root
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/sidecar
src/main.ts is the executable server entry; src/layers.ts wires 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's build script 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.

Repository root
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

NeedSurfaceWhat the caller provides
Compute geometry without persistence@cadcamfun/coreValidated geometry and operation inputs; ownership and document saving remain outside the kernel.
Call the complete typed HTTP contractApiClient from @cadcamfun/apiSidecar base URL, application token, and Effect runtime/layers.
Use Promise-based generated methods@cadcamfun/api/sdkSDK client options and endpoint inputs; check generation omissions first.
Offer an application capability@cadcamfun/plugin-sdkA supported manifest, compatible module exports, and granted capabilities.
Drive project actions from standalone nikcli@cadcamfunv2/cadcamfun-nikcli-pluginThe 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

WorkspacePackageInternal depsSource filesLinesTest filesContents
packages/core@cadcamfun/core—30770,774106Geometry kernel: cad/ (80 files), cam/ (110), drawing/ (7)
packages/ai@cadcamfun/aiapi, core19622,57983Assistant: actions, embedded host, prompts, skills, tools
packages/api@cadcamfun/apicore, httpapi-codegen6418,3889HttpApi contract, errors, Effect and Promise clients
packages/db@cadcamfun/db—71,7302SQLite + Drizzle, migrations, backups
packages/vcs@cadcamfun/vcs—101,1331Content-addressed project history and merge
packages/workflow@cadcamfun/workflow—53201Workflow file schema and run semantics
packages/plugin-sdk@cadcamfun/plugin-sdkcore99522Plugin manifest, capabilities, test host
packages/httpapi-codegen@cadcamfun/httpapi-codegen—134,3302Client generator for HttpApi contracts
packages/nikcli-plugin@cadcamfunv2/cadcamfun-nikcli-plugin—53592Plugin that exposes CADCAMFUN to the nikcli agent
packages/web@cadcamfun/webdb8412,9913This documentation site, Studio, docs assistant
apps/sidecar@cadcamfun/sidecarai, api, core, db, plugin-sdk, vcs, workflow17220,79773Local HTTP server: http/ (34), repos/ (24), services/ (29)
apps/desktop@cadcamfun/desktopapi, core55785,579104SolidJS webview (features/ 280 files) + Rust shell in src-tauri/
apps/mobile@cadcamfun/mobileapi797,6377Expo 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

desktopsidecarmobile dbapiaivcsworkflowplugin-sdk corehttpapi-codegen

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

WorkspaceScripts
roottypecheck, test, build, build:sidecar, build:desktop, desktop:dev, generate, generate:check, db:generate, db:migrate
packages/apitypecheck, coverage, generate, generate:check
packages/dbtypecheck, generate, migrate
packages/webdev, start, studio, build, preview, deploy, astro, check:freshness, check:docs-index, typecheck, generate:api-reference, check:api-reference
apps/desktoptypecheck, dev, build, stub-sidecar, tauri, tauri:dev, tauri:build
apps/mobilestart, ios, dev, ios:build, ios:release, ios:dev, web, native:generate, typecheck, build, test
apps/sidecartypecheck, start
other packagestypecheck

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.

In 3D

Packages and their workspace dependencies Drag to orbit · scroll to zoom · right-drag to pan
All 13 workspace packages from their package.json files; each line is a workspace:* dependency (17 in total). Rows are dependency depth: packages with no workspace dependencies at the front, the sidecar, which depends on 8 of them, at the back. Orange boxes are apps.