# cholopol/cholopol-tetris-inventory-system architecture

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

- Interactive diagram: https://gitdiagram.com/cholopol/cholopol-tetris-inventory-system
- Repository: https://github.com/cholopol/cholopol-tetris-inventory-system
- Video tour (about a minute): https://gitdiagram.com/cholopol/cholopol-tetris-inventory-system/video

## Overview

CTIS is a Godot/.NET grid-inventory system. Its main workflow is pointer interaction with item grids, inventory command validation and simulation, then projection of the resulting state into view models and Godot views. The broader product includes irregular-item geometry and hit testing, nested containers, auto-organization, floating-window/context-menu interactions, multi-slot saves, and a built-in data editor. Several links reflect README-described capabilities; sampled source confirms service dispatch/projection and save handling, but not all UI wiring.

Main entry points: [`addons/ctis/Core/Services/InventoryService.cs`](https://github.com/cholopol/cholopol-tetris-inventory-system/blob/main/addons/ctis/Core/Services/InventoryService.cs) (Inventory Service), [`addons/ctis/Core/Logic/InventorySimulation.cs`](https://github.com/cholopol/cholopol-tetris-inventory-system/blob/main/addons/ctis/Core/Logic/InventorySimulation.cs) (Command Simulation), [`addons/ctis/Core/Services/JsonSaveLoadService.cs`](https://github.com/cholopol/cholopol-tetris-inventory-system/blob/main/addons/ctis/Core/Services/JsonSaveLoadService.cs) (JSON Save Service), [`addons/ctis/Godot/Views/TetrisGridView.cs`](https://github.com/cholopol/cholopol-tetris-inventory-system/blob/main/addons/ctis/Godot/Views/TetrisGridView.cs) (Grid View)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interaction["Godot Interaction"]
  node_grid_view["Grid View<br/>[TetrisGridView.cs]"]
  node_pointer_session["Pointer Session"]
  node_shape_hit["Shape Hit Test<br/>[ShapeHitTest.cs]"]
  node_floating_windows["Floating Windows"]
  node_context_menu["Context Menu"]
  node_mobile_settings["Mobile Settings"]
end

subgraph group_inventory["Inventory Core"]
  node_inventory_service["Inventory Service"]
  node_commands["Inventory Commands"]
  node_simulation["Command Simulation"]
  node_inventory_logic["Placement Logic<br/>[InventoryLogic.cs]"]
  node_geometry["Shape Geometry<br/>[OccupancyBoard.cs]"]
end

subgraph group_state["State and Saves"]
  node_tree[("Inventory Tree")]
  node_catalog[("Item Catalog<br/>[CatalogStore.cs]")]
  node_vm_registry["Item VM Registry<br/>[ItemVmRegistry.cs]"]
  node_grid_vm["Grid View Models<br/>[TetrisGridVM.cs]"]
  node_save_service["JSON Save Service"]
  node_slot_store[("Save Slot Store")]
end

subgraph group_authoring["Data Authoring"]
  node_data_editor["Data Editor"]
  node_data_loaders["Data Loaders"]
end

node_player(("Player"))

node_player -->|"interacts with"| node_grid_view
node_grid_view -->|"handles pointer"| node_pointer_session
node_pointer_session -->|"issues commands"| node_inventory_service
node_grid_view -->|"tests shapes"| node_shape_hit
node_inventory_service -->|"applies command"| node_simulation
node_simulation -->|"updates state"| node_tree
node_simulation -->|"checks items"| node_catalog
node_simulation -->|"checks placement"| node_inventory_logic
node_inventory_service -->|"projects items"| node_vm_registry
node_inventory_service -->|"refreshes grids"| node_grid_vm
node_inventory_service -->|"reads state"| node_tree
node_geometry -->|"supports occupancy"| node_inventory_logic
node_context_menu -->|"opens item panels"| node_floating_windows
node_save_service -->|"reads and restores"| node_tree
node_save_service -->|"checks version"| node_catalog
node_save_service -->|"reads and writes"| node_slot_store
node_data_loaders -->|"loads catalog"| node_catalog
node_data_editor -.->|"edits data"| node_data_loaders

click node_grid_view "https://github.com/cholopol/cholopol-tetris-inventory-system/blob/main/addons/ctis/Godot/Views/TetrisGridView.cs"
click node_pointer_session "https://github.com/cholopol/cholopol-tetris-inventory-system/blob/main/addons/ctis/Godot/PointerGridSession.cs"
click node_shape_hit "https://github.com/cholopol/cholopol-tetris-inventory-system/blob/main/addons/ctis/Godot/ShapeHitTest.cs"
click node_floating_windows "https://github.com/cholopol/cholopol-tetris-inventory-system/blob/main/CTIS_Demo/demo/_Scripts/FloatingInventoryWindows.cs"
click node_context_menu "https://github.com/cholopol/cholopol-tetris-inventory-system/blob/main/CTIS_Demo/demo/_Scripts/ContextMenuWindow.cs"
click node_inventory_service "https://github.com/cholopol/cholopol-tetris-inventory-system/blob/main/addons/ctis/Core/Services/InventoryService.cs"
click node_commands "https://github.com/cholopol/cholopol-tetris-inventory-system/blob/main/addons/ctis/Core/Data/InventoryCommands.cs"
click node_simulation "https://github.com/cholopol/cholopol-tetris-inventory-system/blob/main/addons/ctis/Core/Logic/InventorySimulation.cs"
click node_inventory_logic "https://github.com/cholopol/cholopol-tetris-inventory-system/blob/main/addons/ctis/Core/Logic/InventoryLogic.cs"
click node_tree "https://github.com/cholopol/cholopol-tetris-inventory-system/blob/main/addons/ctis/Core/Services/InventoryTreeCache.cs"
click node_catalog "https://github.com/cholopol/cholopol-tetris-inventory-system/blob/main/addons/ctis/Core/Services/CatalogStore.cs"
click node_vm_registry "https://github.com/cholopol/cholopol-tetris-inventory-system/blob/main/addons/ctis/Core/Services/ItemVmRegistry.cs"
click node_grid_vm "https://github.com/cholopol/cholopol-tetris-inventory-system/blob/main/addons/ctis/Core/ViewModels/TetrisGridVM.cs"
click node_geometry "https://github.com/cholopol/cholopol-tetris-inventory-system/blob/main/addons/ctis/Core/Logic/OccupancyBoard.cs"
click node_save_service "https://github.com/cholopol/cholopol-tetris-inventory-system/blob/main/addons/ctis/Core/Services/JsonSaveLoadService.cs"
click node_slot_store "https://github.com/cholopol/cholopol-tetris-inventory-system/blob/main/addons/ctis/Godot/GodotSaveSlotStore.cs"
click node_data_editor "https://github.com/cholopol/cholopol-tetris-inventory-system/blob/main/addons/ctis/Godot/Editor/CtisDataEditorWindow.cs"
click node_data_loaders "https://github.com/cholopol/cholopol-tetris-inventory-system/blob/main/addons/ctis/Godot/Data/ItemCatalogLoader.cs"
click node_mobile_settings "https://github.com/cholopol/cholopol-tetris-inventory-system/blob/main/addons/ctis/Godot/Services/MobileSettingsManager.cs"

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_grid_view,node_pointer_session,node_shape_hit,node_floating_windows,node_context_menu,node_mobile_settings toneBlue
class node_inventory_service,node_commands,node_simulation,node_inventory_logic,node_geometry toneAmber
class node_tree,node_catalog,node_vm_registry,node_grid_vm,node_save_service,node_slot_store toneMint
class node_data_editor,node_data_loaders toneRose
class node_player toneIndigo
```

## Components

### Godot Interaction

- [Grid View](https://github.com/cholopol/cholopol-tetris-inventory-system/blob/main/addons/ctis/Godot/Views/TetrisGridView.cs): `addons/ctis/Godot/Views/TetrisGridView.cs`
- [Pointer Session](https://github.com/cholopol/cholopol-tetris-inventory-system/blob/main/addons/ctis/Godot/PointerGridSession.cs): `addons/ctis/Godot/PointerGridSession.cs`
- [Shape Hit Test](https://github.com/cholopol/cholopol-tetris-inventory-system/blob/main/addons/ctis/Godot/ShapeHitTest.cs): `addons/ctis/Godot/ShapeHitTest.cs`
- [Floating Windows](https://github.com/cholopol/cholopol-tetris-inventory-system/blob/main/CTIS_Demo/demo/_Scripts/FloatingInventoryWindows.cs): `CTIS_Demo/demo/_Scripts/FloatingInventoryWindows.cs`
- [Context Menu](https://github.com/cholopol/cholopol-tetris-inventory-system/blob/main/CTIS_Demo/demo/_Scripts/ContextMenuWindow.cs): `CTIS_Demo/demo/_Scripts/ContextMenuWindow.cs`
- [Mobile Settings](https://github.com/cholopol/cholopol-tetris-inventory-system/blob/main/addons/ctis/Godot/Services/MobileSettingsManager.cs): `addons/ctis/Godot/Services/MobileSettingsManager.cs`

### Inventory Core

- [Inventory Service](https://github.com/cholopol/cholopol-tetris-inventory-system/blob/main/addons/ctis/Core/Services/InventoryService.cs): `addons/ctis/Core/Services/InventoryService.cs`
- [Inventory Commands](https://github.com/cholopol/cholopol-tetris-inventory-system/blob/main/addons/ctis/Core/Data/InventoryCommands.cs): `addons/ctis/Core/Data/InventoryCommands.cs`
- [Command Simulation](https://github.com/cholopol/cholopol-tetris-inventory-system/blob/main/addons/ctis/Core/Logic/InventorySimulation.cs): `addons/ctis/Core/Logic/InventorySimulation.cs`
- [Placement Logic](https://github.com/cholopol/cholopol-tetris-inventory-system/blob/main/addons/ctis/Core/Logic/InventoryLogic.cs): `addons/ctis/Core/Logic/InventoryLogic.cs`
- [Shape Geometry](https://github.com/cholopol/cholopol-tetris-inventory-system/blob/main/addons/ctis/Core/Logic/OccupancyBoard.cs): `addons/ctis/Core/Logic/OccupancyBoard.cs`

### State and Saves

- [Inventory Tree](https://github.com/cholopol/cholopol-tetris-inventory-system/blob/main/addons/ctis/Core/Services/InventoryTreeCache.cs): `addons/ctis/Core/Services/InventoryTreeCache.cs`
- [Item Catalog](https://github.com/cholopol/cholopol-tetris-inventory-system/blob/main/addons/ctis/Core/Services/CatalogStore.cs): `addons/ctis/Core/Services/CatalogStore.cs`
- [Item VM Registry](https://github.com/cholopol/cholopol-tetris-inventory-system/blob/main/addons/ctis/Core/Services/ItemVmRegistry.cs): `addons/ctis/Core/Services/ItemVmRegistry.cs`
- [Grid View Models](https://github.com/cholopol/cholopol-tetris-inventory-system/blob/main/addons/ctis/Core/ViewModels/TetrisGridVM.cs): `addons/ctis/Core/ViewModels/TetrisGridVM.cs`
- [JSON Save Service](https://github.com/cholopol/cholopol-tetris-inventory-system/blob/main/addons/ctis/Core/Services/JsonSaveLoadService.cs): `addons/ctis/Core/Services/JsonSaveLoadService.cs`
- [Save Slot Store](https://github.com/cholopol/cholopol-tetris-inventory-system/blob/main/addons/ctis/Godot/GodotSaveSlotStore.cs): `addons/ctis/Godot/GodotSaveSlotStore.cs`

### Data Authoring

- [Data Editor](https://github.com/cholopol/cholopol-tetris-inventory-system/blob/main/addons/ctis/Godot/Editor/CtisDataEditorWindow.cs): `addons/ctis/Godot/Editor/CtisDataEditorWindow.cs`
- [Data Loaders](https://github.com/cholopol/cholopol-tetris-inventory-system/blob/main/addons/ctis/Godot/Data/ItemCatalogLoader.cs): `addons/ctis/Godot/Data/ItemCatalogLoader.cs`

### Other components

- **Player**

## Connections

- Player → Grid View: interacts with
- Grid View → Pointer Session: handles pointer
- Pointer Session → Inventory Service: issues commands
- Grid View → Shape Hit Test: tests shapes
- Inventory Service → Command Simulation: applies command
- Command Simulation → Inventory Tree: updates state
- Command Simulation → Item Catalog: checks items
- Command Simulation → Placement Logic: checks placement
- Inventory Service → Item VM Registry: projects items
- Inventory Service → Grid View Models: refreshes grids
- Inventory Service → Inventory Tree: reads state
- Shape Geometry → Placement Logic: supports occupancy
- Context Menu → Floating Windows: opens item panels
- JSON Save Service → Inventory Tree: reads and restores
- JSON Save Service → Item Catalog: checks version
- JSON Save Service → Save Slot Store: reads and writes
- Data Loaders → Item Catalog: loads catalog
- Data Editor → Data Loaders: edits data
