For developers· 10 min read
11For developers
Architecture, local setup, the sacred rules, and where everything lives in the code.
Audience: engineers who'll read or write code. This is the orientation map; the
authoritative, always-current source of truth is the repo root
CLAUDE.md. When this doc and CLAUDE.md disagree,
CLAUDE.md wins.
The architecture in one screen#
A pnpm + Turborepo monorepo. One sentence per layer:
| Layer | Lives in | Stack | Responsibility |
|---|---|---|---|
| Physics engine | packages/engine/ | Rust → WASM (wasm-pack) | All orbital mechanics. Deterministic, golden-bit tested. |
| Web app | apps/web/ | Next.js 16, React 19, TS, R3F + Three.js WebGPU | The UI. Renders only — never computes physics. |
| API | apps/api/ | Fastify 5, Node 22, TS, Postgres.js | Auth, mission/vehicle storage, community, thin proxy to services. |
| Shared types | packages/shared/ | Zod + TS | Single source of truth for domain types & API contracts. |
| Fidelity service | services/fidelity/ | Python FastAPI + orekit_jpype (Orekit 13) | Operational L2+ propagation (full gravity, drag, SRP, 3rd-body). |
| Discovery service | services/discovery/ | Python FastAPI + Lightkurve/astroquery/sklearn | Deep Field: light curves, BLS, vetting, catalog, ML, cross-match. |
| Collab (designed) | — | Hocuspocus (Yjs) | Real-time co-editing of mission YAML. |
| AI service (designed) | services/ai/ | Python FastAPI | RAG + Claude for the CAPCOM copilot (S6). |
Browser (Next.js + WASM engine) ──▶ Fastify API ──┬──▶ Postgres
├──▶ fidelity service (Orekit)
└──▶ discovery service (TESS/MAST)
The sacred rules (do not violate)#
- No physics in TypeScript. Ever. The WASM boundary is sacred — the browser renders, the Rust engine computes. (The one carve-out: Deep Field is data analysis over NASA pipeline products, in Python, using astronomy units; the browser still only renders.)
- Never mix units. SI everywhere (m, s, kg, rad) — except the documented Deep Field astronomy units. No km/m mixing in one calculation.
- Determinism is law. The engine is golden-bit tested. Don't break
bit-reproducibility; rebuild and re-commit the WASM
pkg/after anylib.rschange. - Honesty is first-class. Every result carries a fidelity/honesty label,
provenance, and (for services) a
pipeline/label/credit. This is Constitution Art. XI, never optional. - Free academic tier is untouchable. No code or feature may gate
.edu/.ac.*users. - Never ship code you can't explain.
The full HOUSE PATTERNS list (service shape, API-as-thin-proxy, shared-types
contract, TSL-only shaders, cost/test doctrine, comment discipline) is in
CLAUDE.md — read it before contributing.
Local setup#
# Node 22 (via nvm) is required
pnpm install
# Build the Rust → WASM engine (after any packages/engine/src/lib.rs change)
cd packages/engine && wasm-pack build --target web --out-dir pkg
# Run everything in dev
pnpm dev
# Type-check / format (run before committing)
pnpm typecheck # rebuild @deltav/shared first if you touched it
pnpm format
# Rust tests (the engine's truth)
cargo test
# Physics validation harness
node scripts/validate-physics.mjs
Docker (profile-based; local images mirror prod)#
pnpm docker:dev # Postgres only (schema auto-applied)
pnpm docker:full # db + discovery + api (prod images; dev flags flipped)
pnpm docker:fidelity # the Orekit service
pnpm docker:reset # tear down
Local uses the same prod Dockerfiles Railway deploys, with two bypass flags
for dev (ALLOW_DEV_AUTH=1, DB_NO_SSL=1). Env names are identical to prod;
only values + those flags differ.
Discovery service (needed for /deep-field)#
cd services/discovery && .venv/bin/uvicorn app.main:app --port 8100
cd services/discovery && .venv/bin/python smoke_test.py # QUICK: cached, no network
Where things live (quick map)#
- Engine math:
packages/engine/src/lib.rs— everypub fnis a WASM export; natively-unconstructible types use*_internal+ thin WASM wrappers. - Domain types & API contracts:
packages/shared/src/index.ts(Zod schemas,MissionPackageSchema, discovery schemas). - Flight Deck UI:
apps/web/src/app/deck/page.tsx; rail panels inapps/web/src/components/shell/panels/(Orbit, Maneuver, Target, FiniteBurn, Track, Vehicle, Access, Coverage, Fidelity); 3D scene inapps/web/src/components/orbit/. - Marketing/rooms:
apps/web/src/app/(marketing)/(archive,hangar,napkin,deep-field,loop,m,u,contact,docs). - Presets & catalogs:
apps/web/src/missions/(presets, stations, constellations, vehicles, engines, deepfield-targets, apolloMission). - Canonical mission format:
missions/apollo-11/mission.yaml(.dvmissionYAML; schema inpackages/shared). - API routes:
apps/api/src/routes/(propagate,tle,discovery,feedback, missions/community). - Notes (append-only learning log):
notes/YYYY-MM-DD-HHMM-topic.md— write one per session (seenotes/README.md). - Program docs:
docs/reviews/(phase deliverables + the war plan),docs/implementation/,docs/system-truth/.
Conventions that bite if ignored#
- Rebuild & commit
packages/engine/pkg/after engine changes — CI validates the committed WASM (the deployed bits).ENGINE_PREBUILT=1lets the TS jobs skip the Rust build by downloading thewasm-pkgartifact. - Rebuild
@deltav/sharedbefore typechecking the API. - Shaders are TSL-only for the WebGPU scene (compiles to WGSL and GLSL — no raw GLSL). The star map deliberately uses shaderless built-in materials + procedural CanvasTextures.
- Cost/test doctrine (PROMPTS.md §7): expensive/network checks are
phase-exit gates, never per-edit; one browser verification at the end. Heavy
Python imports (lightkurve, astropy, sklearn) stay lazy inside functions so
/healthis instant. notes/is excluded from Prettier (append-only audit prose). Runpnpm format, lint, and typecheck before committing.- Branches: active work is on
develop-2(the Opus implementation track);develop/mainare reserved. CI runs on all four.
The contribution loop (typical brick)#
- Add the math to
packages/engine/src/lib.rs+cargo test(and golden bits if needed). - Rebuild WASM, commit
pkg/. - Add the shared Zod schema / TS types in
packages/shared(if it crosses the wire). - Build the UI panel that marshals inputs → engine call → render (no physics in TS).
- If a service is involved: engine module + pydantic models + a smoke test; thin API proxy with the honest 400/404/502/503 taxonomy.
- One browser verification at the end; write a
notes/entry. pnpm format && pnpm typecheck && cargo test.
Read these before touching core code#
CLAUDE.md— the living context & house patterns (start here)packages/engine/src/lib.rs— the physics enginepackages/shared/src/index.ts— all domain typesmissions/apollo-11/mission.yaml— canonical mission formatVISION.md,ARCHITECTURE.md,TECHNICAL_BIBLE.md,CONSTITUTION.mddocs/reviews/sovereignty-program-war-plan-2026-06-11.md— the S0–S7 plan
Spotted something? Suggest an editPart of the Delta V Dynamics handbook