Skip to content

Development

YwVeEiS edited this page Nov 30, 2026 · 1 revision

Development

Repository layout

Folder Contents
backend/ FastAPI (Python 3.12+), SQLite, tests; app/engine/ slicer and scene, app/printers/ printer drivers
frontend/ Web app (Svelte 5, Vite, three.js); texts in src/lib/locales/de.js and en.js
webapp/ nginx config and Dockerfile for the web app container
apps/tauri/ Desktop app (Tauri 2), local mode, slicing on the device
apps/android/ Android app (Java without Gradle) with Orca and Python
mcp/ MCP server
.github/workflows/ Docker images for GitHub Container Registry

Code comments are mostly in German.

Dev setup (Mac)

cd backend && python3.13 -m venv .venv && .venv/bin/pip install -r requirements-dev.txt
cd backend && DATA_DIR=../.devdata \
  ORCA_BIN="/Applications/Snapmaker Orca.app/Contents/MacOS/Snapmaker_Orca" \
  ORCA_PROFILES="/Applications/Snapmaker Orca.app/Contents/Resources/profiles" \
  .venv/bin/uvicorn app.main:app --port 8321 --reload --reload-dir app
cd frontend && npm install && npm run dev

On Linux, point ORCA_BIN and ORCA_PROFILES at an extracted Snapmaker Orca AppImage (AppRun and resources/profiles).

Careful: a dev backend with real printers in its database connects to them. Bambu printers only accept a few MQTT connections. For testing, use a database with test printers on an unused address.

Tests

cd backend && .venv/bin/pytest -q
cd frontend && npm test

One test checks that de.js and en.js have the same keys and placeholders.

Building the apps

Set your own app ID first. The source uses the placeholder com.example.plateful.

  • Mac: PLATEFUL_APP_ID=io.github.yourname.plateful apps/tauri/local/build-mac.sh (web app + backend via PyInstaller, about 50 MB). The result is in apps/tauri/src-tauri/target/release/bundle/macos/Plateful.app. Copy it to /Applications. ORCA_BUNDLE=1 builds Orca into the app.
  • Android: PLATEFUL_APP_ID=io.github.yourname.plateful apps/android/build.sh --install <device> builds build/Plateful.apk and installs it via adb (for example over Wireless Debugging). The runtime (Orca, Python) is in apps/android/build/runtime and is only rebuilt when needed. Back up the signing key ~/.android/plateful.keystore; otherwise updates only install after uninstalling. Raise PLATEFUL_VERSION_CODE for every release.
  • Icons: cd apps/tauri && npm run icons creates all sizes from docs/icon-full-1024.png. The macOS icon comes from docs/icon-mac-1024.png.

Releases

  1. Update the version in apps/tauri/package.json, apps/tauri/src-tauri/Cargo.toml and apps/tauri/src-tauri/tauri.conf.json.
  2. Tag vX.Y.Z and push the tag. GitHub Actions builds plateful-backend and plateful-webapp and pushes them to ghcr.io/<owner>/… with the tags X.Y.Z, X.Y and latest.
  3. Build the Mac app and the APK and attach them to the GitHub release.

Internals

Slicing

The backend calls the Snapmaker Orca CLI as a separate program. Each job gets its own working folder in DATA_DIR/slices/<id>/ with the profiles, the project, the command and the log. At most SLICE_PARALLEL jobs run at the same time.

  • Edited scenes: for each object, the web app sends {src, m} (source and 3MF transform in bed coordinates). engine/scene.py writes a 3MF from it (STL/OBJ) or replaces the build items in the project. Orca then runs without --arrange/--orient.
  • Painting: frontend/src/lib/painter.js keeps a state per triangle and layer (color, supports, seam). Split triangles are stored as Orca subdivision trees (lib/paintTree.js). The slice job only sends what changed, gzip + Base64. The backend checks every tree and writes it as paint_color / paint_supports / paint_seam into the 3MF, encoded the same way as Orca. Orca drops paint in filaments it doesn't know, so files3d.grow_filaments extends the filament lists of 3MF projects.
  • Parts and height ranges are written to Metadata/model_settings.config and Metadata/layer_config_ranges.xml. Orca quirks handled by Plateful:
    • a part must not reach below the bottom of the object, or Orca crashes,
    • in Bambu projects, parts must be in the order negative → modifier → part,
    • a height range always needs a layer height.
  • Mixed colors are written as mixed_filament_definitions. Orca treats them as virtual filaments after the real ones.
  • Cutting runs in the browser (frontend/src/lib/cut.js), because the Orca CLI can't cut.
  • Layer preview: the backend converts the G-code once into a compact binary file (GET /api/slices/{id}/layers.bin, format in backend/app/engine/layers.py).

Slicing on the device

  1. The server prepares the job as usual (profiles, project, command), but sets the slice to device instead of starting Orca.
  2. The web app fetches the package (GET /api/slices/{id}/device-job), hands it to the app's built-in backend (POST http://127.0.0.1:<port>/api/device/slice) and uploads the result (POST …/device-result).
  3. The server evaluates it like its own run. If the device doesn't answer, the web app reports it (device-fail); after 15 minutes the server gives up on its own.

The device key the web app gets is SHA-256 of plateful-device:<start key>, so the page from the server never sees the key for the local login.

Local mode

The app starts the backend (backend/local_main.py) with a random key on 127.0.0.1 and opens /api/auth/local?key=…. The first time, Plateful creates a local admin for this. The backend rejects requests with a foreign host name (protection against DNS rebinding) and exits when the app exits.

Printers and cameras

  • Snapmaker U1: Moonraker. Upload to gcodes/plateful/, start with tool mapping (MAP_TABLE), still image from /server/webcams/list.
  • Bambu: MQTT 8883 and FTPS 990 with TLS. Camera on port 6000 (P1/A1, JPEG stream) or RTSPS 322 (X1C, ffmpeg turns it into JPEG frames).
  • The backend keeps at most one connection per camera and shares the frames with all viewers (backend/app/cameras.py).

API conventions

  • Every writing API request needs the header X-Plateful: 1 (protection against forms from other sites).
  • Access keys are sent as Authorization: Bearer plf_…. These requests don't need X-Plateful, and only the key counts, never the session cookie.

The wiki

The wiki is its own Git repository (Plateful.wiki.git). Pages are Markdown files; spaces in the title become - in the file name. _Sidebar.md is the navigation.

Clone this wiki locally