Deployment Architecture
Hyperscape uses a modern cloud-native architecture with separate services:Production Stack
| Component | Service | URL | Purpose |
|---|---|---|---|
| Frontend | Cloudflare Pages | hyperscape.club | React SPA, static assets |
| API/WebSocket | Railway | api.hyperscape.club | Game server, real-time sync |
| Database | Railway PostgreSQL | (internal) | Player data, world state |
| Assets/CDN | Cloudflare R2 | assets.hyperscape.club | 3D models, manifests, audio |
Staging Stack
| Component | Service | URL | Purpose |
|---|---|---|---|
| Frontend | Cloudflare Pages | staging.hyperscape.club | Staging frontend |
| API/WebSocket | Railway | staging-api.hyperscape.club | Staging server |
| Database | Railway PostgreSQL | (internal) | Staging database |
| Assets/CDN | Cloudflare R2 | staging-assets.hyperscape.club | Staging assets |
The staging environment is a complete isolated instance for testing changes before production deployment.
Monorepo Structure
Hyperscape is a Turbo monorepo with 8 packages:Build Dependency Graph
Packages must build in this order due to dependencies:The
turbo.json configuration handles build order automatically via dependsOn: ["^build"].Package Overview
shared (@hyperscape/shared)
The core Hyperscape 3D engine containing:
- Entity Component System (ECS): Game object architecture
- Three.js integration: 3D rendering (v0.180.0) with WebGPU/WebGL support
- PhysX bindings: Physics simulation via WASM
- Networking: Real-time multiplayer sync via WebSockets
- Game data: Manifests for NPCs, items, world areas
- Game systems: Combat, economy, skills, trading, terrain
- WebGPU (preferred): Modern GPU API with TSL post-processing
- WebGL fallback: For environments without WebGPU (e.g., WKWebView in Tauri)
- Automatic detection and graceful degradation
- Settings panel displays active backend (WebGPU/WebGL)
server (@hyperscape/server)
Game server built with:
- Fastify 5: HTTP API with rate limiting
- WebSockets: Real-time game state via
@fastify/websocket - PostgreSQL: Database persistence (Drizzle ORM)
- LiveKit: Voice chat integration
- Trading System: Player-to-player trading with atomic swaps
- Social System: Friend management and private messaging
client (@hyperscape/client)
Web client featuring:
- Vite: Fast development builds with HMR
- React 19: UI framework
- Three.js: 3D rendering
- @dnd-kit: Accessible drag-and-drop
- Zustand: State management
- Capacitor: iOS/Android mobile builds
- Privy: Authentication
- Farcaster: Miniapp SDK integration
plugin-hyperscape (@hyperscape/plugin-hyperscape)
ElizaOS plugin enabling AI agents to:
- Perform actions (combat, skills, movement, banking, social)
- Query world state via 7 providers (goal, gameState, inventory, nearbyEntities, skills, equipment, availableActions)
- Make LLM-driven decisions with Anthropic, OpenAI, or OpenRouter
- Play autonomously as real players with full WebSocket connectivity
- Train all 12 skills including Agility (passive movement-based XP)
@hyperscape/shared to satisfy ElizaOS’s isolatedModules: true requirement. This resolves 70+ TypeScript build errors.
Key Dependencies:
website (@hyperscape/website)
Marketing website built with:
- Next.js 15: React framework with static export
- React 19: UI framework
- Three.js: 3D rendering and effects
- Tailwind CSS 4: Utility-first styling
- Framer Motion: Animations
- GSAP: Advanced animations
- Landing page with hero, features, and CTA
- $GOLD token page with scroll design
asset-forge (3d-asset-forge)
AI-powered asset generation using:
- Elysia: API server (with CORS, rate limiting, Swagger)
- MeshyAI: 3D model generation
- GPT-4: Design and lore generation
- React Three Fiber: 3D preview with
@react-three/fiberand@react-three/drei - Drizzle ORM: PostgreSQL database for asset tracking
- TensorFlow.js: Hand pose detection for VR/AR interactions
Key Patterns
Entity Component System
All game logic runs through ECS:- Entities: Game objects (players, mobs, items)
- Components: Data containers (position, health, inventory)
- Systems: Logic processors (combat, skills, movement)
Manifest-Driven Content
Game content is defined in JSON manifest files. In production, manifests are fetched from the CDN at server startup and cached locally inpackages/server/world/assets/manifests/:
| File | Purpose |
|---|---|
npcs.json | NPC and mob definitions |
items/weapons.json | Combat weapons |
items/tools.json | Skilling tools |
items/resources.json | Gathered materials |
items/food.json | Cooked consumables |
gathering/woodcutting.json | Trees and log yields |
gathering/mining.json | Rocks and ore yields |
gathering/fishing.json | Fishing spots and catch rates |
recipes/smelting.json | Furnace recipes |
recipes/smithing.json | Anvil recipes |
recipes/cooking.json | Cooking recipes |
quests.json | Quest definitions with stages and rewards |
tier-requirements.json | Centralized level requirements |
skill-unlocks.json | Skill progression milestones |
quests.json | Quest definitions with stages and rewards |
stores.json | Shop inventories |
world-areas.json | Zone configuration with station spawns |
biomes.json | Biome definitions |
vegetation.json | Procedural vegetation |
stations.json | Station models and configurations |
model-bounds.json | Auto-generated model footprints (build-time) |
Asset Serving Architecture
Development
In development, assets are served from a local Docker CDN:- Client requests asset:
http://localhost:8080/models/goblin/goblin.vrm - nginx serves from
packages/server/world/assets/ - Manifests loaded from local filesystem
Production
In production, assets are served from Cloudflare R2:- Client requests asset:
https://assets.hyperscape.club/models/goblin/goblin.vrm - Cloudflare R2 serves with global CDN caching
- Server fetches manifests from R2 at startup
- Manifests cached locally in
packages/server/world/assets/manifests/
npcs.json,stores.json,world-areas.json,prayers.jsonitems/*.json(weapons, tools, resources, food, misc)gathering/*.json(woodcutting, mining, fishing)recipes/*.json(cooking, firemaking, smelting, smithing)
Staging
Staging uses a separate R2 bucket (hyperscape-assets-staging) to isolate test content from production.
Build Pipeline
Automated Model Bounds Extraction
The server package includes a build-time task that automatically extracts collision footprints from 3D models:- Scans
world/assets/models/**/*.glbfiles - Parses glTF position accessor min/max values
- Calculates bounding boxes and tile footprints
- Generates
world/assets/manifests/model-bounds.json
packages/server/turbo.json):
The bounds extraction is cached - it only re-runs when GLB files or the script changes. This keeps builds fast while ensuring collision data stays in sync with models.
Deployment Architecture
Railway Deployment
Hyperscape server deploys to Railway with automated CI/CD: Configuration Files:nixpacks.toml: Nixpacks build configuration (recommended)Dockerfile.server: Multi-stage Docker build (alternative)railway.server.json: Railway service configuration.railwayignore: Excludes large directories from upload.github/workflows/deploy-railway.yml: Automated deployment workflow
- Install system dependencies (python3, make, g++, git, cairo, pango)
- Install Node dependencies with
bun install --frozen-lockfile - Clone assets repository (manifests needed by DataManager)
- Build packages in order: shared → server
- Start server with
bun dist/index.js
- Assets are not uploaded to Railway (excluded via
.railwayignore) - Assets are cloned during build from GitHub assets repository
- Assets are served from CDN in production (not bundled with server)
ensure-assets.mjsdetects CI environments and skips download
Split Deployment Model
Hyperscape supports split deployments:- Server: Railway, Fly.io, or Docker host
- Client: Vercel, Netlify, or static hosting
- Database: PostgreSQL (Neon, Railway, or self-hosted)
- Assets: CDN or object storage (R2, S3)
PRIVY_APP_ID(server) must matchPUBLIC_PRIVY_APP_ID(client)- Client’s
PUBLIC_WS_URLandPUBLIC_API_URLmust point to server - Both must use same
PUBLIC_CDN_URLfor assets