Cadiotheka is an open hub for CAD creators. It collects, organizes, and provides resources, tooling, and references to support people working with computer-aided design. The hub runs as a browser application built with leptos and compiled to WebAssembly, backed by a Cloudflare Pages Functions Rust backend that uses a D1 database and an R2 bucket for uploaded project icons.
- Rust — latest stable toolchain
wasm32-unknown-unknowntarget (for the frontend)- Trunk (for the frontend)
- Node.js and
npx(for the backend) - A Cloudflare account with D1 and R2 access (for backend deployment)
Install the target and Trunk with:
rustup target add wasm32-unknown-unknown
cargo install --locked trunkCadiotheka is a Cargo workspace with two members: cadiotheka-frontend and cadiotheka-backend.
Start a local Trunk dev server:
git clone https://github.com/XodiumSoftware/cadiotheka.git
cd cadiotheka
cd cadiotheka-backend
npx wrangler devIn a second terminal, start the frontend:
cd cadiotheka-frontend
trunk serve --port 8080Then open http://localhost:8080/index.html#dev in a browser.
Trunk proxies /data/* requests to the backend dev server on http://127.0.0.1:8787.
The backend is a Cloudflare Pages Functions Rust worker. First build the WASM bundle, then run Wrangler:
cd cadiotheka-backend
cargo install worker-build --version 0.7.5 --force
worker-build
npx wrangler devThe backend API is available at http://localhost:8787/data/accounts by default.
Project assets (IFC models) are uploaded through the backend and stored in the PROJECT_ASSETS R2 binding (backed by the cadiotheka-assets bucket). The database stores only the generated R2 object key, and the frontend loads assets through backend asset routes.
To use your real Cloudflare resources during local development, run Wrangler in remote mode:
cd cadiotheka-backend
worker-build
npx wrangler dev --remoteThis uses the bindings configured in cadiotheka-backend/wrangler.toml:
DBfor D1AUTHfor KVPROJECT_ASSETSfor R2
Be careful: --remote reads and writes real data in those bound resources, including production data if your bindings point at production.
To create the local D1 database tables:
cd cadiotheka-backend
npx wrangler d1 execute cadiotheka-db --file=schemas/accounts.sql --local
npx wrangler d1 execute cadiotheka-db --file=schemas/projects.sql --localFor asset uploads, also create or bind an R2 bucket in wrangler.toml:
[[r2_buckets]]
binding = "PROJECT_ASSETS"
bucket_name = "cadiotheka-assets"Create accounts and projects through the application UI or API as needed.
Run the full workspace test suite:
cargo testLint each crate:
cd cadiotheka-frontend
cargo clippy --target wasm32-unknown-unknown --all-targets --all-features -- -D warnings
cd ../cadiotheka-backend
cargo clippy --all-targets --all-features -- -D warningsFor a release build:
cd cadiotheka-frontend
trunk build --releaseThe static site is placed in cadiotheka-frontend/dist/.
-
Create a D1 database:
npx wrangler d1 create cadiotheka-db
-
Update
cadiotheka-backend/wrangler.tomlwith the database ID from step 1.The backend uses these short Worker bindings:
DBfor the D1 databaseAUTHfor the KV namespace used by OAuth state and sessionsPIfor the R2 bucket that stores project icons
-
Create a KV namespace for OAuth state and sessions:
npx wrangler kv:namespace create AUTH
Then copy the resulting ID into
cadiotheka-backend/wrangler.tomlunder[[kv_namespaces]]. -
Configure secrets for OAuth and session signing:
npx wrangler secret put SESSION_SECRET npx wrangler secret put GITHUB_CLIENT_ID npx wrangler secret put GITHUB_CLIENT_SECRET npx wrangler secret put GOOGLE_CLIENT_ID npx wrangler secret put GOOGLE_CLIENT_SECRET
SESSION_SECRETcan be any long random string.- GitHub and Google credentials come from OAuth apps registered at:
- GitHub:
https://github.com/settings/developers - Google:
https://console.cloud.google.com/apis/credentials
- GitHub:
- Use callback URLs
https://api.cadiotheka.com/auth/github/callbackandhttps://api.cadiotheka.com/auth/google/callback. - If your backend is served from the same origin as the frontend (e.g. via a Cloudflare Pages Function or a zone route), use
https://cadiotheka.com/auth/...instead.
-
Apply the schema:
npx wrangler d1 execute cadiotheka-db --file=cadiotheka-backend/schemas/accounts.sql npx wrangler d1 execute cadiotheka-db --file=cadiotheka-backend/schemas/projects.sql
Create the first accounts and projects through the deployed application UI or API.
-
Build and deploy:
npx wrangler deploy