Skip to content

Anashel-RPG/ev2090

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

5 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

EV Β· 2090

LIVE DEMO: https://ev2090.com/

A 3D space simulation game built with React and Three.js, deployed on Cloudflare.

Read-only repository. This is the first public release of EV Β· 2090. I'm still figuring out the best workflow for collaborating with other developers without spending all my time managing PRs and maintaining two parallel codebases (the MMO branch I actively build on vs. a contributor-friendly fork). For now, treat this repo as read-only β€” explore it, learn from it, and use it as a starting point for your own multiplayer engine, single-player variant, or backend experiments. When I've sorted out a contribution workflow that doesn't slow down development, I'll open things up. Stay tuned.

What is this?

EV Β· 2090 is a 3D space simulation built with React 19 for UI, Three.js for the 3D world, and Cloudflare Workers for the backend. You fly a ship around a solar system, scan NPC vessels, dock at planet stations to trade commodities, swap between ship models and colors, and chat with other players in real time.

Behind the scenes, a living economy simulates production, consumption, and NPC trade routes 24/7 -- whether players are online or not. An AI-powered ship forge lets the community design new vessels. An MCP server lets you manage the whole economy by talking to Claude. And an admin dashboard gives you a 3D visualization of every trade route and market in the system.

The codebase spans four workspaces with a regular structure. Every engine system follows the same pattern. Every Durable Object follows the same pattern. Once you understand one, you understand them all.

Documentation

You do not need to read everything. Pick the guide that matches what you are working on.

Start here

  • Architecture -- big picture, key diagrams, data flow
  • AI Guide -- using AI coding assistants with this codebase

Frontend

  • Engine Guide -- 3D layer: systems, entities, game loop, shaders
  • UI Guide -- React components: sidebar, station, hangar, responsive design

Backend

  • Backend Guide -- Backend Worker, Durable Objects, routing
  • Economy Engine -- tick engine, SQLite schema, price curves, warmup
  • NPC Economy -- NPC hauler brain, trade routes, sawtooth patterns

Extra Tools

Deployment & tooling

  • Cloudflare Setup -- deploying your own instance from scratch
  • Self-Hosting -- running without Cloudflare (workerd, Docker, VPS)
  • Dev Tools -- config panel, debug commands, authoring tools
  • Recipes -- how to add systems, entities, components, routes (Warning; untested)
  • Security -- security model, keys, CORS, rate limiting

Tech Stack

Layer Technology Version
UI React 19
3D Engine Three.js 0.172
Language TypeScript 5.7
Bundler Vite 6
Backend Cloudflare Workers + Durable Objects -
Hosting Cloudflare Pages -

The stack at a glance

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  Frontend (React 19 + Three.js)    ← you fly ships here β”‚
β”‚  Vite 6 Β· TypeScript 5.7 Β· port 5180                    β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚  Admin Dashboard (React 19 + Three.js)    ← economy ops β”‚
β”‚  Vite 6 Β· port 5181                                     β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚  Game Worker (Cloudflare Workers)     ← the brain        β”‚
β”‚  4 Durable Objects Β· 2 R2 buckets Β· 1 queue              β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚  MCP Worker (Cloudflare Workers)      ← AI interface     β”‚
β”‚  37 tools Β· OAuth 2.0 Β· Claude integration               β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Getting Started

Two commands. That's it.

npm install
npm run dev

npm install sets up all four workspaces. npm run dev starts the frontend, the local worker, and the admin dashboard β€” and automatically seeds the NPC economy after 8 seconds so you have live trade data from the moment the page loads. No API keys, no .env files, no Cloudflare account required.

URL What's there
http://localhost:5180 The game β€” fly ships, dock, trade
http://localhost:5181 Admin dashboard β€” 3D trade route viewer, economy overview
http://localhost:8787 Local worker API

The game runs in no-auth mode by default: all admin routes are open and the economy is fully functional with locally seeded data. You can explore the entire game engine without touching any configuration.

Advanced configuration (AI ship forge, custom API keys, deploying your own Cloudflare infrastructure) is covered in CLAUDE.md and docs/cloudflare-setup.md when you're ready for it.

Prerequisites

  • Node.js 18+

Run independently

npm run dev:frontend   # frontend only β€” API proxied to production ws.ev2090.com
npm run dev:api        # local worker only
npm run dev:admin      # admin dashboard only

Deploy

npm run deploy         # builds + deploys frontend to Cloudflare Pages
npm run deploy:api     # deploys worker to Cloudflare Workers

Controls

Key Action
W / Arrow Up Thrust
A / Arrow Left Rotate left
D / Arrow Right Rotate right
S / Arrow Down Brake
B Toggle debug beam

