Skip to content


Cadiotheka Logo

Cadiotheka

The open hub for CAD creators


Contributors Issues License

Table of Contents

About

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.

Requirements

  • Rust — latest stable toolchain
  • wasm32-unknown-unknown target (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 trunk

Running Locally

Cadiotheka is a Cargo workspace with two members: cadiotheka-frontend and cadiotheka-backend.

Frontend

Start a local Trunk dev server:

git clone https://github.com/XodiumSoftware/cadiotheka.git
cd cadiotheka
cd cadiotheka-backend
npx wrangler dev

In a second terminal, start the frontend:

cd cadiotheka-frontend
trunk serve --port 8080

Then 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.

Backend

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 dev

The 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 --remote

This uses the bindings configured in cadiotheka-backend/wrangler.toml:

  • DB for D1
  • AUTH for KV
  • PROJECT_ASSETS for 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 --local

For 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.

Tests & Linting

Run the full workspace test suite:

cargo test

Lint 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 warnings

Frontend Build

For a release build:

cd cadiotheka-frontend
trunk build --release

The static site is placed in cadiotheka-frontend/dist/.

Backend Deployment

  1. Create a D1 database:

    npx wrangler d1 create cadiotheka-db
  2. Update cadiotheka-backend/wrangler.toml with the database ID from step 1.

    The backend uses these short Worker bindings:

    • DB for the D1 database
    • AUTH for the KV namespace used by OAuth state and sessions
    • PI for the R2 bucket that stores project icons
  3. Create a KV namespace for OAuth state and sessions:

    npx wrangler kv:namespace create AUTH

    Then copy the resulting ID into cadiotheka-backend/wrangler.toml under [[kv_namespaces]].

  4. 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_SECRET can 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
    • Use callback URLs https://api.cadiotheka.com/auth/github/callback and https://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.
  5. 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.

  6. Build and deploy:

    npx wrangler deploy

Built With

Built With

About

The open hub for CAD creators

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Sponsor this project

Contributors

Languages