Manifest-Driven Architecture
Hyperscape uses a manifest-driven architecture where game content is defined in JSON files rather than hardcoded in TypeScript. This enables rapid content iteration and modding without touching game logic.Architecture Overview
Key Components
| Component | Responsibility |
|---|---|
| JSON Manifests | Define content (items, recipes, NPCs) |
| DataManager | Load and validate manifests |
| Data Providers | Runtime access to loaded data |
| Game Systems | Use data providers for logic |
| Entities | Runtime instances of content |
Manifest Organization
Directory Structure
Loading Process
1. Atomic Directory Loading
DataManager uses atomic loading for multi-file manifests:2. Load Order
Manifests load in dependency order:- Tier requirements - Needed for item normalization
- Items - Core item definitions
- NPCs - Mob and NPC definitions
- Gathering resources - Trees, rocks, fishing spots
- Recipe manifests - Cooking, firemaking, smelting, smithing
- Skill unlocks - Milestone unlocks by level
- Stations - Anvil, furnace, range configuration
- World areas - Zone definitions
- Stores - Shop inventories
3. Validation
Each manifest is validated on load:- Required fields: Missing fields cause load failure
- Duplicate IDs: Duplicate item/NPC IDs are rejected
- Type checking: JSON structure validated against TypeScript interfaces
- Reference integrity: Item/NPC references validated
Data Providers
ProcessingDataProvider
Provides runtime access to processing recipes:TierDataProvider
Provides tier-based level requirements:StationDataProvider
Provides world station configuration:Adding New Content
Example: Adding a New Smithing Recipe
Step 1: Editpackages/server/world/assets/manifests/recipes/smithing.json
manifests/items/armor.json
Manifest Schemas
Smelting Recipe
Smithing Recipe
Station Configuration
Tier Requirements
Benefits of Manifest-Driven Design
1. Separation of Concerns
- Content creators edit JSON files
- Developers build systems that consume manifests
- Designers balance without code changes
2. Hot Reloading
In development, manifest changes can be applied without full rebuilds:3. Modding Support
Community members can create content packs by providing custom manifest files.4. Type Safety
TypeScript interfaces ensure manifests match expected structure:5. Testability
Manifests can be mocked for testing:Migration from Hardcoded Data
The smithing system demonstrates the migration from hardcoded data to manifests:Before (Hardcoded)
After (Manifest-Driven)
Best Practices
1. Use Providers, Not Direct Access
2. Validate at Load Time
3. Cache Provider References
4. Use Type Guards
Performance Optimizations
Pre-allocated Buffers
Data providers use pre-allocated buffers to avoid allocations in hot paths:Lazy Initialization
Providers initialize on first access:Indexed Lookups
Data is indexed by multiple keys for O(1) access:Related Documentation
- Manifests - Manifest file structure
- Data Providers API - API reference
- Adding Content - Content creation guide
- Smithing System - Smithing gameplay