Console tricks -- open your browser dev tools and try:

Command Action
config() Toggle light/camera debug panel
testship() Spawn a frozen NPC near your ship
heroshot() Toggle hero shot authoring tool
hardpoints() Toggle hardpoint editor
forge() Toggle ship forge overlay
ship("bob") Switch ship by catalog ID
zoom(0.3) Zoom camera (lower = closer)
zoomreset() Reset zoom to default
reset() Clear localStorage and reload

URL shortcuts (dev only):

?scene=gameplay Β· ?scene=docked Β· ?scene=heroshot Β· ?scene=hardpoint Β· ?scene=config Β· ?scene=intro

Architecture Overview

graph LR
  subgraph Frontend ["Frontend Β· React 19 + Three.js"]
    direction TB
    Game["Game.tsx<br/>orchestrator"]
    Canvas["GameCanvas.tsx<br/>React ↔ Engine bridge"]
    Engine["Engine.ts<br/>game loop + scene"]
    Systems["systems/<br/>subsystems"]
    Entities["entities/<br/>Ship Β· Planet Β· NpcShip"]
    Components["UI Components<br/>Sidebar Β· Station Β· Hangar Β· Chat"]
    Game --> Canvas
    Game --> Components
    Canvas -->|"GameCanvasHandle"| Engine
    Engine -->|"subscribe ~20fps"| Canvas
    Engine --> Systems
    Engine --> Entities
  end
  subgraph Worker ["Game Worker Β· Cloudflare"]
    direction TB
    Index["index.ts<br/>HTTP routing"]
    ChatDO["ChatRoom DO<br/>SSE chat"]
    BoardDO["BoardRoom DO<br/>community notes"]
    ForgeDO["ShipForge DO<br/>AI ship pipeline"]
    EconDO["EconomyRegion DO<br/>NPC economy"]
    Index --> ChatDO
    Index --> BoardDO
    Index --> ForgeDO
    Index --> EconDO
  end
  Components -->|"HTTP / SSE"| Index
Loading

The frontend is a single-page app. The Three.js engine runs the 3D scene independently of React. React handles the HUD, sidebar panels, station UI, hangar, and chat. The engine pushes state updates to React at ~20fps via a subscribe callback.

The worker is a Cloudflare Worker with four Durable Objects: ChatRoom (real-time SSE chat), BoardRoom (community notes), ShipForge (AI-powered ship generation), and EconomyRegionDO (NPC economy simulation with SQLite). Two R2 buckets store ship models and economy snapshots.

The one rule that governs everything

The engine has zero React dependencies. React talks to the engine through an imperative ref handle (GameCanvasHandle). The engine pushes state back to React at ~20 fps via a subscribe callback. This boundary is the single most important thing to understand.

The flow looks like this:

graph LR
  React["React (Game.tsx)"] -->|"imperative ref"| Bridge["GameCanvasHandle"] -->|"method calls"| Engine["Engine.ts"]
  Engine -->|"subscribe callback ~20fps"| React
Loading

React never reaches into Three.js objects directly. The engine never imports React. GameCanvasHandle is the contract between the two worlds. If you remember nothing else from these docs, remember this.

The four backend patterns

The backend follows the same principle -- a small number of repeating patterns:

  1. Every Durable Object follows: constructor loads state β†’ fetch() handles routes β†’ alarm() for periodic work.
  2. Every MCP tool follows: validate scope β†’ extract params β†’ call DO or R2 β†’ format response.
  3. Every admin endpoint follows: validate Bearer token β†’ call DO β†’ return JSON.
  4. All state is dual: in-memory (fast) + SQLite/R2 (durable). Always update both.

AI-Assisted Development

Use an AI coding assistant? I've prepared project context files:

  • CLAUDE.md β€” for Claude Code. Loaded automatically when you open this project.
  • .cursorrules β€” for Cursor. Loaded automatically as project rules.
  • docs/ai.md β€” explains what these files contain and why every rule exists.

These files contain architecture rules, conventions, common tasks, and gotchas so your AI assistant understands the codebase from the first prompt.

Project Structure

