# mhollink/runemark architecture

> Architecture diagram of the GitHub repository mhollink/runemark, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/mhollink/runemark
- Repository: https://github.com/mhollink/runemark

## Overview

Runemark is an incremental fantasy-game runtime and web client. The intended player journey is to choose an activity or destination, have commands update game state, simulate travel and activity progress, then inspect character and world state in the client. The excerpts directly verify command dispatch, simulation branches, route finding, content assembly, and save validation; most web feature wiring is unsampled, so those capabilities are represented without guessed call edges.

Main entry points: [`packages/engine/src/simulation.ts`](https://github.com/mhollink/runemark/blob/main/packages/engine/src/simulation.ts) (Game simulation), [`packages/engine/src/commands/execute-command.ts`](https://github.com/mhollink/runemark/blob/main/packages/engine/src/commands/execute-command.ts) (Command dispatch), [`packages/content/src/game-content.ts`](https://github.com/mhollink/runemark/blob/main/packages/content/src/game-content.ts) (Content registry), [`apps/web/src/game/persistence/save-repository.ts`](https://github.com/mhollink/runemark/blob/main/apps/web/src/game/persistence/save-repository.ts) (Save repository)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Web client"]
  node_web["Game interface<br/>[App.tsx]"]
  node_activities_ui["Activities and combat"]
  node_world_ui["World and travel"]
  node_character_ui["Character and skills"]
  node_inventory_ui["Inventory and bank"]
  node_offline_ui["Offline progress"]
end

subgraph group_runtime["Game runtime"]
  node_command["Command dispatch<br/>[execute-command.ts]"]
  node_simulation["Game simulation<br/>[simulation.ts]"]
  node_activity_engine["Activity simulation"]
  node_combat_engine["Combat simulation<br/>[combat.ts]"]
  node_travel_engine["Travel simulation"]
  node_route_finding["Route finding<br/>[find-route.ts]"]
  node_activity_session["Activity sessions"]
end

subgraph group_rules["Domain rules"]
  node_game_state["Game state model<br/>[character.ts]"]
  node_inventory_rules["Inventory rules<br/>[inventory.ts]"]
  node_equipment_rules["Equipment rules<br/>[equipment.ts]"]
end

subgraph group_content["Game content"]
  node_content_registry["Content registry<br/>[game-content.ts]"]
  node_activity_catalog["Activity definitions<br/>[index.ts]"]
  node_item_catalog["Item definitions<br/>[index.ts]"]
end

subgraph group_persistence["Save persistence"]
  node_save_manager["Save manager<br/>[save-manager.ts]"]
  node_save_repository["Save repository<br/>[save-repository.ts]"]
  node_indexed_db[("Browser save store")]
end

node_player(("Player"))

node_command -->|"simulates first"| node_simulation
node_command -->|"transitions session"| node_activity_session
node_command -->|"finds route"| node_route_finding
node_command -->|"creates travel"| node_travel_engine
node_simulation -->|"dispatches combat"| node_combat_engine
node_simulation -->|"dispatches gathering and production"| node_activity_engine
node_simulation -->|"simulates travel"| node_travel_engine
node_simulation -.->|"uses content"| node_content_registry
node_activity_session -->|"finds activity and bank routes"| node_route_finding
node_content_registry -->|"registers activities"| node_activity_catalog
node_content_registry -->|"registers items"| node_item_catalog
node_save_manager -->|"loads and saves"| node_save_repository
node_save_manager -->|"validates loaded save"| node_save_repository
node_indexed_db -->|"implements contract"| node_save_repository
node_inventory_rules -.->|"models backpack state"| node_game_state
node_equipment_rules -->|"moves items"| node_inventory_rules
node_player -.->|"uses"| node_web

click node_web "https://github.com/mhollink/runemark/blob/main/apps/web/src/app/App.tsx"
click node_activities_ui "https://github.com/mhollink/runemark/tree/main/apps/web/src/features/activities"
click node_world_ui "https://github.com/mhollink/runemark/tree/main/apps/web/src/features/world"
click node_character_ui "https://github.com/mhollink/runemark/tree/main/apps/web/src/features/equipment"
click node_inventory_ui "https://github.com/mhollink/runemark/tree/main/apps/web/src/features/inventory"
click node_offline_ui "https://github.com/mhollink/runemark/tree/main/apps/web/src/features/offline-progress"
click node_command "https://github.com/mhollink/runemark/blob/main/packages/engine/src/commands/execute-command.ts"
click node_simulation "https://github.com/mhollink/runemark/blob/main/packages/engine/src/simulation.ts"
click node_activity_engine "https://github.com/mhollink/runemark/tree/main/packages/engine/src/activities"
click node_combat_engine "https://github.com/mhollink/runemark/blob/main/packages/engine/src/activities/combat.ts"
click node_travel_engine "https://github.com/mhollink/runemark/blob/main/packages/engine/src/navigation/standalone-travel.ts"
click node_route_finding "https://github.com/mhollink/runemark/blob/main/packages/engine/src/navigation/find-route.ts"
click node_activity_session "https://github.com/mhollink/runemark/blob/main/packages/engine/src/activities/shared/activity-session.ts"
click node_game_state "https://github.com/mhollink/runemark/blob/main/packages/domain/src/character/character.ts"
click node_inventory_rules "https://github.com/mhollink/runemark/blob/main/packages/domain/src/inventory/inventory.ts"
click node_equipment_rules "https://github.com/mhollink/runemark/blob/main/packages/domain/src/equipment/equipment.ts"
click node_content_registry "https://github.com/mhollink/runemark/blob/main/packages/content/src/game-content.ts"
click node_activity_catalog "https://github.com/mhollink/runemark/blob/main/packages/content/src/activities/index.ts"
click node_item_catalog "https://github.com/mhollink/runemark/blob/main/packages/content/src/items/index.ts"
click node_save_manager "https://github.com/mhollink/runemark/blob/main/apps/web/src/game/persistence/save-manager.ts"
click node_save_repository "https://github.com/mhollink/runemark/blob/main/apps/web/src/game/persistence/save-repository.ts"
click node_indexed_db "https://github.com/mhollink/runemark/blob/main/apps/web/src/game/persistence/indexed-db-save-repository.ts"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_web,node_activities_ui,node_world_ui,node_character_ui,node_inventory_ui,node_offline_ui toneBlue
class node_command,node_simulation,node_activity_engine,node_combat_engine,node_travel_engine,node_route_finding,node_activity_session toneAmber
class node_game_state,node_inventory_rules,node_equipment_rules toneMint
class node_content_registry,node_activity_catalog,node_item_catalog toneRose
class node_save_manager,node_save_repository,node_indexed_db,node_player toneIndigo
```

## Components

### Web client

- [Game interface](https://github.com/mhollink/runemark/blob/main/apps/web/src/app/App.tsx): `apps/web/src/app/App.tsx`
- [Activities and combat](https://github.com/mhollink/runemark/tree/main/apps/web/src/features/activities): `apps/web/src/features/activities`
- [World and travel](https://github.com/mhollink/runemark/tree/main/apps/web/src/features/world): `apps/web/src/features/world`
- [Character and skills](https://github.com/mhollink/runemark/tree/main/apps/web/src/features/equipment): `apps/web/src/features/equipment`
- [Inventory and bank](https://github.com/mhollink/runemark/tree/main/apps/web/src/features/inventory): `apps/web/src/features/inventory`
- [Offline progress](https://github.com/mhollink/runemark/tree/main/apps/web/src/features/offline-progress): `apps/web/src/features/offline-progress`

### Game runtime

- [Command dispatch](https://github.com/mhollink/runemark/blob/main/packages/engine/src/commands/execute-command.ts): `packages/engine/src/commands/execute-command.ts`
- [Game simulation](https://github.com/mhollink/runemark/blob/main/packages/engine/src/simulation.ts): `packages/engine/src/simulation.ts`
- [Activity simulation](https://github.com/mhollink/runemark/tree/main/packages/engine/src/activities): `packages/engine/src/activities`
- [Combat simulation](https://github.com/mhollink/runemark/blob/main/packages/engine/src/activities/combat.ts): `packages/engine/src/activities/combat.ts`
- [Travel simulation](https://github.com/mhollink/runemark/blob/main/packages/engine/src/navigation/standalone-travel.ts): `packages/engine/src/navigation/standalone-travel.ts`
- [Route finding](https://github.com/mhollink/runemark/blob/main/packages/engine/src/navigation/find-route.ts): `packages/engine/src/navigation/find-route.ts`
- [Activity sessions](https://github.com/mhollink/runemark/blob/main/packages/engine/src/activities/shared/activity-session.ts): `packages/engine/src/activities/shared/activity-session.ts`

### Domain rules

- [Game state model](https://github.com/mhollink/runemark/blob/main/packages/domain/src/character/character.ts): `packages/domain/src/character/character.ts`
- [Inventory rules](https://github.com/mhollink/runemark/blob/main/packages/domain/src/inventory/inventory.ts): `packages/domain/src/inventory/inventory.ts`
- [Equipment rules](https://github.com/mhollink/runemark/blob/main/packages/domain/src/equipment/equipment.ts): `packages/domain/src/equipment/equipment.ts`

### Game content

- [Content registry](https://github.com/mhollink/runemark/blob/main/packages/content/src/game-content.ts): `packages/content/src/game-content.ts`
- [Activity definitions](https://github.com/mhollink/runemark/blob/main/packages/content/src/activities/index.ts): `packages/content/src/activities/index.ts`
- [Item definitions](https://github.com/mhollink/runemark/blob/main/packages/content/src/items/index.ts): `packages/content/src/items/index.ts`

### Save persistence

- [Save manager](https://github.com/mhollink/runemark/blob/main/apps/web/src/game/persistence/save-manager.ts): `apps/web/src/game/persistence/save-manager.ts`
- [Save repository](https://github.com/mhollink/runemark/blob/main/apps/web/src/game/persistence/save-repository.ts): `apps/web/src/game/persistence/save-repository.ts`
- [Browser save store](https://github.com/mhollink/runemark/blob/main/apps/web/src/game/persistence/indexed-db-save-repository.ts): `apps/web/src/game/persistence/indexed-db-save-repository.ts`

### Other components

- **Player**

## Connections

- Command dispatch → Game simulation: simulates first (evidence: `packages/engine/src/commands/execute-command.ts`)
- Command dispatch → Activity sessions: transitions session (evidence: `packages/engine/src/commands/execute-command.ts`)
- Command dispatch → Route finding: finds route (evidence: `packages/engine/src/commands/execute-command.ts`)
- Command dispatch → Travel simulation: creates travel (evidence: `packages/engine/src/commands/execute-command.ts`)
- Game simulation → Combat simulation: dispatches combat (evidence: `packages/engine/src/simulation.ts`)
- Game simulation → Activity simulation: dispatches gathering and production (evidence: `packages/engine/src/simulation.ts`)
- Game simulation → Travel simulation: simulates travel (evidence: `packages/engine/src/simulation.ts`)
- Game simulation → Content registry: uses content
- Activity sessions → Route finding: finds activity and bank routes (evidence: `packages/engine/src/activities/shared/activity-session.ts`)
- Content registry → Activity definitions: registers activities (evidence: `packages/content/src/game-content.ts`)
- Content registry → Item definitions: registers items (evidence: `packages/content/src/game-content.ts`)
- Save manager → Save repository: loads and saves (evidence: `apps/web/src/game/persistence/save-manager.ts`)
- Save manager → Save repository: validates loaded save (evidence: `apps/web/src/game/persistence/save-manager.ts`)
- Browser save store → Save repository: implements contract (evidence: `apps/web/src/game/persistence/indexed-db-save-repository.ts`)
- Inventory rules → Game state model: models backpack state (evidence: `packages/domain/src/character/character.ts`)
- Equipment rules → Inventory rules: moves items (evidence: `packages/domain/src/equipment/equipment.ts`)
- Player → Game interface: uses
