How videlboga/cyberjack works
Purpose and Entry Points
Cyberjack is a TypeScript simulation/game backend with a React/Vite operator UI. It models characters, scenes, actions, contracts, resources, narrative reactions, and time-based world progression. Main runtime boundaries are the HTTP/socket server at src/api/server.ts, browser bootstrap at src/ui/main.tsx, and game-tick orchestrator at src/orchestration/runGameTick.ts. The repository also contains a separate Unity project under Assets/ for 3D/avatar interaction work.
API and Client Boundary
The API layer exposes controller/route groups for players, state, ticks, scenarios, scenes, contracts, metadata, and logs. Controllers translate HTTP requests into orchestration/domain operations; socket support is isolated alongside the server. The UI is a multi-surface development/game workspace rather than a simple public site.
• src/api/server.ts
• src/api/socket.ts
• src/api/controllers/tickController.ts
• src/ui/GameApp.tsx
• src/ui/WorkspaceApp.tsx
Tick-Oriented Simulation Core
The primary control flow is a tick: load persisted state, evaluate scene/world conditions and triggers, select/execute actions, apply effects and learning, compute results, then save state and emit narrative/telemetry. The engine owns deterministic state transformation and validation; orchestration coordinates cross-domain work.
• src/orchestration/loadTickState.ts
• src/orchestration/runGameTick.ts
• src/orchestration/saveTickState.ts
• src/engine/runTick.ts
• src/engine/computeResult.ts
• src/engine/applyLearning.ts
Domain, Action Compilation, and Diagnostics
Domain modules define canonical schemas, anatomy, targets, profiles, edge state, taxonomy, and resolution rules. Incoming or generated actions are compiled into vectors/context, scaled and merged before engine execution. Diagnostics interpret semantic actions and infer traits from outcomes, creating a separate analysis boundary from simulation mutation.
• src/domain/schemas.ts
• src/domain/edgeState.ts
• src/compiler/compileAction.ts
• src/compiler/compileContextVector.ts
• src/diagnostics/semanticActionInterpreter.ts
Scenario and World Progression
Scenario services govern resource costs, asset purchases/contracts, action access, character lifecycle, spatial context, and scene transitions. Scene orchestration, condition watching, sustained effects, and event routing extend tick execution into campaign/world behavior.
• src/scenario/runScenarioStep.ts
• src/scenario/resolveSceneTransition.ts
• src/scenario/worldService.ts
• src/orchestration/sceneOrchestrator.ts
• src/orchestration/conditionWatcher.ts
• src/orchestration/sustainedEffects.ts
Persistence, Content, and Generation
Infrastructure encapsulates database access, repositories, event queries, contracts, seeding, presets, and generated visual matrices. Lore JSON and tag catalogs feed character generation, whose pipeline composes prompts and profiles/narratives. Character/portrait generation and memory/embedding services form external-service-facing boundaries; LLM/OpenRouter-oriented prompt construction is explicit.
• src/infrastructure/db.ts
• src/infrastructure/repositories.ts
• src/infrastructure/data/presets/actions.json
• src/orchestration/characterGenerator/generator.ts
• src/prompts/openRouterPromptBuilder.ts
• src/services/embeddingService.ts
Presentation and 3D Integration
React views visualize simulation, diagnostics, database state, campaign controls, portraits, and device/scene context. Static VRM models, poses, and backgrounds support avatar presentation. The Unity project includes body-part UI anchoring, a body UI manager, interaction management, and editor ragdoll generation, suggesting a separate Unity runtime/art pipeline rather than a direct replacement for the TypeScript server.
• src/ui/views/Simulation/SimulationView.tsx
• src/ui/views/Diagnostics/DiagnosticsView.tsx
• public/models/base.vrm
• Assets/Scripts/UI/BodyUIManager.cs
• Assets/Scripts/UI/InteractionManager.cs
Components 23
API & clients
- HTTP/socket server · Routes requests and hosts realtime support.
- Socket support
- Tick controller · Starts simulation ticks from API requests.
- Game app
- Workspace app · Development and operations surfaces.
Simulation pipeline
- Game tick orchestrator · Coordinates state, engine, world behavior, and persistence.
- Tick state loader
- Tick engine · Validates and transforms canonical game state.
- Action compiler · Compiles, scales, and merges action context.
- Results & learning
- Tick state saver
- Domain model · Defines entities, taxonomy, targets, and edge state.
- Action diagnostics · Interprets semantic actions and inferred traits.
World & scenario
- Scene orchestration · Watches conditions and manages sustained effects.
- Scenario step · Governs contracts, costs, lifecycle, and transitions.
Data & generation
- Database & repositories · Stores state, events, contracts, and query data.
- Content presets · Seed actions and authored game content.
- Character generation · Builds characters, profiles, and narratives.
- LLM & embeddings · Builds OpenRouter prompts and manages semantic memory.
Presentation & 3D
- Simulation view
- Diagnostics view
- Unity interaction · Separate avatar/body interaction runtime.
- VRM avatar assets
Connections 26
- Game app → HTTP/socket server: HTTP
- Workspace app → HTTP/socket server: HTTP
- HTTP/socket server → Socket support: realtime
- HTTP/socket server → Tick controller: routes tick
- Tick controller → Game tick orchestrator: run tick
- Game tick orchestrator → Tick state loader: load state
- Tick state loader → Database & repositories: read
- Game tick orchestrator → Action compiler: compile actions
- Action compiler → Domain model: uses schemas
- Action compiler → Tick engine: vectors
- Game tick orchestrator → Tick engine: execute
- Domain model → Tick engine: rules
- Tick engine → Results & learning: outcomes
- Results & learning → Action diagnostics: analyze
- Game tick orchestrator → Scene orchestration: evaluate world
- Scene orchestration → Scenario step: scene actions
- Scenario step → Domain model: state rules
- Game tick orchestrator → Tick state saver: save outcomes
- Tick state saver → Database & repositories: write
- Content presets → Action compiler: action definitions
- Character generation → LLM & embeddings: prompts and memory
- Character generation → Database & repositories: persist characters
- Workspace app → Simulation view: renders
- Workspace app → Diagnostics view: renders
- Simulation view → VRM avatar assets: avatar asset
- Unity interaction → VRM avatar assets: 3D avatar work