escape_velocity/
β”œβ”€β”€ frontend/                       # React + Three.js SPA
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ components/             # React UI components
β”‚   β”‚   β”‚   β”œβ”€β”€ config/             # CollapsibleSection building blocks
β”‚   β”‚   β”‚   β”œβ”€β”€ sidebar/            # Right sidebar panels (Radar, Diagnostic, Selector, Cargo, Status, Nav, Target)
β”‚   β”‚   β”‚   β”œβ”€β”€ station/            # Station facility sub-panels (Summary, Trading, Locked)
β”‚   β”‚   β”‚   β”œβ”€β”€ hangar/             # Ship management overlay (HangarOverlay, ShipCard, ShipDetail, ForgeCreatePanel)
β”‚   β”‚   β”‚   β”œβ”€β”€ Game.tsx            # Main layout orchestrator
β”‚   β”‚   β”‚   β”œβ”€β”€ GameCanvas.tsx      # Three.js canvas + React bridge
β”‚   β”‚   β”‚   β”œβ”€β”€ IntroScreen.tsx     # First-time ship selection
β”‚   β”‚   β”‚   β”œβ”€β”€ StationPanel.tsx    # Desktop docking interface
β”‚   β”‚   β”‚   β”œβ”€β”€ StationOverlay.tsx  # Mobile docking interface (CRT terminal)
β”‚   β”‚   β”‚   β”œβ”€β”€ ChatPanel.tsx       # Multiplayer SSE chat
β”‚   β”‚   β”‚   └── ...                 # DockFlash, TouchControls, hangar/, etc.
β”‚   β”‚   β”œβ”€β”€ engine/                 # Three.js game engine (no React deps)
β”‚   β”‚   β”‚   β”œβ”€β”€ Engine.ts           # Core: game loop, scene, renderer
β”‚   β”‚   β”‚   β”œβ”€β”€ ShipCatalog.ts      # Ship definitions (11 built-in + community)
β”‚   β”‚   β”‚   β”œβ”€β”€ entities/           # Ship, Planet, NpcShip, Bridge
β”‚   β”‚   β”‚   β”œβ”€β”€ systems/            # CameraController, NpcManager, PostProcessing, etc.
β”‚   β”‚   β”‚   └── shaders/            # GLSL shaders (shield, vignette, color correction)
β”‚   β”‚   β”œβ”€β”€ data/                   # Static game data (stations, missions)
β”‚   β”‚   β”œβ”€β”€ hooks/                  # useBreakpoint, useConfigSlider, usePlayerEconomy, useMarketPrices
β”‚   β”‚   └── types/                  # Shared TypeScript interfaces
β”‚   └── vite.config.ts
β”œβ”€β”€ worker/                         # Cloudflare Worker (game backend)
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ index.ts                # HTTP routing + CORS + queue consumer
β”‚   β”‚   β”œβ”€β”€ admin.ts                # Admin API handlers (Bearer auth)
β”‚   β”‚   β”œβ”€β”€ chat-room.ts            # ChatRoom DO (SSE chat)
β”‚   β”‚   β”œβ”€β”€ board-room.ts           # BoardRoom DO (community notes)
β”‚   β”‚   β”œβ”€β”€ ship-forge.ts           # ShipForge DO (AI ship pipeline)
β”‚   β”‚   β”œβ”€β”€ economy-region.ts       # EconomyRegionDO (NPC economy, SQLite)
β”‚   β”‚   β”œβ”€β”€ economy/                # Pricing, trade routes, disruptions
β”‚   β”‚   └── data/                   # Commodity + planet definitions
β”‚   └── wrangler.toml
β”œβ”€β”€ worker-mcp/                     # MCP server (AI economy management)
β”‚   └── src/tools/                  # 37 tools across 10 categories
β”œβ”€β”€ admin/                          # Admin dashboard (local dev only)
β”‚   └── src/                        # Economy monitoring + 3D trade viewer
β”œβ”€β”€ docs/                           # Project documentation
└── package.json                    # Monorepo root (workspaces)

Environment Variables

Variable Description
VITE_API_PROXY_TARGET Override API proxy target in dev. Defaults to https://ws.ev2090.com.
VITE_FORGE_API_KEY Ship Forge admin key for local dev.

Shared Infrastructure

The project ships with hardcoded URLs pointing to cdn.ev2090.com (assets) and ws.ev2090.com (API backend). These are provided temporarily so you can clone the repo and play immediately without deploying your own infrastructure. They will likely be shut down in the future β€” don't depend on them for a fork. To deploy your own instance, see docs/cloudflare-setup.md.

Credits

The ship models in this project are by @Quaternius, released under CC0 1.0 Universal (Public Domain). These models are incredible and free β€” if you use them in your own projects, consider supporting Quaternius on Patreon. Even $1 helps.

β†’ patreon.com/quaternius

Roadmap

EV Β· 2090 is built on React and TypeScript β€” which means it can ship everywhere. I'm working toward releasing the framework with native builds for:

  • Web (current) β€” runs in any modern browser
  • Desktop β€” Windows and macOS executables via Electron or Tauri
  • Mobile β€” iOS and Android via Capacitor or React Native

One codebase, every platform. Stay tuned.

License

This project is licensed under the MIT License.

About

No description, website, or topics provided.

Resources

License

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages