SpaceAutoBattler is a lightweight, research-oriented 3D space combat simulator. The project separates deterministic simulation logic (pure game logic under src/game) from rendering and UI (src/components, App.tsx) so you can run headless tests and fast experiments.
- TypeScript + React 19
- Rendering: React Three Fiber (
@react-three/fiber) + Drei + Three.js - Physics: Rapier (
@dimforge/rapier3d-compat) - ECS: Miniplex
- UI state: Zustand
- Tooling: Vite, ESLint, Prettier
- Tests: Vitest (unit/integration) and Playwright (E2E/visual)
Clone, install dependencies, then either run the dev server (fast feedback) or build and serve the production bundle:
git clone https://github.com/deadronos/SpaceAutoBattler.git
Set-Location SpaceAutoBattler
npm install
# Development (Vite dev server)
npm run dev
# Build a production bundle (Vite -> `dist/`)
npm run build
# Preview the built files (serves `./dist` on :8080)
npm run previewOpen the local server at http://localhost:8080 (or the URL printed by the serve script).
- Architecture Overview:
ARCHITECTURE.md— High-level system design, architectural principles, directory structure, core concepts, and data flow patterns - Source Structure:
spec/src-structure.md— Detailed file-by-file breakdown of thesrc/directory - Motion System:
spec/spec-physical-movement.md— Deterministic ship movement, renderer interpolation, and banking behavior specifications - Inline Documentation: Many core modules include JSDoc comments. Hover over symbols in your IDE to see usage details, parameters, and return types.
Edit TypeScript sources in src/ only. Key folders:
src/main.tsx— App bootstrap and renderer mountingsrc/App.tsx— React top-level application componentsrc/game/— pure game logic: state container, systems, and ship blueprintssrc/components/— React / R3F components for rendering (Ship, Projectile, HUD)src/types/— canonical types includingGameState(single source of runtime state types)src/utils/— seeded RNG and shared helperssrc/data/— data tables (for example ship stats)src/worker/— optional worker-simulation protocol and transforms layout helperssrc/styles/andspaceautobattler.html— global styles and HTML entry points
Build artifacts and generated files live in dist/ (do not edit).
The project provides a set of npm scripts to run tests, checks and builds. Common ones:
npm install— install dependenciesnpm run dev— Vite dev server on port 8080npm start— alias fornpm run devnpm run build— production Vite build (runsprebuildfirst)npm run build:dev— development build (vite build --mode development)npm run preview— serve./diston port 8080npm run serve— alias fornpm run previewnpm run serve:e2e— servesdist/+ repository root for Playwright pagesnpm test— run unit tests (Vitest, node/happy-dom environment)npm run test:browser— run Vitest configured for browser testsnpm run test:e2e— run Playwright end-to-end testsnpm run typecheck— TypeScript typecheck (no emit)npm run lint— ESLint (source files)npm run lint:fix— ESLint with autofixnpm run format— Prettier formatting
There are also utility scripts used by the project lifecycle:
npm run prebuild— runs a project-specific check (no sync reads) before buildingnpm run check-no-sync-reads— detection script used byprebuildnpm run hash-assets— compute asset hashes for the buildnpm run validate-config— config validation helper
Use npm run to list all scripts.
Unit tests live under test/vitest/ (logic-focused, deterministic). Playwright tests live under test/playwright/ and test artifacts appear in test-output/ and playwright-report/ when run.
Recommended quick checks before committing:
npm run typecheck; npm test- Keep edits confined to
src/(TypeScript). Do not edit files underdist/— they are build artifacts. - Canonical runtime state: use the
GameStatetype defined insrc/types/index.tsfor all simulation state. - Determinism: runtime randomness is provided by the seeded RNG in
src/utils/rng.ts; do not introduce nondeterministic behavior in simulation codepaths. - Configuration-driven design: most gameplay and rendering parameters live under
src/config/. Prefer editing config over hardcoding values.
Proposed small improvements (low-risk):
- Add
docs/_index.mdor expandllms.txtwith brief file summaries for discoverability. - Add a CI link-check job to validate README and docs links.
- Add a lightweight API audit that exposes minimal test helpers for external tooling.
This project is configured to automatically deploy to GitHub Pages when a new tag is created (e.g., for releases).
Repository owners need to enable GitHub Pages:
- Go to repository Settings → Pages
- Set Source to "GitHub Actions"
- No additional configuration needed
- Automatic deployment: Push a git tag (e.g.,
v1.0.0) to trigger the GitHub Actions workflow - Quality gates: The workflow runs
npm run typecheckandnpm testbefore building - Build and deploy: Creates a production build and deploys to GitHub Pages
- File handling: Automatically copies
spaceautobattler.htmltoindex.htmlfor proper GitHub Pages routing
To create a release deployment:
git tag v1.0.0
git push origin v1.0.0The site will be available at https://[username].github.io/SpaceAutoBattler/ after deployment completes.
Production builds generate pre-compressed versions of eligible assets (.gz and .br). Whether clients
receive these depends on your hosting/CDN configuration.
See docs/compression.md for detailed compression ratios and configuration.
Test the deployment build process locally:
npm run build:deploy
npm run serveVerify compression is working on the deployed site:
node scripts/verify-compression.mjsFork the repository, create a feature branch, add tests, and open a pull request. Follow these rules:
- Edit TypeScript only under
src/(do not modify build artifacts indist/). - Preserve deterministic behavior: use the seeded RNG and
GameStatefor runtime state. - Add unit tests in
test/vitest/for logic changes and updatetest/playwright/for UI flows when relevant. - Run
npm run typecheckandnpm testbefore opening a PR.
MIT — see LICENSE.MD.
