Add CLAUDE.md, switch to static adapter for nginx deployment

- CLAUDE.md: build commands, architecture overview, coordinate systems,
  WASM rebuild instructions for future development sessions
- Switch from adapter-auto to adapter-static with SPA fallback
  (outputs to build/ directory for nginx serving)
- Install @sveltejs/adapter-static dependency

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-08 12:28:18 -07:00
parent 6c69d7cf89
commit 2ebe0e90d0
4 changed files with 70 additions and 23 deletions

53
CLAUDE.md Normal file
View File

@@ -0,0 +1,53 @@
# Mass Driver — Interplanetary Relay Network Simulator
## Project Structure
Rust workspace + SvelteKit frontend compiled to WASM.
```
crates/
orbital-mechanics/ — Pure Rust: Kepler solver, Lambert solver, orbit propagation, Lagrange points
mass-driver-core/ — Station placement, transfer matrix computation, Dijkstra routing
mass-driver-wasm/ — Thin wasm-bindgen wrapper exposing core to JS
mass-driver-backend/ — Axum cache server (Postgres)
frontend/ — SvelteKit + Threlte (Three.js) + Canvas2D
```
## Build Commands
```bash
# Rust tests
cargo test
# Build WASM (required before frontend)
cd crates/mass-driver-wasm && wasm-pack build --target web --release
# Frontend dev server
cd frontend && npm run dev -- --port 5173
# Frontend production build
cd frontend && npx vite build
# Backend (needs DATABASE_URL env var)
cargo run -p mass-driver-backend
```
## Key Architecture
- Orbital mechanics runs in WASM (Rust compiled to WebAssembly)
- Frontend loads WASM on mount, calls it every animation frame for body positions
- Route computation: Lambert solver → transfer matrix → time-expanded graph → Dijkstra
- 2D view: Canvas2D with manual drawing. 3D view: Threlte (Svelte Three.js wrapper)
- Positions in AU (ecliptic coords), converted to screen pixels (2D) or Three.js units (3D)
- Ecliptic→Three.js mapping: X→X, Y→-Z, Z→Y (Three.js is Y-up)
## WASM Rebuild
After changing any Rust code in orbital-mechanics, mass-driver-core, or mass-driver-wasm:
```bash
cd crates/mass-driver-wasm && wasm-pack build --target web --release
```
The frontend links to the WASM pkg via `file:../crates/mass-driver-wasm/pkg` in package.json.
## Coordinate Systems
- Rust returns positions in AU, ecliptic frame (X=vernal equinox, Y=90° in ecliptic, Z=north pole)
- Lambert solver works in km (positions × AU_KM constant)
- 2D canvas: AU mapped to pixels via zoom factor
- 3D scene: 1 AU = 50 Three.js units, Y-up convention